From 83322372fb3d62225f0ac733f63d5dd21e8685c0 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Mon, 23 May 2011 15:42:10 -0500 Subject: [PATCH] tests: Correctly pass string args in superuser-t We need to give a NULL pointer for string OUT arguments, so XDR knows to allocate a new string. Also free the string each time so it gets set back to NULL. Change-Id: I1eb0c63dc4019b855a2cbecd9e35393f2fbb0fd7 Reviewed-on: http://gerrit.openafs.org/4708 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- tests/auth/superuser-t.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/auth/superuser-t.c b/tests/auth/superuser-t.c index 3d3bda0..c2ebbc6 100644 --- a/tests/auth/superuser-t.c +++ b/tests/auth/superuser-t.c @@ -123,7 +123,7 @@ startClient(char *configPath) struct hostent *he; afs_uint32 addr; afs_int32 result; - char *string; + char *string = NULL; plan(63); @@ -255,6 +255,8 @@ startClient(char *configPath) is_int(0, code, "Can get identity back"); is_string("", string, "Forged token is super user"); + xdr_free((xdrproc_t)xdr_string, &string); + /* Throw away this connection and security class */ rx_DestroyConnection(conn); rxs_Release(class); @@ -275,9 +277,11 @@ startClient(char *configPath) is_int(EPERM, code, "Running new interface RPC as non-super user fails as expected"); code = TEST_WhoAmI(conn, &string); + xdr_free((xdrproc_t)xdr_string, &string); is_int(EPERM, code, "Running RPC returning string fails as expected"); code = TEST_NewWhoAmI(conn, &string); + xdr_free((xdrproc_t)xdr_string, &string); is_int(EPERM, code, "Running new interface RPC returning string fails as expected"); ok(afsconf_AddUser(dir, "rpctest") == 0, @@ -289,9 +293,11 @@ startClient(char *configPath) code = TEST_WhoAmI(conn, &string); is_int(0, code, "Running RPC returning string as %s works", "rpctest"); is_string("rpctest", string, "Returned user string matches"); + xdr_free((xdrproc_t)xdr_string, &string); code = TEST_NewWhoAmI(conn, &string); is_int(0, code, "Running new RPC returning string as %s works", "rpctest"); is_string("rpctest", string, "Returned user string for new interface matches"); + xdr_free((xdrproc_t)xdr_string, &string); rx_DestroyConnection(conn); rxs_Release(class); @@ -310,9 +316,11 @@ startClient(char *configPath) is_int(EPERM, code, "Running new interface RPC as non-super user fails as expected"); code = TEST_WhoAmI(conn, &string); + xdr_free((xdrproc_t)xdr_string, &string); is_int(EPERM, code, "Running RPC returning string fails as expected"); code = TEST_NewWhoAmI(conn, &string); + xdr_free((xdrproc_t)xdr_string, &string); is_int(EPERM, code, "Running new interface RPC returning string fails as expected"); @@ -326,11 +334,13 @@ startClient(char *configPath) code = TEST_WhoAmI(conn, &string); is_int(0, code, "Running RPC returning string as %s works", "rpctest/admin"); is_string("rpctest.admin", string, "Returned user string matches"); + xdr_free((xdrproc_t)xdr_string, &string); code = TEST_NewWhoAmI(conn, &string); is_int(0, code, "Running new interface RPC returning string as %s works", "rpctest/admin"); is_string("rpctest.admin", string, "Returned user string from new interface matches"); + xdr_free((xdrproc_t)xdr_string, &string); rx_DestroyConnection(conn); rxs_Release(class); -- 1.9.4