From e1eb0fd66af158b86aec9c21cda836d84bc21c59 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sat, 21 Apr 2012 11:24:25 +0100 Subject: [PATCH] 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 Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear --- src/rx/rx_identity.c | 7 +++++-- src/rx/rx_opaque.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rx/rx_identity.c b/src/rx/rx_identity.c index ae9c694d19..3d87ec4364 100644 --- a/src/rx/rx_identity.c +++ b/src/rx/rx_identity.c @@ -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); } diff --git a/src/rx/rx_opaque.c b/src/rx/rx_opaque.c index db3e407063..0b3ee2dd34 100644 --- a/src/rx/rx_opaque.c +++ b/src/rx/rx_opaque.c @@ -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;