auth: Handle memory errors when parsing key file
authorSimon Wilkinson <sxw@your-file-system.com>
Tue, 12 Feb 2013 12:24:44 +0000 (12:24 +0000)
committerDerrick Brashear <shadow@your-file-system.com>
Wed, 20 Feb 2013 19:39:09 +0000 (11:39 -0800)
Return an IO error if we run out of memory whilst parsing a key file

Caught by clang-analyzer

Change-Id: I783a193fe9315f08d76d1be9b1c77089df25fd64
Reviewed-on: http://gerrit.openafs.org/9146
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/auth/keys.c

index 13bb647..9bfa67a 100644 (file)
@@ -365,6 +365,8 @@ _parseOriginalKeyFile(struct afsconf_dir *dir, char *fileName)
     for(i=0; i<nkeys; i++) {
 
        key = afsconf_typedKey_blank();
+       if (key == NULL)
+           goto fail;
 
        key->type = afsconf_rxkad;
        key->subType = 0;
@@ -473,6 +475,8 @@ _parseExtendedKeyFile(struct afsconf_dir *dir, char *fileName)
        afs_int32 reclen;
 
        key = afsconf_typedKey_blank();
+       if (key == NULL)
+           goto fail;
 
        /* The only data version we currently parse has a reclen of 16.
         * Anything smaller indicates a corrupt key file. Anything more,