mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
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>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user