From 1a9dbcf032a9536273cc62e283b82985645fc668 Mon Sep 17 00:00:00 2001 From: James Brister Date: Thu, 28 Oct 1999 17:53:16 +0000 Subject: [PATCH] Save port numbers in host-byte order. memset unused areas of isc_sockaddr_t --- lib/dns/config/confctl.c | 4 ++-- lib/dns/config/confctx.c | 5 ++--- lib/dns/config/confip.c | 1 + lib/dns/config/conflsn.c | 4 ++-- lib/dns/config/confparser.y | 11 ++++++----- lib/dns/config/confzone.c | 8 ++++---- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/dns/config/confctl.c b/lib/dns/config/confctl.c index 8956458942..c0e7e0bb9e 100644 --- a/lib/dns/config/confctl.c +++ b/lib/dns/config/confctl.c @@ -261,10 +261,10 @@ dns_c_ctrl_print(isc_log_t *lctx, fprintf(fp, "inet "); dns_c_print_ipaddr(lctx, fp, &ctl->u.inet_v.addr); - if (port == htons(0)) { + if (port == 0) { fprintf(fp, " port *\n"); } else { - fprintf(fp, " port %d\n", (int)ntohs(port)); + fprintf(fp, " port %d\n", port); } dns_c_printtabs(lctx, fp, indent + 1); diff --git a/lib/dns/config/confctx.c b/lib/dns/config/confctx.c index ba4ba2a550..e74b71dded 100644 --- a/lib/dns/config/confctx.c +++ b/lib/dns/config/confctx.c @@ -3200,11 +3200,10 @@ dns_c_ctx_optionsprint(isc_log_t *lctx, fprintf(fp, "query-source address "); dns_c_print_ipaddr(lctx, fp, &options->query_source_addr); - if (options->query_source_port == htons(0)) { + if (options->query_source_port == 0) { fprintf(fp, " port *"); } else { - fprintf(fp, " port %d", - (int)ntohs(options->query_source_port)); + fprintf(fp, " port %d", options->query_source_port); } fprintf(fp, " ;\n"); } diff --git a/lib/dns/config/confip.c b/lib/dns/config/confip.c index 347784f329..0ac4b2b8f4 100644 --- a/lib/dns/config/confip.c +++ b/lib/dns/config/confip.c @@ -946,6 +946,7 @@ dns_c_iplist_append(isc_log_t *lctx, return (ISC_R_NOMEMORY); } + memset(newlist, 0x0, newbytes); memcpy(newlist, list->ips, oldbytes); isc_mem_put(list->mem, list->ips, oldbytes); diff --git a/lib/dns/config/conflsn.c b/lib/dns/config/conflsn.c index 5c9bde8595..953bc9291d 100644 --- a/lib/dns/config/conflsn.c +++ b/lib/dns/config/conflsn.c @@ -211,8 +211,8 @@ dns_c_lstnon_print(isc_log_t *lctx, FILE *fp, int indent, dns_c_lstnon_t *lo) CHECK_LISTEN(lo); fprintf(fp, "listen-on "); - if (lo->port != htons(DNS_C_DEFAULTPORT)) { - fprintf(fp, "port %d ", (int)ntohs(lo->port)); + if (lo->port != DNS_C_DEFAULTPORT) { + fprintf(fp, "port %d ", lo->port); } dns_c_ipmatchlist_print(lctx, fp, indent + 1, lo->iml); diff --git a/lib/dns/config/confparser.y b/lib/dns/config/confparser.y index 63e30088c2..4fe843c669 100644 --- a/lib/dns/config/confparser.y +++ b/lib/dns/config/confparser.y @@ -17,7 +17,7 @@ */ #if !defined(lint) && !defined(SABER) -static char rcsid[] = "$Id: confparser.y,v 1.15 1999/10/28 02:25:22 halley Exp $"; +static char rcsid[] = "$Id: confparser.y,v 1.16 1999/10/28 17:53:15 brister Exp $"; #endif /* not lint */ #include @@ -1067,7 +1067,7 @@ maybe_wild_port: in_port } | L_STRING { - $$ = htons(0); + $$ = 0; if (strcmp ($1, "*") != 0) { parser_error(ISC_TRUE, @@ -1114,7 +1114,7 @@ query_source: query_source_address maybe_port: /* nothing */ { - $$ = htons(DNS_C_DEFAULTPORT); + $$ = DNS_C_DEFAULTPORT; } | L_PORT in_port { @@ -1124,7 +1124,7 @@ maybe_port: /* nothing */ maybe_zero_port : /* nothing */ { - $$ = htons(0); + $$ = 0; } | L_PORT in_port { @@ -2132,6 +2132,7 @@ address_match_simple: ip_address } else { ia.s_addr = htonl(($1 & 0xff) << 24); + memset(&address, 0x0, sizeof address); address.type.sin.sin_family = AF_INET; address.type.sin.sin_addr = ia; @@ -3235,7 +3236,7 @@ in_port: L_INTEGER (int)$1); $1 = 0; } else { - $$ = htons((isc_uint16_t)$1); + $$ = $1; } } ; diff --git a/lib/dns/config/confzone.c b/lib/dns/config/confzone.c index 292a5b3f89..6879b69551 100644 --- a/lib/dns/config/confzone.c +++ b/lib/dns/config/confzone.c @@ -2594,8 +2594,8 @@ slave_zone_print(isc_log_t *lctx, FILE *fp, int indent, dns_c_printtabs(lctx, fp, indent); fprintf(fp, "masters "); if (DNS_C_CHECKBIT(SZ_MASTER_PORT_BIT, &szone->setflags)) { - if (ntohs(szone->master_port) != 0) { - fprintf(fp, "port %d ", ntohs(szone->master_port)); + if (szone->master_port != 0) { + fprintf(fp, "port %d ", szone->master_port); } } if (szone->master_ips == NULL || @@ -2683,8 +2683,8 @@ stub_zone_print(isc_log_t *lctx, FILE *fp, int indent, dns_c_stubzone_t *szone) dns_c_printtabs(lctx, fp, indent); fprintf(fp, "masters "); if (DNS_C_CHECKBIT(TZ_MASTER_PORT_BIT, &szone->setflags)) { - if (ntohs(szone->master_port) != 0) { - fprintf(fp, "port %d ", ntohs(szone->master_port)); + if (szone->master_port != 0) { + fprintf(fp, "port %d ", szone->master_port); } } if (szone->master_ips == NULL ||