doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

Blame SOURCES/0087-abrt-auto-reporting-make-the-code-more-safer.patch

44797e
From b6d744ffd5e70b410c960ace62c68094bbbd045c Mon Sep 17 00:00:00 2001
44797e
From: Jakub Filak <jfilak@redhat.com>
44797e
Date: Fri, 9 Jan 2015 16:34:00 +0100
44797e
Subject: [ABRT PATCH 87/87] abrt-auto-reporting: make the code more safer
44797e
44797e
Uncovered by coverity.
44797e
44797e
Related: #1174833
44797e
44797e
Signed-off-by: Jakub Filak <jfilak@redhat.com>
44797e
---
44797e
 src/daemon/abrt-auto-reporting.c | 10 +++++++++-
44797e
 1 file changed, 9 insertions(+), 1 deletion(-)
44797e
44797e
diff --git a/src/daemon/abrt-auto-reporting.c b/src/daemon/abrt-auto-reporting.c
44797e
index f50c4c2..f3b4ed0 100644
44797e
--- a/src/daemon/abrt-auto-reporting.c
44797e
+++ b/src/daemon/abrt-auto-reporting.c
44797e
@@ -50,6 +50,8 @@ const char *const REPORTING_STATES[8][2] = {
44797e
 static int
44797e
 set_abrt_reporting(map_string_t *conf, const char *opt_value)
44797e
 {
44797e
+    assert(opt_value != NULL || !"BUG: invalid auto-reporting state");
44797e
+
44797e
     const char *const def_value = REPORTING_STATES[0][1];
44797e
     const char *const cur_value = get_map_string_item_or_NULL(conf, OPTION_NAME);
44797e
 
44797e
@@ -356,7 +358,13 @@ int main(int argc, char *argv[])
44797e
         goto finito;
44797e
     }
44797e
 
44797e
-    exit_code = set_abrt_reporting(conf, opt_value) ? EXIT_SUCCESS : EXIT_FAILURE;
44797e
+    if (opt_value == NULL)
44797e
+    {   /* calm coverity: see 'if (argc ...)' statements above. 0 exits, >1 fails, 1 sets opt_value */
44797e
+        error_msg("BUG: invalid command line arguments");
44797e
+        exit_code = EXIT_FAILURE;
44797e
+    }
44797e
+    else
44797e
+        exit_code = set_abrt_reporting(conf, opt_value) ? EXIT_SUCCESS : EXIT_FAILURE;
44797e
 
44797e
     if (exit_code == EXIT_FAILURE)
44797e
     {
44797e
-- 
44797e
1.8.3.1
44797e