Windows: MSRPC_WriteMessage, call MSRPC_NewCall at right time
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 25 Aug 2009 19:46:01 +0000 (12:46 -0700)
committerJeffrey Altman <jaltman|account-1000011@unknown>
Tue, 25 Aug 2009 20:25:18 +0000 (13:25 -0700)
In MSRPC_WriteMessage, call MSRPC_NewCall after checking for
MAX_RPC_MSG_SIZE and return an error if MSRPC_NewCall fails.

LICENSE MIT

Reviewed-on: http://gerrit.openafs.org/339
Reviewed-by: Asanka Herath <asanka@secure-endpoints.com>
Tested-by: Asanka Herath <asanka@secure-endpoints.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/msrpc.c

index f430ffa..035ec26 100644 (file)
@@ -972,18 +972,20 @@ MSRPC_FreeConn(msrpc_conn * conn)
  */
 int
 MSRPC_WriteMessage(msrpc_conn * conn, BYTE * buffer, unsigned int len,
-                  cm_user_t * userp)
+                   cm_user_t * userp)
 {
     msrpc_call * call;
 
     if (len == 0)
        return CM_ERROR_INVAL;
 
-    call = MSRPC_NewCall();
-
     if (len > MAX_RPC_MSG_SIZE)
        return CM_ERROR_BUFFERTOOSMALL;
 
+    call = MSRPC_NewCall();
+    if (!call)
+        return ENOMEM;
+
     MSRPC_AllocBuffer(&call->in, len);
     memcpy(call->in.buf_data, buffer, len);
     call->in.buf_pos = len;