]> xenbits.xensource.com Git - xen.git/commit
tools: libxl: NULL terminate partially constructed hex string
authorIan Campbell <ian.campbell@citrix.com>
Tue, 16 Feb 2016 11:18:20 +0000 (11:18 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 16 Feb 2016 17:38:51 +0000 (17:38 +0000)
commitb021beb21a977a89b763db7b7df7c362cf8640a8
treef4e0f8c702c2307a877b8bdeebe5813ea83f18cc
parent382c72d83ad032e985bfcaa2dbb6bf78859b380e
tools: libxl: NULL terminate partially constructed hex string

Coverity (correctly) complains that the strncpy(p, "0x", 2) will not
null terminate p.

Although we can see that in the rest of the function p will
definitely be NULL terminated by the time it is complete there is no
harm in passing 3 to the strncpy and allowing it to NULL terminate to
placate Coverity. We know this is safe because the allocation to hold
the string includes a "+3" for the 0x and the terminating NULL.

Compile tested only.

CID: 1198708

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl_utils.c