From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlKD0-0004nv-7g for qemu-devel@nongnu.org; Tue, 26 Nov 2013 10:05:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlKCu-0002Dd-9K for qemu-devel@nongnu.org; Tue, 26 Nov 2013 10:05:50 -0500 Received: from cantor2.suse.de ([195.135.220.15]:54290 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlKCu-0002DM-2S for qemu-devel@nongnu.org; Tue, 26 Nov 2013 10:05:44 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A8148A7B44 for ; Tue, 26 Nov 2013 16:05:42 +0100 (CET) From: Hannes Reinecke Date: Tue, 26 Nov 2013 16:05:38 +0100 Message-Id: <1385478338-27433-1-git-send-email-hare@suse.de> Subject: [Qemu-devel] [PATCH] qdev: Validate hex properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas Faerber Cc: Hannes Reinecke , qemu-devel@nongnu.org, Alexander Graf strtoull() might return '-1' to signify an overflow. Signed-off-by: Hannes Reinecke --- hw/core/qdev-properties.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index dc8ae69..5761295 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -202,6 +202,9 @@ static int parse_hex8(DeviceState *dev, Property *prop, const char *str) if ((*end != '\0') || (end == str)) { return -EINVAL; } + if (*ptr == (uint8_t)-1) { + return -ERANGE; + } return 0; } @@ -333,6 +336,9 @@ static int parse_hex32(DeviceState *dev, Property *prop, const char *str) if ((*end != '\0') || (end == str)) { return -EINVAL; } + if (*ptr == (uint32_t)-1) { + return -ERANGE; + } return 0; } @@ -400,6 +406,9 @@ static int parse_hex64(DeviceState *dev, Property *prop, const char *str) if ((*end != '\0') || (end == str)) { return -EINVAL; } + if (*ptr == (uint64_t)-1) { + return -ERANGE; + } return 0; } -- 1.8.1.4