From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXTue-0000Cq-RE for qemu-devel@nongnu.org; Wed, 20 Jan 2010 01:19:32 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXTua-0000B8-Is for qemu-devel@nongnu.org; Wed, 20 Jan 2010 01:19:32 -0500 Received: from [199.232.76.173] (port=40820 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXTua-0000Aw-85 for qemu-devel@nongnu.org; Wed, 20 Jan 2010 01:19:28 -0500 Received: from mail-ew0-f228.google.com ([209.85.219.228]:60703) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NXTuZ-0004cu-PY for qemu-devel@nongnu.org; Wed, 20 Jan 2010 01:19:27 -0500 Received: by ewy28 with SMTP id 28so5617520ewy.17 for ; Tue, 19 Jan 2010 22:19:26 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <85e877202ec86dac15d392f5e88d5b5d76e3b02f.1263944807.git.quintela@redhat.com> References: <85e877202ec86dac15d392f5e88d5b5d76e3b02f.1263944807.git.quintela@redhat.com> Date: Wed, 20 Jan 2010 08:19:26 +0200 Message-ID: From: "Kirill A. Shutemov" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org On Wed, Jan 20, 2010 at 1:56 AM, Juan Quintela wrote: > From: Kirill A. Shutemov > > CC =C2=A0 =C2=A0block/vvfat.o > cc1: warnings being treated as errors > block/vvfat.c: In function 'commit_one_file': > block/vvfat.c:2259: error: ignoring return value of 'ftruncate', declared= with attribute warn_unused_result > make: *** [block/vvfat.o] Error 1 > =C2=A0CC =C2=A0 =C2=A0block/vvfat.o > In file included from /usr/include/stdio.h:912, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 from ./qemu-commo= n.h:19, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 from block/vvfat.= c:27: > In function 'snprintf', > =C2=A0 =C2=A0inlined from 'init_directories' at block/vvfat.c:871, > =C2=A0 =C2=A0inlined from 'vvfat_open' at block/vvfat.c:1068: > /usr/include/bits/stdio2.h:65: error: call to __builtin___snprintf_chk wi= ll always overflow destination buffer > make: *** [block/vvfat.o] Error 1 > > Signed-off-by: Kirill A. Shutemov > Signed-off-by: Juan Quintela > --- > =C2=A0block/vvfat.c | =C2=A0 =C2=A09 +++++++-- > =C2=A01 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/block/vvfat.c b/block/vvfat.c > index 063f731..df957e5 100644 > --- a/block/vvfat.c > +++ b/block/vvfat.c > @@ -868,7 +868,8 @@ static int init_directories(BDRVVVFATState* s, > =C2=A0 =C2=A0 { > =C2=A0 =C2=A0 =C2=A0 =C2=A0direntry_t* entry=3Darray_get_next(&(s->direct= ory)); > =C2=A0 =C2=A0 =C2=A0 =C2=A0entry->attributes=3D0x28; /* archive | volume = label */ > - =C2=A0 =C2=A0 =C2=A0 snprintf((char*)entry->name,11,"QEMU VVFAT"); > + =C2=A0 =C2=A0 =C2=A0 memcpy(entry->name,"QEMU VVF",8); > + =C2=A0 =C2=A0 =C2=A0 memcpy(entry->extension,"AT ",3); > =C2=A0 =C2=A0 } Better to use memcpy(entry->name, "QEMU VVFAT", 11); memcpy() doesn't check bounds. > =C2=A0 =C2=A0 /* Now build FAT, and write back information into directory= */ > @@ -2256,7 +2257,11 @@ static int commit_one_file(BDRVVVFATState* s, > =C2=A0 =C2=A0 =C2=A0 =C2=A0c =3D c1; > =C2=A0 =C2=A0 } > > - =C2=A0 =C2=A0ftruncate(fd, size); > + =C2=A0 =C2=A0if (ftruncate(fd, size)) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0perror("ftruncate()"); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0close(fd); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0return -4; > + =C2=A0 =C2=A0} > =C2=A0 =C2=A0 close(fd); > > =C2=A0 =C2=A0 return commit_mappings(s, first_cluster, dir_index); > -- > 1.6.5.2 > >