auth: Make afsconf_PutTypedKeyList idempotent 07/13507/4
authorAndrew Deason <adeason@sinenomine.net>
Sat, 2 Feb 2019 05:25:02 +0000 (23:25 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Sat, 23 Mar 2019 22:43:57 +0000 (18:43 -0400)
Currently, if we call afsconf_PutTypedKeyList on a key list, we set
the key list to NULL. But then if we call afsconf_PutTypedKeyList on a
NULL key list, we segfault because we try to dereference the list.

Change afsconf_PutTypedKeyList to be a noop if we give it a NULL list,
avoiding a segfault in such a situation.

Change-Id: I2c1de0c0a05ab036667031eb0e765933917826a6
Reviewed-on: https://gerrit.openafs.org/13507
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/auth/keys.c

index 54ad955..b1959c7 100644 (file)
@@ -1006,6 +1006,10 @@ afsconf_PutTypedKeyList(struct afsconf_typedKeyList **keys)
 {
      int i;
 
+     if (*keys == NULL) {
+        return;
+     }
+
      for (i=0;i<(*keys)->nkeys;i++)
        afsconf_typedKey_put(&((*keys)->keys[i]));