rx: Make identity and opaque usable with NULL vals

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>
This commit is contained in:
Simon Wilkinson 2012-04-21 11:24:25 +01:00 committed by Derrick Brashear
parent 5815a04cf1
commit e1eb0fd66a
2 changed files with 8 additions and 2 deletions

View 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);
}

View 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;