Blame SOURCES/0268-Shut-Coverity-up.patch

b12e4c
From 88c967f40857a0ebac6b2bde0209fbfbcf914d24 Mon Sep 17 00:00:00 2001
b12e4c
From: Ernestas Kulik <ekulik@redhat.com>
b12e4c
Date: Mon, 10 Jun 2019 14:09:44 +0200
b12e4c
Subject: [PATCH] Shut Coverity up
b12e4c
MIME-Version: 1.0
b12e4c
Content-Type: text/plain; charset=UTF-8
b12e4c
Content-Transfer-Encoding: 8bit
b12e4c
b12e4c
In problem_report.c:
b12e4c
    alloc_strlen: Allocating insufficient memory for the terminating
b12e4c
null of the string.
b12e4c
b12e4c
    That makes absolutely *no* sense in the context of fmemopen().
b12e4c
b12e4c
In get_cmdline.c and problem_data.c:
b12e4c
    The functions called sanitize the input, so I think we’re in the
b12e4c
clear.
b12e4c
b12e4c
In logging.c:
b12e4c
    The buffer is dynamically reallocated if the error string length
b12e4c
exceeds the initial size.
b12e4c
b12e4c
Signed-off-by: Ernestas Kulik <ekulik@redhat.com>
b12e4c
b12e4c
cov
b12e4c
---
b12e4c
 src/lib/get_cmdline.c    | 1 +
b12e4c
 src/lib/logging.c        | 1 +
b12e4c
 src/lib/problem_data.c   | 1 +
b12e4c
 src/lib/problem_report.c | 1 +
b12e4c
 4 files changed, 4 insertions(+)
b12e4c
b12e4c
diff --git a/src/lib/get_cmdline.c b/src/lib/get_cmdline.c
b12e4c
index 9e83994..3ba6e32 100644
b12e4c
--- a/src/lib/get_cmdline.c
b12e4c
+++ b/src/lib/get_cmdline.c
b12e4c
@@ -111,6 +111,7 @@ static char* get_escaped(const char *path, char separator)
b12e4c
             while (1)
b12e4c
             {
b12e4c
                 /* escape till next NUL char */
b12e4c
+                /* coverity[tainted_data] */
b12e4c
                 char *d = append_escaped(dst, src);
b12e4c
                 total_esc_len += (d - dst);
b12e4c
                 dst = d;
b12e4c
diff --git a/src/lib/logging.c b/src/lib/logging.c
b12e4c
index 4b9dd87..be1a2e1 100644
b12e4c
--- a/src/lib/logging.c
b12e4c
+++ b/src/lib/logging.c
b12e4c
@@ -116,6 +116,7 @@ static void log_handler(int level,
b12e4c
             msg[used++] = ':';
b12e4c
             msg[used++] = ' ';
b12e4c
         }
b12e4c
+        /* coverity[fixed_size_dest] */
b12e4c
         strcpy(&msg[used], strerr);
b12e4c
         used += strerr_len;
b12e4c
     }
b12e4c
diff --git a/src/lib/problem_data.c b/src/lib/problem_data.c
b12e4c
index fdecc83..c2bbd65 100644
b12e4c
--- a/src/lib/problem_data.c
b12e4c
+++ b/src/lib/problem_data.c
b12e4c
@@ -469,6 +469,7 @@ void problem_data_load_from_dump_dir(problem_data_t *problem_data, struct dump_d
b12e4c
         /* Sanitize possibly corrupted utf8.
b12e4c
          * Of control chars, allow only tab and newline.
b12e4c
          */
b12e4c
+        /* coverity[tainted_data] */
b12e4c
         char *sanitized = sanitize_utf8(content,
b12e4c
                 (SANITIZE_ALL & ~SANITIZE_LF & ~SANITIZE_TAB)
b12e4c
         );
b12e4c
diff --git a/src/lib/problem_report.c b/src/lib/problem_report.c
b12e4c
index 2bf5530..dff4945 100644
b12e4c
--- a/src/lib/problem_report.c
b12e4c
+++ b/src/lib/problem_report.c
b12e4c
@@ -1124,6 +1124,7 @@ problem_formatter_load_string(problem_formatter_t *self, const char *fmt)
b12e4c
     const size_t len = strlen(fmt);
b12e4c
     if (len != 0)
b12e4c
     {
b12e4c
+        /* coverity[alloc_strlen] */
b12e4c
         FILE *fp = fmemopen((void *)fmt, len, "r");
b12e4c
         if (fp == NULL)
b12e4c
         {
b12e4c
-- 
b12e4c
2.21.0
b12e4c