[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] libxl: qmp: ensure qmp read buffer is NULL terminated



On Wed, 2016-02-17 at 11:02 +0000, Ian Campbell wrote:
> 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@xxxxxxxxxx>

ping.

> ---
> Âtools/libxl/libxl_qmp.c | 3 ++-
> Â1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
> index 714038b..c45702e 100644
> --- a/tools/libxl/libxl_qmp.c
> +++ b/tools/libxl/libxl_qmp.c
> @@ -67,7 +67,7 @@ struct libxl__qmp_handler {
> ÂÂÂÂÂ/* 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;
> @@ -457,6 +457,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler
> *qmp)
> ÂÂÂÂÂÂÂÂÂÂÂÂÂLOGE(ERROR, "Socket read error");
> ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn rd;
> ÂÂÂÂÂÂÂÂÂ}
> +ÂÂÂÂÂÂÂÂqmp->buffer[rd] = '\0';
> Â
> ÂÂÂÂÂÂÂÂÂDEBUG_REPORT_RECEIVED(qmp->buffer, rd);
> Â

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.