if (dp_ipc_read(sock, &array_size, extra_size, __FUNCTION__) < 0) {
errorcode = DP_ERROR_IO_ERROR;
} else {
- if (array_size <= 0) {
+ if (array_size <= 0 && array_size >= SIZE_MAX) {
errorcode = DP_ERROR_NO_DATA;
*length = 0;
} else {
#include <download-provider-plugin-download-agent.h>
#include <download-provider-smack.h>
+#ifndef SIZE_MAX
+#define SIZE_MAX ((size_t) - 1)
+#endif
+
char *dp_print_state(int state)
{
switch (state) {
TRACE_ERROR("there is a confusion waiting raw binary in %s section", dp_print_property(ipc_info->property));
errorcode = DP_ERROR_IO_ERROR;
}
- if (raw_info != NULL && raw_info->size > 0) {
+ if (raw_info != NULL && raw_info->size > 0 && raw_info->size < SIZE_MAX) {
unsigned char *recv_raws = (unsigned char *)calloc(raw_info->size, sizeof(unsigned char));
if (recv_raws == NULL) {
TRACE_ERROR("sock:%d check memory length:%d", client->channel, raw_info->size);