From owner-svn-soc-all@FreeBSD.ORG Mon May 4 18:57:12 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8D11C6C1 for ; Mon, 4 May 2015 18:57:12 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7B78B1643 for ; Mon, 4 May 2015 18:57:12 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t44IvCou021846 for ; Mon, 4 May 2015 18:57:12 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t44IvBnB021843 for svn-soc-all@FreeBSD.org; Mon, 4 May 2015 18:57:11 GMT (envelope-from def@FreeBSD.org) Date: Mon, 4 May 2015 18:57:11 GMT Message-Id: <201505041857.t44IvBnB021843@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r285002 - soc2013/def/crashdump-head/sbin/cryptcore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2015 18:57:12 -0000 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);