[PATCH 0/1] qemu qapi: SIGSEGV small fix

Hello everyone! When implementing some custom qemu capability I cought this bug when some string with '*' pattern is not contained in schema, and virQEMUQAPISchemaTraverseObject passes NULL ptr to virJSONValueObjectHasKey. Nikolai Barybin (1): qemu: qapi: fix potential SIGSEGV in virQEMUQAPISchemaTraverseObject() src/qemu/qemu_qapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.43.5

We need to check obj ptr before passing it to virJSONValueObjectHasKey(). If it's NULL it will fail with SIGSEGV. Signed-off-by: Nikolai Barybin <nikolai.barybin@virtuozzo.com> --- src/qemu/qemu_qapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c index 184c0a965f..a2fef55019 100644 --- a/src/qemu/qemu_qapi.c +++ b/src/qemu/qemu_qapi.c @@ -180,7 +180,7 @@ virQEMUQAPISchemaTraverseObject(virJSONValue *cur, } else { obj = virQEMUQAPISchemaObjectGet("members", query, "name", cur); - if (modifier == '*' && + if (modifier == '*' && obj && !virJSONValueObjectHasKey(obj, "default")) return 0; } -- 2.43.5

On Thu, Jul 03, 2025 at 13:19:07 +0300, Nikolai Barybin via Devel wrote:
We need to check obj ptr before passing it to virJSONValueObjectHasKey(). If it's NULL it will fail with SIGSEGV.
Signed-off-by: Nikolai Barybin <nikolai.barybin@virtuozzo.com> --- src/qemu/qemu_qapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c index 184c0a965f..a2fef55019 100644 --- a/src/qemu/qemu_qapi.c +++ b/src/qemu/qemu_qapi.c @@ -180,7 +180,7 @@ virQEMUQAPISchemaTraverseObject(virJSONValue *cur, } else { obj = virQEMUQAPISchemaObjectGet("members", query, "name", cur);
- if (modifier == '*' && + if (modifier == '*' && obj && !virJSONValueObjectHasKey(obj, "default")) return 0; } -- 2.43.5
Reviewed-by: Peter Krempa <pkrempa@redhat.com> and I'll push it shortly.

On Thu, Jul 03, 2025 at 13:19:07 +0300, Nikolai Barybin via Devel wrote: Please also fix your git configuration: https://libvirt.org/submitting-patches.html#git-configuration Otherwise the author will be wrong (Nikolai Barybin via Devel) unless fixed manually due to the DMARC countermeasures the mailing list needs to take.
We need to check obj ptr before passing it to virJSONValueObjectHasKey(). If it's NULL it will fail with SIGSEGV.
Signed-off-by: Nikolai Barybin <nikolai.barybin@virtuozzo.com>
I've fixed it in this patch with this spelling.

On 7/3/25 12:19, Nikolai Barybin wrote:
Hello everyone!
When implementing some custom qemu capability I cought this bug when some string with '*' pattern is not contained in schema, and virQEMUQAPISchemaTraverseObject passes NULL ptr to virJSONValueObjectHasKey.
Nikolai Barybin (1): qemu: qapi: fix potential SIGSEGV in virQEMUQAPISchemaTraverseObject()
src/qemu/qemu_qapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Ping message.
participants (2)
-
Nikolai Barybin
-
Peter Krempa