xl: NULL terminate buf when reading dom0 /proc/uptime
authorIan Campbell <ian.campbell@citrix.com>
Wed, 17 Feb 2016 10:34:24 +0000 (10:34 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 1 Mar 2016 16:11:10 +0000 (16:11 +0000)
commit8891dccfed78c6ee03b8912ed5353b83595a9549
tree1aeb7de632312717972662cf05fe15d5f30ef0c9
parent9bc457987917ad66bd7fb43ac8bc31c314dce610
xl: NULL terminate buf when reading dom0 /proc/uptime

The contents of /proc/uptime is typically something like "80164.57
640617.58", so the existing 512 byte buffer is more than large enoguh,
so reduce its effective size to 511 bytes and ensure we include a
NULL.

Otherwise Coverity points out that we pass a potentially unterminated
string to strtok. In practice this likely doesn't actually cause
issues (at least on Linux) because the
string should always contain a space so we will stop parsing.

CID: 105590

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c