From c62ce742de5fc86e8def098fb37ed66bbbe9acc8 Mon Sep 17 00:00:00 2001 From: Jim Norman Date: Fri, 29 Sep 2006 22:22:26 +0000 Subject: [PATCH] Prevent hang when caller does not pass large enough buffer. --- CASA/micasacache/sscs_unx_ipc_client.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CASA/micasacache/sscs_unx_ipc_client.c b/CASA/micasacache/sscs_unx_ipc_client.c index 75b538a9..ecde063e 100644 --- a/CASA/micasacache/sscs_unx_ipc_client.c +++ b/CASA/micasacache/sscs_unx_ipc_client.c @@ -2268,22 +2268,21 @@ int32_t ipc_ReadBinaryKey } else { - //buffer allocated by application is not sufficient to hold the data. + //buffer allocated by application is not sufficient to hold the data. *bytesRequired = dataLen; { // Cleanup the channel by reading the remaining and return error. int n; - n = dataLen + MSG_DWORD_LEN; + n = dataLen; while(n) { - int bytes = IPC_READ(ssHandle->platHandle, gpReplyBuf, MIN_REPLY_BUF_LEN); - if( bytes > 0) - n -= bytes; + int bytesRead = IPC_READ(ssHandle->platHandle, gpReplyBuf, n); + if( bytesRead > 0) + n -= bytesRead; else break; } - // Read the sscs return code also. -// IPC_READ(ssHandle->platHandle, (Byte *) &sockReturn, MSG_DWORD_LEN); + retCode = NSSCS_E_ENUM_BUFF_TOO_SHORT; break; }