antirez / antirez/lua-cmsgpack

mp_buf_append and sanitizing realloc

Aperta
#66 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C
Stelle
383
Fork
122
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I noticed mp_buf_append and mp_buf_new are not sanitizing the result to [mp_realloc](https://github.com/antirez/lua-cmsgpack/blob/master/lua_cmsgpack.c#L122).

The Lua documentation states that when the pointer is non-null is must behave like realloc (and in the default case it is: `return realloc(ptr, nsize)`). In turn, when realloc fails the original block is left untouched and NULL is returned, which paths into a memcpy (and likely segmenta.... fau.. or something else entirely dependent on `buf->len`).

While a minor issue, a bit of defensive programming here would not hurt.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.