:p
atchew
Login
virXPathString() can return NULL so we need to check it before calling strcmp() Found by Linux Verification Center (linuxtesting.org) with Svace. Reported-by: Dmitry Fedin <d.fedin@fobos-nt.ru> Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org> --- tools/virsh-completer-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index XXXXXXX..XXXXXXX 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -XXX,XX +XXX,XX @@ virshDomainConsoleCompleter(vshControl *ctl, ctxt->node = parallels[i - nserials]; type = virXPathString("string(./@type)", ctxt); - if (STRNEQ(type, "pty")) + if (!type || STRNEQ(type, "pty")) continue; tmp[offset++] = virXPathString("string(./alias/@name)", ctxt); -- 2.42.4
v2: - switch to use STRNEQ_NULLABLE instead of simple nullness check Alexander Kuznetsov (1): virsh: prevent potential NULL dereference tools/virsh-completer-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.42.4
virXPathString() can return NULL so we need to use STRNEQ_NULLABLE here Found by Linux Verification Center (linuxtesting.org) with Svace. Reported-by: Dmitry Fedin <d.fedin@fobos-nt.ru> Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org> --- tools/virsh-completer-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index XXXXXXX..XXXXXXX 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -XXX,XX +XXX,XX @@ virshDomainConsoleCompleter(vshControl *ctl, ctxt->node = parallels[i - nserials]; type = virXPathString("string(./@type)", ctxt); - if (STRNEQ(type, "pty")) + if (STRNEQ_NULLABLE(type, "pty")) continue; tmp[offset++] = virXPathString("string(./alias/@name)", ctxt); -- 2.42.4