diff options
| author | 2023-04-10 15:12:09 +0200 | |
|---|---|---|
| committer | 2023-04-10 15:12:09 +0200 | |
| commit | aa0b8732aa375440b81e176dcc868ed3540c302d (patch) | |
| tree | df49b09197b2e7e229881988855626f2c0e8bf13 | |
| parent | Added image attachments. (diff) | |
| parent | Merge pull request 'Fix some overflow bugs' (#29) from saagarjha/snac2:master... (diff) | |
| download | penes-snac2-aa0b8732aa375440b81e176dcc868ed3540c302d.tar.gz penes-snac2-aa0b8732aa375440b81e176dcc868ed3540c302d.tar.xz penes-snac2-aa0b8732aa375440b81e176dcc868ed3540c302d.zip | |
Merge https://codeberg.org/grunfink/snac2
| -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) | |||
| 1057 | xs_data *v; | 1057 | xs_data *v; |
| 1058 | 1058 | ||
| 1059 | /* add the overhead (data type + 24bit size) */ | 1059 | /* add the overhead (data type + 24bit size) */ |
| 1060 | size += 4; | 1060 | int total_size = size + 4; |
| 1061 | 1061 | ||
| 1062 | v = xs_realloc(NULL, _xs_blk_size(size)); | 1062 | v = xs_realloc(NULL, _xs_blk_size(total_size)); |
| 1063 | v[0] = XSTYPE_DATA; | 1063 | v[0] = XSTYPE_DATA; |
| 1064 | 1064 | ||
| 1065 | _xs_put_24b(v + 1, size); | 1065 | _xs_put_24b(v + 1, total_size); |
| 1066 | 1066 | ||
| 1067 | memcpy(&v[4], data, size); | 1067 | memcpy(&v[4], data, size); |
| 1068 | 1068 | ||
| @@ -55,7 +55,7 @@ static int _data_callback(void *buffer, size_t size, | |||
| 55 | 55 | ||
| 56 | /* open space */ | 56 | /* open space */ |
| 57 | pd->size += sz; | 57 | pd->size += sz; |
| 58 | pd->data = xs_realloc(pd->data, pd->size + 1); | 58 | pd->data = xs_realloc(pd->data, _xs_blk_size(pd->size + 1)); |
| 59 | 59 | ||
| 60 | /* copy data */ | 60 | /* copy data */ |
| 61 | memcpy(pd->data + pd->offset, buffer, sz); | 61 | memcpy(pd->data + pd->offset, buffer, sz); |