libxl: fix the bug which will cause heap to break down

If the JSON message contains more bytes than QMP_RECEIVE_BUFFER_SIZE,
this bug will break down the heap, that leads to core dump. One more
byte should be allocated to contain the appended null character.

Signed-off-by: Li Liang <liangx.z.li@intel.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
This commit is contained in:
Li Liang authored and Ian Campbell committed 2014-07-03 10:49:51 +01:00
1 parent cbe8115b6b
commit 35fa07df87
1 file changed
+1 -1
+1 -1
View File
@@ -456,7 +456,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp)
if (incomplete) {
size_t current_pos = s - incomplete;
incomplete = libxl__realloc(gc, incomplete,
incomplete_size + rd);
incomplete_size + rd + 1);
strncat(incomplete + incomplete_size, qmp->buffer, rd);
s = incomplete + current_pos;
incomplete_size += rd;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.