afaefd0
From e69a45b96be09d25429175fa8f0f85e3d7fab5a8 Mon Sep 17 00:00:00 2001
afaefd0
Message-Id: <e69a45b96be09d25429175fa8f0f85e3d7fab5a8.1277191832.git.amit.shah@redhat.com>
afaefd0
From: Kirill A. Shutemov <kirill@shutemov.name>
afaefd0
Date: Wed, 20 Jan 2010 00:56:14 +0100
afaefd0
Subject: [PATCH] block/vvfat.c: fix warnings with _FORTIFY_SOURCE
afaefd0
afaefd0
CC    block/vvfat.o
afaefd0
cc1: warnings being treated as errors
afaefd0
block/vvfat.c: In function 'commit_one_file':
afaefd0
block/vvfat.c:2259: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result
afaefd0
make: *** [block/vvfat.o] Error 1
afaefd0
  CC    block/vvfat.o
afaefd0
In file included from /usr/include/stdio.h:912,
afaefd0
                 from ./qemu-common.h:19,
afaefd0
                 from block/vvfat.c:27:
afaefd0
In function 'snprintf',
afaefd0
    inlined from 'init_directories' at block/vvfat.c:871,
afaefd0
    inlined from 'vvfat_open' at block/vvfat.c:1068:
afaefd0
/usr/include/bits/stdio2.h:65: error: call to __builtin___snprintf_chk will always overflow destination buffer
afaefd0
make: *** [block/vvfat.o] Error 1
afaefd0
afaefd0
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
afaefd0
Signed-off-by: Juan Quintela <quintela@redhat.com>
afaefd0
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
afaefd0
(cherry picked from commit 2dedf83ef0cc3463783d6b71bf1b25476f691f3a)
afaefd0
afaefd0
This fixes Fedora bug 605202.
afaefd0
afaefd0
Signed-off-by: Amit Shah <amit.shah@redhat.com>
afaefd0
---
afaefd0
 block/vvfat.c |    9 +++++++--
afaefd0
 1 files changed, 7 insertions(+), 2 deletions(-)
afaefd0
afaefd0
diff --git a/block/vvfat.c b/block/vvfat.c
afaefd0
index c1acb35..592d6e6 100644
afaefd0
--- a/block/vvfat.c
afaefd0
+++ b/block/vvfat.c
afaefd0
@@ -868,7 +868,8 @@ static int init_directories(BDRVVVFATState* s,
afaefd0
     {
afaefd0
 	direntry_t* entry=array_get_next(&(s->directory));
afaefd0
 	entry->attributes=0x28; /* archive | volume label */
afaefd0
-	snprintf((char*)entry->name,11,"QEMU VVFAT");
afaefd0
+	memcpy(entry->name,"QEMU VVF",8);
afaefd0
+	memcpy(entry->extension,"AT ",3);
afaefd0
     }
afaefd0
 
afaefd0
     /* Now build FAT, and write back information into directory */
afaefd0
@@ -2256,7 +2257,11 @@ static int commit_one_file(BDRVVVFATState* s,
afaefd0
 	c = c1;
afaefd0
     }
afaefd0
 
afaefd0
-    ftruncate(fd, size);
afaefd0
+    if (ftruncate(fd, size)) {
afaefd0
+        perror("ftruncate()");
afaefd0
+        close(fd);
afaefd0
+        return -4;
afaefd0
+    }
afaefd0
     close(fd);
afaefd0
 
afaefd0
     return commit_mappings(s, first_cluster, dir_index);
afaefd0
-- 
afaefd0
1.7.0.1
afaefd0