socsvn commit: r285002 - soc2013/def/crashdump-head/sbin/cryptcore

def at FreeBSD.org def at FreeBSD.org
Mon May 4 18:57:12 UTC 2015


Author: def
Date: Mon May  4 18:57:11 2015
New Revision: 285002
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=285002

Log:
  Remove file descriptor leaks.

Modified:
  soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c

Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c
==============================================================================
--- soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c	Mon May  4 17:59:39 2015	(r285001)
+++ soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c	Mon May  4 18:57:11 2015	(r285002)
@@ -107,6 +107,8 @@
 	PJDLOG_ASSERT(input != NULL);
 	PJDLOG_ASSERT(output != NULL);
 
+	ofd = -1;
+	fd = -1;
 	privkey = RSA_new();
 	if (privkey == NULL)
 		pjdlog_exitx(1, "Unable to allocate an RSA structure.");
@@ -118,6 +120,7 @@
 	size = (int)read(fd, ciphertext, KERNELDUMP_CIPHERTEXT_SIZE);
 	err = errno;
 	close(fd);
+	fd = -1;
 	if (size != KERNELDUMP_CIPHERTEXT_SIZE) {
 		errno = err;
 		pjdlog_exit(1, "Unable to read data from %s", keyfile);
@@ -195,6 +198,10 @@
 
 	return;
 failed:
+	if (ofd >= 0)
+		close(ofd);
+	if (fd >= 0)
+		close(fd);
 	bzero(buf, KERNELDUMP_KEY_SIZE + KERNELDUMP_IV_SIZE);
 	EVP_CIPHER_CTX_cleanup(&ctx);
 	RSA_free(privkey);


More information about the svn-soc-all mailing list