Prevent hang when caller does not pass large enough buffer.
This commit is contained in:
		| @@ -2268,22 +2268,21 @@ int32_t ipc_ReadBinaryKey | |||||||
|         } |         } | ||||||
|         else |         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; |             *bytesRequired = dataLen; | ||||||
|             { |             { | ||||||
|                 // Cleanup the channel by reading the remaining and return error. |                 // Cleanup the channel by reading the remaining and return error. | ||||||
|                 int n; |                 int n; | ||||||
|                 n = dataLen + MSG_DWORD_LEN;  |                 n = dataLen;  | ||||||
|                 while(n) |                 while(n) | ||||||
|                 { |                 { | ||||||
|                     int bytes = IPC_READ(ssHandle->platHandle, gpReplyBuf, MIN_REPLY_BUF_LEN); |                     int bytesRead = IPC_READ(ssHandle->platHandle, gpReplyBuf, n); | ||||||
|                     if( bytes > 0) |                     if( bytesRead > 0) | ||||||
|                         n -= bytes; |                         n -= bytesRead; | ||||||
|                     else |                     else | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
|                 // Read the sscs return code also. |  | ||||||
| //                IPC_READ(ssHandle->platHandle, (Byte *) &sockReturn, MSG_DWORD_LEN); |  | ||||||
|                 retCode = NSSCS_E_ENUM_BUFF_TOO_SHORT; |                 retCode = NSSCS_E_ENUM_BUFF_TOO_SHORT; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user