From: Simon Wilkinson Date: Sat, 31 Mar 2012 18:59:47 +0000 (-0400) Subject: auth: Don't leak key on file parse error X-Git-Tag: openafs-stable-1_8_0pre1~2590 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=be8d8b7c78eb54f460489084650ba13f3946d7a2;hp=8f39150b2718d5d758ba9d02bf3becd9c8947120 auth: Don't leak key on file parse error If we fail for any reason whilst parsing the keyfile from disk, don't leak the key structure which we allocated to store the results of the parse. Change-Id: I21a27723f96af9428465134cfb975c83e10da535 Reviewed-on: http://gerrit.openafs.org/7102 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/auth/keys.c b/src/auth/keys.c index 52d1265..ba6843d 100644 --- a/src/auth/keys.c +++ b/src/auth/keys.c @@ -458,7 +458,7 @@ _parseExtendedKeyFile(struct afsconf_dir *dir, char *fileName) { int fd, i, code; afs_int32 nkeys; - struct afsconf_typedKey *key; + struct afsconf_typedKey *key = NULL; fd = open(fileName, O_RDONLY); if (fd < 0) @@ -530,6 +530,9 @@ _parseExtendedKeyFile(struct afsconf_dir *dir, char *fileName) return 0; fail: + if (key) + afsconf_typedKey_put(&key); + close(fd); return EIO; }