[libvirt PATCH 1/6] virt-login-shell: correctly calculate string length

Martin Kletzander mkletzan at redhat.com
Mon Aug 3 08:33:57 UTC 2020


On Mon, Aug 03, 2020 at 12:25:29AM +0200, Ján Tomko wrote:
>virLoginShellGetShellArgv was not dereferencing the pointer
>to the string list containing the shell parameters from the
>config file, thus setting some random number as shargvlen.
>
>Signed-off-by: Ján Tomko <jtomko at redhat.com>
>Fixes: 740e4d705284ba0598258291c2656f50075486f0
>---
> tools/virt-login-shell-helper.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helper.c
>index d9db883ee6..2db349754e 100644
>--- a/tools/virt-login-shell-helper.c
>+++ b/tools/virt-login-shell-helper.c
>@@ -104,7 +104,7 @@ static int virLoginShellGetShellArgv(virConfPtr conf,
>         (*shargv)[0] = g_strdup("/bin/sh");
>         *shargvlen = 1;
>     } else {
>-        *shargvlen = virStringListLength((const char *const *)shargv);
>+        *shargvlen = virStringListLength((const char *const *)*shargv);

Yay for:

  - casting,
  - functions that need casting, and
  - C rules that force such functions

Reviewed-by: Martin Kletzander <mkletzan at redhat.com>

>     }
>     return 0;
> }
>-- 
>2.26.2
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200803/343eebd6/attachment-0001.sig>


More information about the libvir-list mailing list