From a738c8dcff8410d82b631a0e71c23b8447db9a0d Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Mon, 23 Jul 2012 22:07:38 -0400 Subject: [PATCH] ptuser: pr_SNameToId/SIdToName: if RPC response empty, force error If the prserver returns an empty response to ubik_PR_NameToID or ubik_PR_IDToName, but doesn't otherwise give an error, force a PRINTERNAL error return so that the client knows that the the return parameter was not updated. Existing callers seem to expect this, as pr_SNameToId is often called without initializing the variable which receives the result and checking only for the error code. PRINTERNAL is a new error code. Change-Id: I3e598a22deb39792a0f208ac09b3c1991d6f1e58 Reviewed-on: http://gerrit.openafs.org/7836 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/ptserver/pterror.et | 1 + src/ptserver/ptuser.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/ptserver/pterror.et b/src/ptserver/pterror.et index 4b066ae9b..ab3f1e846 100644 --- a/src/ptserver/pterror.et +++ b/src/ptserver/pterror.et @@ -30,4 +30,5 @@ error_table PT ec PRDBADDR, "bad database address" ec PRTOOMANY, "too many elements in group" ec PRNOMEM, "malloc failed to alloc enough memory" + ec PRINTERNAL, "Protection library internal error" end diff --git a/src/ptserver/ptuser.c b/src/ptserver/ptuser.c index 6c84e266f..3fb545a1b 100644 --- a/src/ptserver/ptuser.c +++ b/src/ptserver/ptuser.c @@ -507,6 +507,8 @@ pr_SNameToId(char name[PR_MAXNAMELEN], afs_int32 *id) if (lids.idlist_val) { *id = *lids.idlist_val; xdr_free((xdrproc_t) xdr_idlist, &lids); + } else if (code == 0) { + code = PRINTERNAL; } if (lnames.namelist_val) free(lnames.namelist_val); @@ -538,6 +540,8 @@ pr_SIdToName(afs_int32 id, char name[PR_MAXNAMELEN]) if (lnames.namelist_val) strncpy(name, lnames.namelist_val[0], PR_MAXNAMELEN); + else if (code == 0) + code = PRINTERNAL; if (lids.idlist_val) free(lids.idlist_val); -- 2.39.5