hw/9pfs: add NULL check in v9fs_path_is_ancestor()
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>
Christian Schoenebeck committed
May 18, 2026 at 19:35 UTC
abb0cc02fb56e2432837e34b80fe68768f95e774
1 file changed
+3
hw/9pfs/9p.c
+3
@@ -241,6 +241,9 @@ int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
241
*/
242
static int v9fs_path_is_ancestor(V9fsPath *s1, V9fsPath *s2)
243
{
244
+ if (!s1->data || !s2->data) {
245
+ return 0;
246
+ }
247
if (!strncmp(s1->data, s2->data, s1->size - 1)) {
248
if (s2->data[s1->size - 1] == '\0' || s2->data[s1->size - 1] == '/') {
249
return 1;