svn rev #25265: trunk/src/ccapi/ common/win/ lib/win/ server/win/

hartmans@MIT.EDU hartmans at MIT.EDU
Wed Sep 28 16:55:53 EDT 2011


http://src.mit.edu/fisheye/changelog/krb5/?cs=25265
Commit By: hartmans
Log Message:
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 <kevin.wasserman at painless-security.com>


Changed Files:
U   trunk/src/ccapi/common/win/ccs_reply.Idl
U   trunk/src/ccapi/common/win/ccs_request.idl
U   trunk/src/ccapi/lib/win/ccapi_os_ipc.cxx
U   trunk/src/ccapi/lib/win/ccs_reply_proc.c
U   trunk/src/ccapi/server/win/ccs_os_server.cpp
U   trunk/src/ccapi/server/win/ccs_request_proc.c
U   trunk/src/ccapi/server/win/ccs_win_pipe.c
U   trunk/src/ccapi/server/win/ccs_win_pipe.h
Modified: trunk/src/ccapi/common/win/ccs_reply.Idl
===================================================================
--- trunk/src/ccapi/common/win/ccs_reply.Idl	2011-09-28 20:55:49 UTC (rev 25264)
+++ trunk/src/ccapi/common/win/ccs_reply.Idl	2011-09-28 20:55:53 UTC (rev 25265)
@@ -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(

Modified: trunk/src/ccapi/common/win/ccs_request.idl
===================================================================
--- trunk/src/ccapi/common/win/ccs_request.idl	2011-09-28 20:55:49 UTC (rev 25264)
+++ trunk/src/ccapi/common/win/ccs_request.idl	2011-09-28 20:55:53 UTC (rev 25265)
@@ -36,7 +36,7 @@
 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 */

Modified: trunk/src/ccapi/lib/win/ccapi_os_ipc.cxx
===================================================================
--- trunk/src/ccapi/lib/win/ccapi_os_ipc.cxx	2011-09-28 20:55:49 UTC (rev 25264)
+++ trunk/src/ccapi/lib/win/ccapi_os_ipc.cxx	2011-09-28 20:55:53 UTC (rev 25265)
@@ -148,6 +148,7 @@
     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 @@
             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 @@
     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 @@
 
     // 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 */
             }

Modified: trunk/src/ccapi/lib/win/ccs_reply_proc.c
===================================================================
--- trunk/src/ccapi/lib/win/ccs_reply_proc.c	2011-09-28 20:55:49 UTC (rev 25264)
+++ trunk/src/ccapi/lib/win/ccs_reply_proc.c	2011-09-28 20:55:53 UTC (rev 25265)
@@ -44,13 +44,13 @@
     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 */
         }

Modified: trunk/src/ccapi/server/win/ccs_os_server.cpp
===================================================================
--- trunk/src/ccapi/server/win/ccs_os_server.cpp	2011-09-28 20:55:49 UTC (rev 25264)
+++ trunk/src/ccapi/server/win/ccs_os_server.cpp	2011-09-28 20:55:53 UTC (rev 25265)
@@ -318,7 +318,7 @@
 
     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_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 {

Modified: trunk/src/ccapi/server/win/ccs_request_proc.c
===================================================================
--- trunk/src/ccapi/server/win/ccs_request_proc.c	2011-09-28 20:55:49 UTC (rev 25264)
+++ trunk/src/ccapi/server/win/ccs_request_proc.c	2011-09-28 20:55:53 UTC (rev 25265)
@@ -42,8 +42,8 @@
     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 @@
     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);

Modified: trunk/src/ccapi/server/win/ccs_win_pipe.c
===================================================================
--- trunk/src/ccapi/server/win/ccs_win_pipe.c	2011-09-28 20:55:49 UTC (rev 25264)
+++ trunk/src/ccapi/server/win/ccs_win_pipe.c	2011-09-28 20:55:53 UTC (rev 25265)
@@ -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 @@
 
 /* ------------------------------------------------------------------------ */
 
-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;}

Modified: trunk/src/ccapi/server/win/ccs_win_pipe.h
===================================================================
--- trunk/src/ccapi/server/win/ccs_win_pipe.h	2011-09-28 20:55:49 UTC (rev 25264)
+++ trunk/src/ccapi/server/win/ccs_win_pipe.h	2011-09-28 20:55:53 UTC (rev 25265)
@@ -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_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_




More information about the cvs-krb5 mailing list