block: Fix regression for MinGW (assertion caused by short string)
authorStefan Weil <sw@weilnetz.de>
Thu, 22 Nov 2012 06:25:48 +0000 (07:25 +0100)
committerBlue Swirl <blauwirbel@gmail.com>
Sat, 24 Nov 2012 19:54:43 +0000 (19:54 +0000)
The local string tmp_filename is passed to function get_tmp_filename
which expects a string with minimum size MAX_PATH for w32 hosts.

MAX_PATH is 260 and PATH_MAX is 259, so tmp_filename was too short.

Commit eba25057b9a5e19d10ace2bc7716667a31297169 introduced this
regression.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
block.c

diff --git a/block.c b/block.c
index 854ebd60d448a2a2b18ca21045a772b160512007..c05875fe393a1a64db599846db4be00cd03032bc 100644 (file)
--- a/block.c
+++ b/block.c
@@ -787,7 +787,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
               BlockDriver *drv)
 {
     int ret;
-    char tmp_filename[PATH_MAX];
+    /* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
+    char tmp_filename[PATH_MAX + 1];
 
     if (flags & BDRV_O_SNAPSHOT) {
         BlockDriverState *bs1;