From 734d527f6d3a6a5a49564ebe8e4b118867086b39 Mon Sep 17 00:00:00 2001 From: Jan Schaumann Date: Sat, 8 Jul 2023 13:19:44 -0400 Subject: [PATCH 1/3] add a space after the comma in an error message --- examples/ldns-walk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ldns-walk.c b/examples/ldns-walk.c index 3710098a..41879e6f 100644 --- a/examples/ldns-walk.c +++ b/examples/ldns-walk.c @@ -570,7 +570,7 @@ main(int argc, char *argv[]) if (!rrlist) { fflush(stdout); fprintf(stderr, "Zone does not seem to be DNSSEC secured," - "or it uses NSEC3.\n"); + " or it uses NSEC3.\n"); fflush(stderr); goto exit; } From 236bf3a0cf46325e5832212f6277d5f0efd75eca Mon Sep 17 00:00:00 2001 From: Jan Schaumann Date: Mon, 10 Jul 2023 23:14:27 -0400 Subject: [PATCH 2/3] add '\n' to error messages --- examples/ldns-walk.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/ldns-walk.c b/examples/ldns-walk.c index 41879e6f..8d767723 100644 --- a/examples/ldns-walk.c +++ b/examples/ldns-walk.c @@ -324,7 +324,7 @@ main(int argc, char *argv[]) /* create a new resolver from /etc/resolv.conf */ if(!serv) { if (ldns_resolver_new_frm_file(&res, NULL) != LDNS_STATUS_OK) { - fprintf(stderr, "%s", "Could not create resolver obj"); + fprintf(stderr, "%s\n", "Could not create resolver obj."); result = EXIT_FAILURE; goto exit; } @@ -345,7 +345,7 @@ main(int argc, char *argv[]) status = ldns_resolver_new_frm_file(&cmdline_res, NULL); if (status != LDNS_STATUS_OK) { - fprintf(stderr, "%s", "@server ip could not be converted"); + fprintf(stderr, "%s\n", "@server ip could not be converted"); result = EXIT_FAILURE; goto exit; } @@ -359,7 +359,7 @@ main(int argc, char *argv[]) ldns_rdf_deep_free(cmdline_dname); ldns_resolver_deep_free(cmdline_res); if (!cmdline_rr_list) { - fprintf(stderr, "%s %s", "could not find any address for the name: ", serv); + fprintf(stderr, "%s %s\n", "Could not find any address for the name:", serv); result = EXIT_FAILURE; goto exit; } else { @@ -367,7 +367,7 @@ main(int argc, char *argv[]) res, cmdline_rr_list ) != LDNS_STATUS_OK) { - fprintf(stderr, "%s", "pushing nameserver"); + fprintf(stderr, "%s\n", "pushing nameserver"); result = EXIT_FAILURE; ldns_rr_list_deep_free(cmdline_rr_list); goto exit; @@ -376,7 +376,7 @@ main(int argc, char *argv[]) } } else { if (ldns_resolver_push_nameserver(res, serv_rdf) != LDNS_STATUS_OK) { - fprintf(stderr, "%s", "pushing nameserver"); + fprintf(stderr, "%s\n", "pushing nameserver"); result = EXIT_FAILURE; goto exit; } else { From 3cc12cb4cb88b6feeb4dd24e57acfa7b65ed93e5 Mon Sep 17 00:00:00 2001 From: Jan Schaumann Date: Thu, 8 Aug 2024 12:20:25 -0400 Subject: [PATCH 3/3] send errors to stderr --- drill/drill.c | 2 +- masterdont/server.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drill/drill.c b/drill/drill.c index 44c1b768..9db77cf1 100644 --- a/drill/drill.c +++ b/drill/drill.c @@ -855,7 +855,7 @@ main(int argc, char *argv[]) status = ldns_send_buffer(&pkt, res, query_buffer, NULL); ldns_buffer_free(query_buffer); if (status != LDNS_STATUS_OK) { - printf("Error: %s\n", ldns_get_errorstr_by_id(status)); + fprintf(stderr, "Error: %s\n", ldns_get_errorstr_by_id(status)); exit(1); } } else { diff --git a/masterdont/server.c b/masterdont/server.c index a78ec6c2..e0f13f34 100644 --- a/masterdont/server.c +++ b/masterdont/server.c @@ -240,23 +240,23 @@ handle_listen(struct server_info_t *sinfo, struct socket_service* listen_v) int newfd; if(sinfo->num_tcp >= MAX_TCP) { - printf("Error: incoming tcp query, but MAX_TCP reached (%d)\n", + fprintf(stderr, "Error: incoming tcp query, but MAX_TCP reached (%d)\n", MAX_TCP); return; } if((newfd=accept(listen_v->s, NULL, NULL)) == -1) { - printf("Error tcp accept: %s", strerror(errno)); + fprintf(stderr, "Error tcp accept: %s", strerror(errno)); return; } if(fcntl(newfd, F_SETFL, O_NONBLOCK) == -1) { - printf("Error fcntl: %s\n", strerror(errno)); + fprintf(stderr, "Error fcntl: %s\n", strerror(errno)); close(newfd); return; } sh = (struct socket_service*)malloc(sizeof(struct socket_service)); if(!sh) { - printf("out of memory\n"); + fprintf(stderr, "malloc: %s\n", strerror(errno)); close(newfd); return; }