rx: Make identity and opaque usable with NULL vals
authorSimon Wilkinson <sxw@your-file-system.com>
Sat, 21 Apr 2012 10:24:25 +0000 (11:24 +0100)
committerDerrick Brashear <shadow@dementix.org>
Sun, 22 Apr 2012 13:18:40 +0000 (06:18 -0700)
Make it possible to have NULL values for elements of the rx_identity
and rx_opaque structures.

Change-Id: I3624d490d92da3cf75da5edb91c7d4e5ce1fa937
Reviewed-on: http://gerrit.openafs.org/7260
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/rx/rx_identity.c
src/rx/rx_opaque.c

index ae9c694..3d87ec4 100644 (file)
@@ -79,8 +79,11 @@ rx_identity_populate(struct rx_identity *identity, rx_identity_kind kind,
     memset(identity, 0, sizeof(struct rx_identity));
 
     identity->kind = kind;
-    identity->displayName = rxi_Alloc(strlen(displayName)+1);
-    memcpy(identity->displayName, displayName, strlen(displayName)+1);
+
+    if (displayName) {
+       identity->displayName = rxi_Alloc(strlen(displayName)+1);
+       memcpy(identity->displayName, displayName, strlen(displayName)+1);
+    }
 
     rx_opaque_populate(&identity->exportedName, enameData, enameLength);
 }
index db3e407..0b3ee2d 100644 (file)
@@ -110,6 +110,9 @@ rx_opaque_populate(struct rx_opaque *to, void *data, size_t datalen)
     to->len = 0;
     to->val = NULL;
 
+    if (data == NULL || datalen == 0)
+       return 0;
+
     code = rx_opaque_alloc(to, datalen);
     if (code)
         return code;