[hackers] [quark] Fortify error-cases || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 12 Aug 2014 19:15:47 +0200

commit 8001703f501a0c1ff503d8743bcc28520d1aa945
Author: FRIGN <dev_AT_frign.de>
Date: Tue Aug 12 19:17:19 2014 +0200

    Fortify error-cases
    
    We don't want to play with our luck here.

diff --git a/quark.c b/quark.c
index 5a4c69b..361cb18 100644
--- a/quark.c
+++ b/quark.c
_AT_@ -95,7 +95,7 @@ static char reqbuf[MAXBUFLEN+1];
 static char resbuf[MAXBUFLEN+1];
 static char reqhost[256];
 static char reqmod[256];
-static int fd;
+static int fd = -1;
 static Request req;
 
 char *
_AT_@ -504,7 +504,7 @@ sighandler(int sig) {
 
 int
 main(int argc, char *argv[]) {
- struct addrinfo hints, *ai;
+ struct addrinfo hints, *ai = NULL;
         struct passwd *upwd;
         struct group *gpwd;
         int i;
_AT_@ -595,7 +595,7 @@ main(int argc, char *argv[]) {
         freeaddrinfo(ai);
         return EXIT_SUCCESS;
 err:
- if (fd)
+ if (fd != -1)
                 close(fd);
         if (ai)
                 freeaddrinfo(ai);
Received on Tue Aug 12 2014 - 19:15:47 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 12 2014 - 19:24:09 CEST