Resolve RHELPLAN-170235 Fix OpenScanHub report

- Fix deprecated g_spawn_check_exit_status with -Wdeprecated-declarations
- Fix uninitialized n_failed with -Wanalyzer-use-of-uninitialized-value
- Fix to check return value of g_setenv() with CWE-252
This commit is contained in:
Takao Fujiwara 2024-06-13 22:44:34 +09:00
parent f14e0b41e1
commit a2acfa45e1
2 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,67 @@
From 34d62ea8af9b2ec83acedfeac31c3d345e88d30b Mon Sep 17 00:00:00 2001
From: Takao Fujiwara <tfujiwar@redhat.com>
Date: Thu, 13 Jun 2024 22:30:51 +0900
Subject: [PATCH] Resolve RHELPLAN-170235 Fix OpenScanHub report
- Fix deprecated g_spawn_check_exit_status with -Wdeprecated-declarations
- Fix uninitialized n_failed with -Wanalyzer-use-of-uninitialized-value
- Fix to check return value of g_setenv() with CWE-252
---
src/gnome-desktop-testing-runner.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/gnome-desktop-testing-runner.c b/src/gnome-desktop-testing-runner.c
index 150489f..b17b843 100644
--- a/src/gnome-desktop-testing-runner.c
+++ b/src/gnome-desktop-testing-runner.c
@@ -46,7 +46,7 @@ rm_rf (GFile *path, GError **error)
if (!g_spawn_sync (NULL, (char**)child_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
NULL, NULL, &estatus, error))
return FALSE;
- if (!g_spawn_check_exit_status (estatus, error))
+ if (!g_spawn_check_wait_status (estatus, error))
return FALSE;
return TRUE;
}
@@ -348,7 +348,7 @@ on_test_exited (GObject *obj,
if (!g_subprocess_wait (proc, cancellable, error))
goto out;
estatus = g_subprocess_get_status (proc);
- if (!g_spawn_check_exit_status (estatus, &tmp_error))
+ if (!g_spawn_check_wait_status (estatus, &tmp_error))
{
if (g_error_matches (tmp_error, G_SPAWN_EXIT_ERROR, 77))
{
@@ -671,7 +671,9 @@ main (int argc, char **argv)
GOptionContext *context;
TestRunnerApp appstruct;
const char *const *datadirs_iter;
- int n_passed, n_skipped, n_failed;
+ int n_passed = 0;
+ int n_skipped = 0;
+ int n_failed = 0;
memset (&appstruct, 0, sizeof (appstruct));
app = &appstruct;
@@ -680,7 +682,9 @@ main (int argc, char **argv)
app->failed_test_msgs = g_ptr_array_new_with_free_func ((GDestroyNotify)g_free);
/* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
- g_setenv ("GIO_USE_VFS", "local", TRUE);
+ errno = 0;
+ if (!!g_setenv ("GIO_USE_VFS", "local", TRUE))
+ g_warning ("Failed to set GIO_USE_VFS=local: %s", g_strerror (errno));
context = g_option_context_new ("[PREFIX...] - Run installed tests");
g_option_context_add_main_entries (context, options, NULL);
@@ -815,7 +819,6 @@ main (int argc, char **argv)
struct rusage child_rusage;
g_autofree char *rusage_str = NULL;
- n_passed = n_skipped = n_failed = 0;
for (i = 0; i < app->tests->len; i++)
{
GdtrTest *test = app->tests->pdata[i];
--
2.45.1

View File

@ -16,6 +16,7 @@ BuildRequires: make
# https://gitlab.gnome.org/GNOME/gnome-desktop-testing/merge_requests/1
Patch0: 0001-Don-t-crash-on-unknown-command-line-options.patch
Patch1: 0001-Resolve-RHELPLAN-170235-Fix-OpenScanHub-report.patch
%description
gnome-desktop-testing-runner is a basic runner for tests that are
@ -27,7 +28,7 @@ installed in /usr/share/installed-tests. For more information, see
NOCONFIGURE=1 ./autogen.sh
%build
%configure --with-systemd-journal
%configure
make %{?_smp_mflags}
%install