All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libqtest: check for g_setenv() failure
@ 2021-08-20 16:37 Peter Maydell
  2021-08-20 16:53 ` Philippe Mathieu-Daudé
  2021-09-01 13:55 ` Thomas Huth
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Maydell @ 2021-08-20 16:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth

g_setenv() can fail; check for it when starting a QEMU process
when we set the QEMU_AUDIO_DRV environment variable.

Because this happens after fork() reporting an exact message
via printf() is a bad idea; just exit(1), as we already do
for the case of execlp() failure.

Fixes: Coverity CID 1460117
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 tests/qtest/libqtest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 825b13a44c7..73f6b977a66 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -301,7 +301,9 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
     s->expected_status = 0;
     s->qemu_pid = fork();
     if (s->qemu_pid == 0) {
-        g_setenv("QEMU_AUDIO_DRV", "none", true);
+        if (!g_setenv("QEMU_AUDIO_DRV", "none", true)) {
+            exit(1);
+        }
         execlp("/bin/sh", "sh", "-c", command, NULL);
         exit(1);
     }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libqtest: check for g_setenv() failure
  2021-08-20 16:37 [PATCH] libqtest: check for g_setenv() failure Peter Maydell
@ 2021-08-20 16:53 ` Philippe Mathieu-Daudé
  2021-09-01 13:55 ` Thomas Huth
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-20 16:53 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth

On 8/20/21 6:37 PM, Peter Maydell wrote:
> g_setenv() can fail; check for it when starting a QEMU process
> when we set the QEMU_AUDIO_DRV environment variable.
> 
> Because this happens after fork() reporting an exact message
> via printf() is a bad idea; just exit(1), as we already do
> for the case of execlp() failure.
> 
> Fixes: Coverity CID 1460117
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  tests/qtest/libqtest.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libqtest: check for g_setenv() failure
  2021-08-20 16:37 [PATCH] libqtest: check for g_setenv() failure Peter Maydell
  2021-08-20 16:53 ` Philippe Mathieu-Daudé
@ 2021-09-01 13:55 ` Thomas Huth
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2021-09-01 13:55 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini

On 20/08/2021 18.37, Peter Maydell wrote:
> g_setenv() can fail; check for it when starting a QEMU process
> when we set the QEMU_AUDIO_DRV environment variable.
> 
> Because this happens after fork() reporting an exact message
> via printf() is a bad idea; just exit(1), as we already do
> for the case of execlp() failure.
> 
> Fixes: Coverity CID 1460117
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   tests/qtest/libqtest.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index 825b13a44c7..73f6b977a66 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -301,7 +301,9 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
>       s->expected_status = 0;
>       s->qemu_pid = fork();
>       if (s->qemu_pid == 0) {
> -        g_setenv("QEMU_AUDIO_DRV", "none", true);
> +        if (!g_setenv("QEMU_AUDIO_DRV", "none", true)) {
> +            exit(1);
> +        }
>           execlp("/bin/sh", "sh", "-c", command, NULL);
>           exit(1);
>       }

Thanks, queued to my testing-next branch:

  https://gitlab.com/thuth/qemu/-/commits/testing-next

  Thomas




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-01 13:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 16:37 [PATCH] libqtest: check for g_setenv() failure Peter Maydell
2021-08-20 16:53 ` Philippe Mathieu-Daudé
2021-09-01 13:55 ` Thomas Huth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.