From 22196688fbdc5c3e196339df665dfc95bae8d5a7 Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Wed, 28 Sep 2011 20:55:53 +0000 Subject: Fix ccapi rpc methods to always pass 8 byte handles instead of sizeof(void*). ccapi server always stores all 8 bytes, whether compiled as 32 bit or 64 bit. If 32 bit, client zero-pads handle when sending and truncates when receiving. Signed-off-by: Kevin Wasserman git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25265 dc483132-0cff-0310-8789-dd5450dbe970 --- src/ccapi/common/win/ccs_reply.Idl | 2 +- src/ccapi/common/win/ccs_request.idl | 2 +- src/ccapi/lib/win/ccapi_os_ipc.cxx | 9 +++++++-- src/ccapi/lib/win/ccs_reply_proc.c | 4 ++-- src/ccapi/server/win/ccs_os_server.cpp | 4 ++-- src/ccapi/server/win/ccs_request_proc.c | 6 +++--- src/ccapi/server/win/ccs_win_pipe.c | 8 ++++---- src/ccapi/server/win/ccs_win_pipe.h | 6 +++--- 8 files changed, 23 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/ccapi/common/win/ccs_reply.Idl b/src/ccapi/common/win/ccs_reply.Idl index 9035a4d..73e8186 100644 --- a/src/ccapi/common/win/ccs_reply.Idl +++ b/src/ccapi/common/win/ccs_reply.Idl @@ -33,7 +33,7 @@ */ interface ccs_reply { - const long HSIZE = sizeof(void*); + const long HSIZE = 8; /* The reply from the server to a request from the client: */ void ccs_rpc_request_reply( diff --git a/src/ccapi/common/win/ccs_request.idl b/src/ccapi/common/win/ccs_request.idl index 8c68fd8..cad5e44 100644 --- a/src/ccapi/common/win/ccs_request.idl +++ b/src/ccapi/common/win/ccs_request.idl @@ -36,7 +36,7 @@ typedef unsigned char CC_UCHAR; typedef int CC_INT32; typedef unsigned int CC_UINT32; -const long HSIZE = sizeof(void*); +const long HSIZE = 8; void ccs_rpc_request( [in] const long rpcmsg, /* Message type */ diff --git a/src/ccapi/lib/win/ccapi_os_ipc.cxx b/src/ccapi/lib/win/ccapi_os_ipc.cxx index 062558c..7359eb0 100644 --- a/src/ccapi/lib/win/ccapi_os_ipc.cxx +++ b/src/ccapi/lib/win/ccapi_os_ipc.cxx @@ -148,6 +148,7 @@ extern "C" cc_int32 cci_os_ipc_msg( cc_int32 in_launch_server, PROCESS_INFORMATION pi = { 0 }; HANDLE replyEvent = 0; BOOL bCCAPI_Connected= FALSE; + unsigned char tspdata_handle[8] = { 0 }; if (!in_request_stream) { err = cci_check_error (ccErrBadParam); } if (!out_reply_stream ) { err = cci_check_error (ccErrBadParam); } @@ -196,9 +197,11 @@ extern "C" cc_int32 cci_os_ipc_msg( cc_int32 in_launch_server, cci_debug_printf("%s calling remote ccs_rpc_request tsp*:0x%X", __FUNCTION__, ptspdata); cci_debug_printf(" rpcmsg:%d; UUID[%d]:<%s> SST:%ld", in_msg, lenUUID, uuid, sst); #endif + /* copy ptr into handle; ptr may be 4 or 8 bytes, depending on platform; handle is always 8 */ + memcpy(tspdata_handle, &ptspdata, sizeof(ptspdata)); ccs_rpc_request( /* make call with user message: */ in_msg, /* Message type */ - (unsigned char*)&ptspdata, /* Our tspdata* will be sent back to the reply proc. */ + tspdata_handle, /* Our tspdata* will be sent back to the reply proc. */ (unsigned char*)uuid, krb5int_ipc_stream_size(in_request_stream), (unsigned char*)krb5int_ipc_stream_data(in_request_stream), /* Data buffer */ @@ -263,6 +266,7 @@ cc_int32 ccapi_connect(const struct tspdata* tsp) { HANDLE replyEvent = 0; RPC_STATUS status = FALSE; char* uuid = NULL; + unsigned char tspdata_handle[8] = {0}; /* Start listening to our uuid before establishing the connection, * so that when the server tries to call ccapi_listen, we will be ready. @@ -338,10 +342,11 @@ cc_int32 ccapi_connect(const struct tspdata* tsp) { // New code using new RPC procedures for sending the data and receiving a reply: if (!status) { + memcpy(tspdata_handle, &tsp, sizeof(tsp)); RpcTryExcept { ccs_rpc_connect( /* make call with user message: */ CCMSG_CONNECT, /* Message type */ - (unsigned char*)&tsp, /* Our tspdata* will be sent back to the reply proc. */ + tspdata_handle, /* Our tspdata* will be sent back to the reply proc. */ (unsigned char*)uuid, (long*)(&status) ); /* Return code */ } diff --git a/src/ccapi/lib/win/ccs_reply_proc.c b/src/ccapi/lib/win/ccs_reply_proc.c index b0fe037..bf8c7f4 100644 --- a/src/ccapi/lib/win/ccs_reply_proc.c +++ b/src/ccapi/lib/win/ccs_reply_proc.c @@ -44,13 +44,13 @@ void ccs_rpc_request_reply( long* ret_status ) { /* Return code */ HANDLE hEvent = openThreadEvent(uuid, REPLY_SUFFIX); - DWORD* p = (DWORD*)(tspHandle); - struct tspdata* tsp = (struct tspdata*)*p; + struct tspdata* tsp; k5_ipc_stream stream; long status = 0; #if 0 cci_debug_printf("%s! msg#:%d SST:%ld uuid:%s", __FUNCTION__, rpcmsg, srvStartTime, uuid); #endif + memcpy(&tsp, tspHandle, sizeof(tsp)); if (!status) { status = krb5int_ipc_stream_new (&stream); /* Create a stream for the request data */ } diff --git a/src/ccapi/server/win/ccs_os_server.cpp b/src/ccapi/server/win/ccs_os_server.cpp index e069587..b9c70a9 100644 --- a/src/ccapi/server/win/ccs_os_server.cpp +++ b/src/ccapi/server/win/ccs_os_server.cpp @@ -318,7 +318,7 @@ cc_int32 ccs_os_server_send_reply (ccs_pipe_t in_pipe, cc_int32 err = 0; char* uuid = ccs_win_pipe_getUuid(in_pipe); - HANDLE h = ccs_win_pipe_getHandle(in_pipe); + UINT64 h = ccs_win_pipe_getHandle(in_pipe); if (!err) { err = send_init(uuid); // Sets RPC handle to be used. @@ -619,7 +619,7 @@ RPC_STATUS send_finish() { RPC_STATUS send_connection_reply(ccs_pipe_t in_pipe) { char* uuid = ccs_win_pipe_getUuid (in_pipe); - HANDLE h = ccs_win_pipe_getHandle(in_pipe); + UINT64 h = ccs_win_pipe_getHandle(in_pipe); RPC_STATUS status = send_init(uuid); RpcTryExcept { diff --git a/src/ccapi/server/win/ccs_request_proc.c b/src/ccapi/server/win/ccs_request_proc.c index bdd691e..461c441 100644 --- a/src/ccapi/server/win/ccs_request_proc.c +++ b/src/ccapi/server/win/ccs_request_proc.c @@ -42,8 +42,8 @@ void ccs_rpc_request( long* return_status ) { /* Return code */ cc_int32 status = 0; - k5_ipc_stream stream; - DWORD* p = (DWORD*)(tspHandle); + k5_ipc_stream stream; + UINT64* p = (UINT64*)(tspHandle); WIN_PIPE* pipe = NULL; #if 0 cci_debug_printf("%s rpcmsg:%d; UUID:<%s> SST:<%s>", __FUNCTION__, rpcmsg, pszUUID, serverStartTime); @@ -70,7 +70,7 @@ void ccs_rpc_connect( const char* pszUUID, /* Data buffer */ long* return_status ) { /* Return code */ - DWORD* p = (DWORD*)(tspHandle); + UINT64* p = (UINT64*)(tspHandle); WIN_PIPE* pipe = ccs_win_pipe_new(pszUUID, *p); #if 0 cci_debug_printf("%s; rpcmsg:%d; UUID: <%s>", __FUNCTION__, rpcmsg, pszUUID); diff --git a/src/ccapi/server/win/ccs_win_pipe.c b/src/ccapi/server/win/ccs_win_pipe.c index 9cbfa9c..d23e444 100644 --- a/src/ccapi/server/win/ccs_win_pipe.c +++ b/src/ccapi/server/win/ccs_win_pipe.c @@ -33,13 +33,13 @@ /* Ref: struct ccs_win_pipe_t { char* uuid; - HANDLE clientHandle; + UINT64 clientHandle; } */ /* ------------------------------------------------------------------------ */ -struct ccs_win_pipe_t* ccs_win_pipe_new (const char* uuid, const HANDLE h) { +struct ccs_win_pipe_t* ccs_win_pipe_new (const char* uuid, const UINT64 h) { cc_int32 err = ccNoError; struct ccs_win_pipe_t* out_pipe = NULL; @@ -153,9 +153,9 @@ char* ccs_win_pipe_getUuid (const WIN_PIPE* in_pipe) { /* ------------------------------------------------------------------------ */ -HANDLE ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe) { +UINT64 ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe) { - HANDLE result = NULL; + UINT64 result = 0; if (!ccs_win_pipe_valid(in_pipe)) {cci_check_error(ccErrBadParam);} else {result = in_pipe->clientHandle;} diff --git a/src/ccapi/server/win/ccs_win_pipe.h b/src/ccapi/server/win/ccs_win_pipe.h index e5fb837..fef9995 100644 --- a/src/ccapi/server/win/ccs_win_pipe.h +++ b/src/ccapi/server/win/ccs_win_pipe.h @@ -44,12 +44,12 @@ struct ccs_win_pipe_t { char* uuid; - HANDLE clientHandle; + UINT64 clientHandle; }; typedef struct ccs_win_pipe_t WIN_PIPE; -struct ccs_win_pipe_t* ccs_win_pipe_new(const char* uuid, const HANDLE h); +struct ccs_win_pipe_t* ccs_win_pipe_new(const char* uuid, const UINT64 h); cc_int32 ccs_win_pipe_release (const WIN_PIPE* io_pipe); @@ -63,6 +63,6 @@ cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, cc_int32 ccs_win_pipe_valid (const WIN_PIPE* in_pipe); char* ccs_win_pipe_getUuid (const WIN_PIPE* in_pipe); -HANDLE ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe); +UINT64 ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe); #endif // _ccs_win_pipe_h_ -- cgit v1.1