From 2c20d775162fc96bc71258a0eb0dda3c644de74f Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Tue, 18 Jun 2024 01:00:57 +0200 Subject: [PATCH] Always check the values returned by fdopen(3) --- whois.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/whois.c b/whois.c index 1afe313..fe73f00 100644 --- a/whois.c +++ b/whois.c @@ -801,6 +801,8 @@ char *do_query(const int sock, const char *query) strcat(temp, "\r\n"); fi = fdopen(sock, "r"); + if (!fi) + err_sys("fdopen"); if (write(sock, temp, strlen(temp)) < 0) err_sys("write"); free(temp); @@ -875,6 +877,8 @@ char *query_crsnic(const int sock, const char *query) strcat(temp, "\r\n"); fi = fdopen(sock, "r"); + if (!fi) + err_sys("fdopen"); if (write(sock, temp, strlen(temp)) < 0) err_sys("write"); free(temp); @@ -928,6 +932,8 @@ char *query_afilias(const int sock, const char *query) strcat(temp, "\r\n"); fi = fdopen(sock, "r"); + if (!fi) + err_sys("fdopen"); if (write(sock, temp, strlen(temp)) < 0) err_sys("write"); free(temp); @@ -980,6 +986,8 @@ char *query_iana(const int sock, const char *query) strcat(temp, "\r\n"); fi = fdopen(sock, "r"); + if (!fi) + err_sys("fdopen"); if (write(sock, temp, strlen(temp)) < 0) err_sys("write"); free(temp);