mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-22 08:02:08 +02:00
adding int overflow checks to vrefbuffer
This commit is contained in:
@@ -43,6 +43,10 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
|||||||
vbuf->end = array + nfirst;
|
vbuf->end = array + nfirst;
|
||||||
vbuf->array = array;
|
vbuf->array = array;
|
||||||
|
|
||||||
|
if((sizeof(msgpack_vrefbuffer_chunk) + chunk_size) < chunk_size){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
||||||
sizeof(msgpack_vrefbuffer_chunk) + chunk_size);
|
sizeof(msgpack_vrefbuffer_chunk) + chunk_size);
|
||||||
if(chunk == NULL) {
|
if(chunk == NULL) {
|
||||||
@@ -135,6 +139,9 @@ int msgpack_vrefbuffer_append_copy(msgpack_vrefbuffer* vbuf,
|
|||||||
sz = len;
|
sz = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((sizeof(msgpack_vrefbuffer_chunk) + sz) < sz){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
||||||
sizeof(msgpack_vrefbuffer_chunk) + sz);
|
sizeof(msgpack_vrefbuffer_chunk) + sz);
|
||||||
if(chunk == NULL) {
|
if(chunk == NULL) {
|
||||||
@@ -165,6 +172,10 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
|
|||||||
{
|
{
|
||||||
size_t sz = vbuf->chunk_size;
|
size_t sz = vbuf->chunk_size;
|
||||||
|
|
||||||
|
if((sizeof(msgpack_vrefbuffer_chunk) + sz) < sz){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
msgpack_vrefbuffer_chunk* empty = (msgpack_vrefbuffer_chunk*)malloc(
|
msgpack_vrefbuffer_chunk* empty = (msgpack_vrefbuffer_chunk*)malloc(
|
||||||
sizeof(msgpack_vrefbuffer_chunk) + sz);
|
sizeof(msgpack_vrefbuffer_chunk) + sz);
|
||||||
if(empty == NULL) {
|
if(empty == NULL) {
|
||||||
|
Reference in New Issue
Block a user