From: Erik Skultety Date: Thu, 19 Feb 2015 15:53:13 +0000 (+0100) Subject: qemu: Check for negative port values in network drive configuration X-Git-Tag: v1.2.14-rc1~154 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84646165262de4fcdfca49e9e9198fa7b26edea6;p=thirdparty%2Flibvirt.git qemu: Check for negative port values in network drive configuration We interpret port values as signed int (convert them from char *), so if a negative value is provided in network disk's configuration, we accept it as valid, however there's an 'unknown cause' error raised later. This error is only accidental because we return the port value in the return code. This patch adds just a minor tweak to the already existing check so we reject negative values the same way as we reject non-numerical strings. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1163553 --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5303de5eb8..3f0a3065bb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3003,7 +3003,7 @@ qemuNetworkDriveGetPort(int protocol, int ret = 0; if (port) { - if (virStrToLong_i(port, NULL, 10, &ret) < 0) { + if (virStrToLong_i(port, NULL, 10, &ret) < 0 || ret < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse port number '%s'"), port);