]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/9pfs: add NULL check in v9fs_path_is_ancestor()
authorChristian Schoenebeck <qemu_oss@crudebyte.com>
Mon, 18 May 2026 17:35:36 +0000 (19:35 +0200)
committerChristian Schoenebeck <qemu_oss@crudebyte.com>
Mon, 1 Jun 2026 09:11:39 +0000 (11:11 +0200)
Add NULL check for s1->data and s2->data before using them in
string operations. This prevents potential crashes when dealing
with uninitialized paths.

This is just a defensive measure. We are currently never passing
NULL to this function.

Link: https://lore.kernel.org/qemu-devel/3348c4d683f061c23083bd45994d527be4fb7cbc.1779126034.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
hw/9pfs/9p.c

index e2713b9eee29ab3c578e10e227f68512a686a0e8..e590c414ab6098c4713fbafa2ad82ed546b31e6e 100644 (file)
@@ -241,6 +241,9 @@ int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
  */
 static int v9fs_path_is_ancestor(V9fsPath *s1, V9fsPath *s2)
 {
+    if (!s1->data || !s2->data) {
+        return 0;
+    }
     if (!strncmp(s1->data, s2->data, s1->size - 1)) {
         if (s2->data[s1->size - 1] == '\0' || s2->data[s1->size - 1] == '/') {
             return 1;