Coverity rightly points out that qmp->buffer may not be NULL
terminated when passed to strncat.
Make the actual buffer a byte bigger than QMP_RECEIVE_BUFFER_SIZE and
always append a NULL byte.
I suspect that in practice we have not yet seen QMP messages
approaching the buffer size (4K).
Compile tested only.
CID:
1055989
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
/* wait_for_id will be used by the synchronous send function */
int wait_for_id;
- char buffer[QMP_RECEIVE_BUFFER_SIZE];
+ char buffer[QMP_RECEIVE_BUFFER_SIZE + 1];
libxl__yajl_ctx *yajl_ctx;
libxl_ctx *ctx;
LOGE(ERROR, "Socket read error");
return rd;
}
+ qmp->buffer[rd] = '\0';
DEBUG_REPORT_RECEIVED(qmp->buffer, rd);