From patchwork Tue Nov 26 15:05:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 294341 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EEE052C0092 for ; Wed, 27 Nov 2013 02:06:20 +1100 (EST) Received: from localhost ([::1]:59145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlKDS-00056j-Cg for incoming@patchwork.ozlabs.org; Tue, 26 Nov 2013 10:06:18 -0500 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 To: Andreas Faerber Date: Tue, 26 Nov 2013 16:05:38 +0100 Message-Id: <1385478338-27433-1-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.1.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Hannes Reinecke , qemu-devel@nongnu.org, Alexander Graf Subject: [Qemu-devel] [PATCH] qdev: Validate hex properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }