winedbg: Force read data to be NUL terminated.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2020-03-31 15:12:26 +02:00 committed by Alexandre Julliard
parent 3192fb5396
commit 46ec0b956d
1 changed files with 3 additions and 1 deletions

View File

@ -1848,12 +1848,14 @@ static int fetch_data(struct gdb_context* gdbctx)
if (gdbctx->in_len + STEP > gdbctx->in_buf_alloc)
gdbctx->in_buf = packet_realloc(gdbctx->in_buf, gdbctx->in_buf_alloc += STEP);
#undef STEP
len = read(gdbctx->sock, gdbctx->in_buf + gdbctx->in_len, gdbctx->in_buf_alloc - gdbctx->in_len);
len = read(gdbctx->sock, gdbctx->in_buf + gdbctx->in_len, gdbctx->in_buf_alloc - gdbctx->in_len - 1);
if (len <= 0) break;
gdbctx->in_len += len;
assert(gdbctx->in_len <= gdbctx->in_buf_alloc);
if (len < gdbctx->in_buf_alloc - gdbctx->in_len) break;
}
gdbctx->in_buf[gdbctx->in_len] = '\0';
return gdbctx->in_len - in_len;
}