Received: from [140.186.70.92] (port=41655 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrDbQ-0006io-Fj for qemu-devel@nongnu.org; Sun, 20 Feb 2011 13:01:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrDL4-0001Wz-2t for qemu-devel@nongnu.org; Sun, 20 Feb 2011 12:44:55 -0500 Received: from hall.aurel32.net ([88.191.126.93]:49088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PrDL3-0001Wt-TD for qemu-devel@nongnu.org; Sun, 20 Feb 2011 12:44:54 -0500 Date: Sun, 20 Feb 2011 18:44:49 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH 2/3] check-qdict: Fix possible crash Message-ID: <20110220174449.GQ18619@volta.aurel32.net> References: <1295646630-31217-1-git-send-email-weil@mail.berlios.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1295646630-31217-1-git-send-email-weil@mail.berlios.de> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: QEMU Developers On Fri, Jan 21, 2011 at 10:50:30PM +0100, Stefan Weil wrote: > This warning is reported by cppcheck: > > check-qdict.c:270: warning: scanf without field width limits can crash with huge input data > > Fix it by limiting the field widths to 127 (both key and value take > 127 characters + a terminating '\0' byte). > > Signed-off-by: Stefan Weil > --- > check-qdict.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) Thanks, applied. > diff --git a/check-qdict.c b/check-qdict.c > index 6afce5a..ecc7fd7 100644 > --- a/check-qdict.c > +++ b/check-qdict.c > @@ -267,8 +267,9 @@ static QString *read_line(FILE *file, char *key) > { > char value[128]; > > - if (fscanf(file, "%s%s", key, value) == EOF) > + if (fscanf(file, "%127s%127s", key, value) == EOF) { > return NULL; > + } > remove_dots(key); > return qstring_from_str(value); > } > -- > 1.7.2.3 > > > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net