commit 861d4fc180b4b6648e5fd2ebb1e011720898b197
parent 0095352e537f5987d868b5807edc2034b250d7b9
Author: Naveen Narayanan <zerous@nocebo.space>
Date: Sat, 25 Sep 2021 17:20:52 +0200
Handle error from recv
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/finger.c b/finger.c
@@ -105,6 +105,11 @@ main(int argc, char **argv)
byt = recv(sockfd, msg, BUFSZ, 0);
for (int i = 0; i < byt; ++i)
putchar(msg[i]);
+ if (byt == -1) {
+ fprintf(stderr, "recv failed: %s\n",
+ strerror(errno));
+ goto err3;
+ }
} while (byt > 0);
}