diff --git a/src/shared/protocol.c b/src/shared/protocol.c index 4146078..1e5cb7f 100644 --- a/src/shared/protocol.c +++ b/src/shared/protocol.c @@ -182,10 +182,16 @@ bool send_data(int file_descriptor, const Data* data) { return true; } +#define MAX_DATA_SIZE (1024ULL * 1024 * 1024) + Data* receive_data(int file_descriptor) { unsigned long long size = 0; if (!receive_n_data(file_descriptor, &size, sizeof(unsigned long long))) return NULL; + if ((size_t)size != size || size > MAX_DATA_SIZE) { + log_message(LOG_LEVEL_ERROR, "receive_data size %llu exceeds limits", size); + return NULL; + } void* data = malloc((size_t)size); if (data == NULL) return NULL;