From 089b7d5cfabb70f37f769e06499985cb6c0280d3 Mon Sep 17 00:00:00 2001 From: deraadt Date: Sat, 2 Jul 2022 16:06:56 +0000 Subject: [PATCH] Avoid c99 features, come on, this is supposed to be highly portable software ok florian --- usr.sbin/nsd/configparser.y | 5 +++-- usr.sbin/nsd/nsd-checkconf.c | 6 ++++-- usr.sbin/nsd/server.c | 9 +++++---- usr.sbin/nsd/verify.c | 9 ++++++--- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/usr.sbin/nsd/configparser.y b/usr.sbin/nsd/configparser.y index f0d165c071e..eda10a66f11 100644 --- a/usr.sbin/nsd/configparser.y +++ b/usr.sbin/nsd/configparser.y @@ -1059,14 +1059,15 @@ command: { char **argv; size_t argc = 1; - for(struct component *i = $2; i; i = i->next) { + struct component *i, *j; + for(i = $2; i; i = i->next) { argc++; } argv = region_alloc_zero( cfg_parser->opt->region, (argc + 1) * sizeof(char *)); argc = 0; argv[argc++] = $1; - for(struct component *j, *i = $2; i; i = j) { + for(i = $2; i; i = j) { j = i->next; argv[argc++] = i->str; region_recycle(cfg_parser->opt->region, i, sizeof(*i)); diff --git a/usr.sbin/nsd/nsd-checkconf.c b/usr.sbin/nsd/nsd-checkconf.c index a286b5cff86..7467db18ab4 100644 --- a/usr.sbin/nsd/nsd-checkconf.c +++ b/usr.sbin/nsd/nsd-checkconf.c @@ -557,8 +557,9 @@ static void print_zone_content_elems(pattern_options_type* pat) } } if(pat->verifier) { + char *const *s; printf("\tverifier:"); - for(char *const *s = pat->verifier; *s; s++) { + for(s = pat->verifier; *s; s++) { printf(" \"%s\"", *s); } printf("\n"); @@ -725,8 +726,9 @@ config_test_print_server(nsd_options_type* opt) printf("\tport: %s\n", opt->verify_port); printf("\tverify-zones: %s\n", opt->verify_zones?"yes":"no"); if(opt->verifier) { + char **s; printf("\tverifier:"); - for(char **s = opt->verifier; *s; s++) { + for(s = opt->verifier; *s; s++) { printf(" \"%s\"", *s); } printf("\n"); diff --git a/usr.sbin/nsd/server.c b/usr.sbin/nsd/server.c index 18fc6d4c0ec..ef5004984b0 100644 --- a/usr.sbin/nsd/server.c +++ b/usr.sbin/nsd/server.c @@ -3026,6 +3026,7 @@ void server_verify(struct nsd *nsd, int cmdsocket) size_t size = 0; struct event cmd_event, signal_event, exit_event; struct zone *zone; + size_t i; assert(nsd != NULL); @@ -3045,7 +3046,7 @@ void server_verify(struct nsd *nsd, int cmdsocket) fcntl(nsd->verifier_pipe[1], F_SETFD, FD_CLOEXEC); nsd->verifiers = region_alloc_zero(nsd->server_region, size); - for(size_t i = 0; i < nsd->verifier_limit; i++) { + for(i = 0; i < nsd->verifier_limit; i++) { nsd->verifiers[i].nsd = nsd; nsd->verifiers[i].zone = NULL; nsd->verifiers[i].pid = -1; @@ -3080,7 +3081,7 @@ void server_verify(struct nsd *nsd, int cmdsocket) } memset(msgs, 0, sizeof(msgs)); - for (int i = 0; i < NUM_RECV_PER_SELECT; i++) { + for (i = 0; i < NUM_RECV_PER_SELECT; i++) { queries[i] = query_create(nsd->server_region, compressed_dname_offsets, compression_table_size, compressed_dnames); @@ -3093,7 +3094,7 @@ void server_verify(struct nsd *nsd, int cmdsocket) msgs[i].msg_hdr.msg_namelen = queries[i]->addrlen; } - for (size_t i = 0; i < nsd->verify_ifs; i++) { + for (i = 0; i < nsd->verify_ifs; i++) { struct udp_handler_data *data; data = region_alloc_zero( nsd->server_region, sizeof(*data)); @@ -3104,7 +3105,7 @@ void server_verify(struct nsd *nsd, int cmdsocket) tcp_accept_handlers = region_alloc_array(nsd->server_region, nsd->verify_ifs, sizeof(*tcp_accept_handlers)); - for (size_t i = 0; i < nsd->verify_ifs; i++) { + for (i = 0; i < nsd->verify_ifs; i++) { struct tcp_accept_handler_data *data; data = &tcp_accept_handlers[i]; memset(data, 0, sizeof(*data)); diff --git a/usr.sbin/nsd/verify.c b/usr.sbin/nsd/verify.c index f8c21f59ee3..eed30c2174c 100644 --- a/usr.sbin/nsd/verify.c +++ b/usr.sbin/nsd/verify.c @@ -290,6 +290,7 @@ void verify_handle_exit(int fd, short event, void *arg) pid_t pid; struct nsd *nsd; char buf[1]; + size_t i; assert(event & EV_READ); assert(arg != NULL); @@ -303,7 +304,7 @@ void verify_handle_exit(int fd, short event, void *arg) { struct verifier *verifier = NULL; - for(size_t i = 0; !verifier && i < nsd->verifier_limit; i++) { + for(i = 0; !verifier && i < nsd->verifier_limit; i++) { if(nsd->verifiers[i].zone != NULL && nsd->verifiers[i].pid == pid) { @@ -362,6 +363,7 @@ verify_handle_command(int fd, short event, void *arg) struct nsd *nsd = (struct nsd *)arg; int len; sig_atomic_t mode; + size_t i; assert(nsd != NULL); assert(event & (EV_READ @@ -390,7 +392,7 @@ verify_handle_command(int fd, short event, void *arg) } /* kill verifiers, processes reaped elsewhere */ - for(size_t i = 0; i < nsd->verifier_limit; i++) { + for(i = 0; i < nsd->verifier_limit; i++) { if(nsd->verifiers[i].zone != NULL) { kill_verifier(&nsd->verifiers[i]); } @@ -410,6 +412,7 @@ void verify_zone(struct nsd *nsd, struct zone *zone) char **command; FILE *fin; int fdin, fderr, fdout, flags; + size_t i; assert(nsd != NULL); assert(nsd->verifier_count < nsd->verifier_limit); @@ -419,7 +422,7 @@ void verify_zone(struct nsd *nsd, struct zone *zone) fdin = fdout = fderr = -1; /* search for available verifier slot */ - for(size_t i = 0; i < nsd->verifier_limit && !verifier; i++) { + for(i = 0; i < nsd->verifier_limit && !verifier; i++) { if(nsd->verifiers[i].zone == NULL) { verifier = &nsd->verifiers[i]; } -- 2.20.1