Fix a few fd leaks in isakmpd.
authordoug <doug@openbsd.org>
Mon, 25 Aug 2014 08:00:48 +0000 (08:00 +0000)
committerdoug <doug@openbsd.org>
Mon, 25 Aug 2014 08:00:48 +0000 (08:00 +0000)
The latter close is from a sweep of the tree looking for fdopen problems.
While reviewing the patch, gerhard@ fixed another leak.

ok gerhard@

sbin/isakmpd/ike_auth.c

index b009baf..bd122a6 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ike_auth.c,v 1.111 2014/08/23 00:48:57 doug Exp $  */
+/* $OpenBSD: ike_auth.c,v 1.112 2014/08/25 08:00:48 doug Exp $  */
 /* $EOM: ike_auth.c,v 1.59 2000/11/21 00:21:31 angelos Exp $    */
 
 /*
@@ -301,12 +301,14 @@ ignorekeynote:
 
                if (check_file_secrecy_fd(fd, keyfile, &fsize)) {
                        free(privkeyfile);
+                       close(fd);
                        return 0;
                }
 
                if ((keyfp = fdopen(fd, "r")) == NULL) {
                        log_print("ike_auth_get_key: fdopen failed");
                        free(privkeyfile);
+                       close(fd);
                        return 0;
                }
 #if SSLEAY_VERSION_NUMBER >= 0x00904100L