diff options
| author | 2017-02-07 12:44:52 +0100 | |
|---|---|---|
| committer | 2017-02-07 12:44:52 +0100 | |
| commit | 56ba9bf7f625f6b72df982e7ef298b9791b1cf47 (patch) | |
| tree | 4d53004b4c7788e3c78d91e6a41f43ca568f800d | |
| parent | fbd8494d5e4e46bf2e90cb6116903e404374fb56 (diff) | |
| download | libplist-56ba9bf7f625f6b72df982e7ef298b9791b1cf47.tar.gz libplist-56ba9bf7f625f6b72df982e7ef298b9791b1cf47.tar.bz2 | |
bplist: Make sure to bail out if malloc() fails in parse_data_node()
Credit to OSS-Fuzz
| -rw-r--r-- | src/bplist.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/bplist.c b/src/bplist.c index 20e5090..c1f6007 100644 --- a/src/bplist.c +++ b/src/bplist.c | |||
| @@ -394,6 +394,11 @@ static plist_t parse_data_node(const char **bnode, uint64_t size) | |||
| 394 | data->type = PLIST_DATA; | 394 | data->type = PLIST_DATA; |
| 395 | data->length = size; | 395 | data->length = size; |
| 396 | data->buff = (uint8_t *) malloc(sizeof(uint8_t) * size); | 396 | data->buff = (uint8_t *) malloc(sizeof(uint8_t) * size); |
| 397 | if (!data->strval) { | ||
| 398 | plist_free_data(data); | ||
| 399 | PLIST_BIN_ERR("%s: Could not allocate %" PRIu64 " bytes\n", __func__, sizeof(uint8_t) * size); | ||
| 400 | return NULL; | ||
| 401 | } | ||
| 397 | memcpy(data->buff, *bnode, sizeof(uint8_t) * size); | 402 | memcpy(data->buff, *bnode, sizeof(uint8_t) * size); |
| 398 | 403 | ||
| 399 | return node_create(NULL, data); | 404 | return node_create(NULL, data); |
