Skip to contentSkip to conversation

block: Fix regression for MinGW (assertion caused by short string)

PATCH Applied Stefan Weil 3 participants 3 messages Nov 22, 2012 – Nov 24, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 block: Fix regression for MinGW (assertion caused by short string)

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.

---

v2: Added TODO comment as suggested by Stefan Hajnoczi.

Hi Anthony, hi Blue,

this fix is needed for 1.3 to avoid a fatal assertion on Windows. As discussed on qemu-devel, it is a minimal solution and can be replaced by a better one after 1.3.

Please commit it to git master.

Regards
Stefan

 block.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block.c +2 -1
index 854ebd6..c05875f 100644
@@ -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;
Signature · 1 line
1.7.10.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 19 lines · Stefan Weil

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.

---

v2: Added TODO comment as suggested by Stefan Hajnoczi.

Hi Anthony, hi Blue,

this fix is needed for 1.3 to avoid a fatal assertion on Windows. As discussed on qemu-devel, it is a minimal solution and can be replaced by a better one after 1.3.

Quoted 8 lines

Please commit it to git master.

Regards
Stefan

 block.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Applied
#2 lore raw
In reply to Stefan Weil

Thanks, applied.

Quoted 45 lines · Stefan Weil

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.

---

v2: Added TODO comment as suggested by Stefan Hajnoczi.

Hi Anthony, hi Blue,

this fix is needed for 1.3 to avoid a fatal assertion on Windows. As discussed on qemu-devel, it is a minimal solution and can be replaced by a better one after 1.3.

Please commit it to git master.

Regards
Stefan

 block.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block.c +2 -2
index 854ebd6..c05875f 100644
@@ -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;
--

1.7.10.4