mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Wrap inet_ntop() and use that in the _totext() functions. The wrapper calls
inet_ntop() and copies the output (but not the trailing null) into the buffer.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: rdata.c,v 1.141 2001/01/09 21:51:20 bwelling Exp $ */
|
||||
/* $Id: rdata.c,v 1.142 2001/01/25 20:14:36 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <ctype.h>
|
||||
@@ -107,6 +107,9 @@ name_length(dns_name_t *name);
|
||||
static isc_result_t
|
||||
str_totext(const char *source, isc_buffer_t *target);
|
||||
|
||||
static isc_result_t
|
||||
inet_totext(int af, isc_region_t *src, isc_buffer_t *target);
|
||||
|
||||
static isc_boolean_t
|
||||
buffer_empty(isc_buffer_t *source);
|
||||
|
||||
@@ -1469,6 +1472,19 @@ str_totext(const char *source, isc_buffer_t *target) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
inet_totext(int af, isc_region_t *src, isc_buffer_t *target) {
|
||||
char tmpbuf[64];
|
||||
|
||||
/* Note - inet_ntop doesn't do size checking on its input. */
|
||||
if (inet_ntop(af, src->base, tmpbuf, sizeof(tmpbuf)) == NULL)
|
||||
return (ISC_R_NOSPACE);
|
||||
if (strlen(tmpbuf) > isc_buffer_availablelength(target))
|
||||
return (ISC_R_NOSPACE);
|
||||
isc_buffer_putstr(target, tmpbuf);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static isc_boolean_t
|
||||
buffer_empty(isc_buffer_t *source) {
|
||||
return((source->current == source->active) ? ISC_TRUE : ISC_FALSE);
|
||||
|
Reference in New Issue
Block a user