[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/3] check-qdict: Fix possible crash
From: |
Aurelien Jarno |
Subject: |
Re: [Qemu-devel] [PATCH 2/3] check-qdict: Fix possible crash |
Date: |
Sun, 20 Feb 2011 18:44:49 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
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 <address@hidden>
> ---
> 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
address@hidden http://www.aurel32.net
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [PATCH 2/3] check-qdict: Fix possible crash,
Aurelien Jarno <=