Browse code

CID 11939, 11940 - fixed resource leaks in sigtool

Kevin Lin authored on 2014/09/23 23:51:03
Showing 1 changed files
... ...
@@ -373,7 +373,7 @@ static char *getdsig(const char *host, const char *user, const unsigned char *da
373 373
 	    closesocket(sockd);
374 374
 	    return NULL;
375 375
 	} else {
376
-	    mprintf("Signature received (length = %lu)\n", strlen(buff) - 10);
376
+	    mprintf("Signature received (length = %lu)\n", (unsigned long)strlen(buff) - 10);
377 377
 	}
378 378
     } else {
379 379
 	mprintf("!getdsig: Communication error with remote server\n");
... ...
@@ -712,6 +712,7 @@ static int build(const struct optstruct *opts)
712 712
 			dblist2 = (char **) realloc(dblist2, (dblist2cnt + 1) * sizeof(char *));
713 713
 			if(!dblist2) { /* dblist2 leaked but we don't really care */
714 714
 			    mprintf("!build: Memory allocation error\n");
715
+                            closedir(dd);
715 716
 			    return -1;
716 717
 			}
717 718
 			dblist2[dblist2cnt] = strdup(dent->d_name);
... ...
@@ -847,6 +848,7 @@ static int build(const struct optstruct *opts)
847 847
 	mprintf("Builder name: ");
848 848
 	if(scanf("%32s", builder) == EOF || !pt) {
849 849
 	    mprintf("!build: Can't get builder name\n");
850
+	    free(dblist2);
850 851
 	    return -1;
851 852
 	}
852 853
     }