Skip to content
Snippets Groups Projects
Commit 652c1584 authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

Update maximum expected return value form read_file_data()

from UINT32_MAX to INT32_MAX to avoid signed comparison issues when compiled
for 32-bit systems.
parent 0a1260af
No related branches found
No related tags found
1 merge request!34Update cmp_tool to version v0.13
......@@ -1393,7 +1393,7 @@ ssize_t read_file_data(const char *file_name, enum cmp_data_type data_type,
int err;
size = read_file8(file_name, (uint8_t *)buf, buf_size, flags);
if (size > UINT32_MAX)
if (size > INT32_MAX)
return -1;
if (size < 0)
......
......@@ -362,7 +362,7 @@ int main(int argc, char **argv)
int32_t samples;
size = read_file_data(data_file_name, cfg.data_type, NULL, 0, io_flags);
if (size <= 0 || size > UINT32_MAX) /* empty file is treated as an error */
if (size <= 0 || size > INT32_MAX) /* empty file is treated as an error */
goto fail;
samples = cmp_input_size_to_samples((uint32_t)size, cfg.data_type);
if (samples < 0)
......@@ -374,7 +374,7 @@ int main(int argc, char **argv)
input_size = cmp_cal_size_of_data(cfg.samples, cfg.data_type);
} else {
size = read_file_data(data_file_name, cfg.data_type, NULL, 0, io_flags);
if (size <= 0 || size > UINT32_MAX) /* empty file is treated as an error */
if (size <= 0 || size > INT32_MAX) /* empty file is treated as an error */
goto fail;
input_size = (uint32_t)size;
}
......@@ -433,7 +433,7 @@ int main(int argc, char **argv)
printf("Importing compressed data file %s ... ", data_file_name);
size = read_file_cmp_entity(data_file_name, NULL, 0, io_flags);
if (size < 0 || size > UINT32_MAX)
if (size < 0 || size > INT32_MAX)
goto fail;
/* to be save allocate at least the size of the cmp_entity struct */
buf_size = (size_t)size;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment