qemu-img: Use qemu_strtoul() rather than raw strtoul()
commit8b3c67922851bee9d5420373bfea010d3648bbc4
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 10 Feb 2017 16:28:23 +0000 (10 16:28 +0000)
committerMax Reitz <mreitz@redhat.com>
Sat, 11 Feb 2017 23:53:31 +0000 (12 00:53 +0100)
tree594a28cda91b7f2f176ab48264bc7a3a2293a995
parent3026c4688ca80d9c5cc1606368c4a1009a6f507d
qemu-img: Use qemu_strtoul() rather than raw strtoul()

Some of the argument parsing in qemu-img uses strtoul() to parse
integer arguments.  This is tricky to get correct and in fact the
code does not get it right, because it assigns the result of
strtoul() to an 'int' variable and then tries to check for > INT_MAX.
Coverity correctly complains that the comparison is always false.

Rewrite to use qemu_strtoul(), which has a saner convention for
reporting conversion failures.

(Fixes CID 1356421, CID 1356422, CID 1356423.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1486744104-15590-2-git-send-email-peter.maydell@linaro.org
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Max Reitz <mreitz@redhat.com>
qemu-img.c