diff options
author | grunfink <grunfink@noreply.codeberg.org> | 2023-04-10 13:11:34 +0000 |
---|---|---|
committer | grunfink <grunfink@noreply.codeberg.org> | 2023-04-10 13:11:34 +0000 |
commit | 5ae107188f1587d09bb52b3b6c5d661bcfb1724d (patch) | |
tree | fa4bc80525da91bfe9da28704e21a4c9efe1c77d | |
parent | 74817a4552e41a34644ec869c6ff7578854fac74 (diff) | |
parent | ea9c030249cb3db7a923c8e546df9897e0a39384 (diff) |
Merge pull request 'Fix some overflow bugs' (#29) from saagarjha/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/29
-rw-r--r-- | xs.h | 6 | ||||
-rw-r--r-- | xs_curl.h | 2 |
2 files changed, 4 insertions, 4 deletions
@@ -1057,12 +1057,12 @@ xs_data *xs_data_new(const void *data, int size) xs_data *v; /* add the overhead (data type + 24bit size) */ - size += 4; + int total_size = size + 4; - v = xs_realloc(NULL, _xs_blk_size(size)); + v = xs_realloc(NULL, _xs_blk_size(total_size)); v[0] = XSTYPE_DATA; - _xs_put_24b(v + 1, size); + _xs_put_24b(v + 1, total_size); memcpy(&v[4], data, size); @@ -55,7 +55,7 @@ static int _data_callback(void *buffer, size_t size, /* open space */ pd->size += sz; - pd->data = xs_realloc(pd->data, pd->size + 1); + pd->data = xs_realloc(pd->data, _xs_blk_size(pd->size + 1)); /* copy data */ memcpy(pd->data + pd->offset, buffer, sz); |