arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone

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

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