Skip to contentSkip to conversation

Bug in path.c

PATCH Applied Paul Brook 2 participants 2 messages Sep 11, 2004 – Sep 13, 2004

lore
Share & tools
lore

Paul Brook

author
#0 lore raw

PATCH 1/1 Bug in path.c

The path mangling code does the wrong thing when the prefix doesn't exist. For example path("/.") still returns "/usr/gnemul/qemu-arm", even if the latter doesn't exist (commonly the case when using a chroot).

Patch below fixes this by setting base to NULL if the prefix contains no files.

Paul

Index: path.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/path.c,v
retrieving revision 1.1

path.c 11 Sep 2004 17:12:14 -0000 renamed from path.c 11 Apr 2003 00:15:13 -0000 1.1 +5 -1
diff -u -p -r1.1 path.c
@@ -101,7 +101,11 @@ void init_paths(const char *prefix)
 
     base = new_entry("", NULL, prefix+1);
     base = add_dir_maybe(base);
-    set_parents(base, base);
+    if (base->num_entries == 0) {
+        free (base);
+        base = NULL;
+    } else
+        set_parents(base, base);
 }
 
 /* FIXME: Doesn't handle DIR/.. where DIR is not in emulated dir. */
#1 lore raw

applied.

Fabrice.

Quoted 35 lines · Paul Brook

The path mangling code does the wrong thing when the prefix doesn't exist.
For example path("/.") still returns "/usr/gnemul/qemu-arm", even if the latter doesn't exist (commonly the case when using a chroot).

Patch below fixes this by setting base to NULL if the prefix contains no files.

Paul

Index: path.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/path.c,v
retrieving revision 1.1
diff -u -p -r1.1 path.c

path.c 11 Sep 2004 17:12:14 -0000 renamed from path.c 11 Apr 2003 00:15:13 -0000 1.1 +5 -1
@@ -101,7 +101,11 @@ void init_paths(const char *prefix)
 
     base = new_entry("", NULL, prefix+1);
     base = add_dir_maybe(base);
-    set_parents(base, base);
+    if (base->num_entries == 0) {
+        free (base);
+        base = NULL;
+    } else
+        set_parents(base, base);
 }
 
 /* FIXME: Doesn't handle DIR/.. where DIR is not in emulated dir. */

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel