Blame block-vvfat.c-fix-warnings-with-_FORTIFY_SOURCE.patch

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