module/script: Fix buffer overflow when reading script data

This commit is contained in:
Miles Breslin 2024-01-23 00:33:32 -08:00
parent c4e094de3e
commit c9581ad712

View file

@ -299,7 +299,7 @@ data_received(struct module *mod, const char *data, size_t len)
struct private *m = mod->private; struct private *m = mod->private;
if (len > m->recv_buf.sz - m->recv_buf.idx) { if (len > m->recv_buf.sz - m->recv_buf.idx) {
size_t new_sz = m->recv_buf.sz == 0 ? 1024 : m->recv_buf.sz * 2; size_t new_sz = m->recv_buf.sz == 0 ? m->recv_buf.idx + len : m->recv_buf.sz * 2;
char *new_buf = realloc(m->recv_buf.data, new_sz); char *new_buf = realloc(m->recv_buf.data, new_sz);
if (new_buf == NULL) if (new_buf == NULL)