Blame SOURCES/0005-PATH_UTILS-suppress-false-positive-warnings.patch

76347b
From 82ee1cff9d7401f4381cfa574f8b102625b06a31 Mon Sep 17 00:00:00 2001
76347b
From: Alexey Tikhonov <atikhono@redhat.com>
76347b
Date: Thu, 5 Aug 2021 18:02:57 +0200
76347b
Subject: [PATCH 5/6] PATH_UTILS: suppress false positive warnings
76347b
76347b
Warnings are false positives: every such `strncpy` is followed
76347b
by an explicit check that result is NULL-terminated.
76347b
76347b
Reviewed-by: Pawel Polawski <ppolawsk@redhat.com>
76347b
---
76347b
 path_utils/path_utils.c | 5 +++++
76347b
 1 file changed, 5 insertions(+)
76347b
76347b
diff --git a/path_utils/path_utils.c b/path_utils/path_utils.c
76347b
index 61605ab..5203cc9 100644
76347b
--- a/path_utils/path_utils.c
76347b
+++ b/path_utils/path_utils.c
76347b
@@ -116,6 +116,7 @@ int get_basename(char *base_name, size_t base_name_size, const char *path)
76347b
     if (!path) return EINVAL;
76347b
     if (!base_name || base_name_size < 1) return ENOBUFS;
76347b
 
76347b
+    /* coverity[buffer_size_warning : SUPPRESS] */ /* false positive warning */
76347b
     strncpy(tmp_path, path, sizeof(tmp_path));
76347b
     if (tmp_path[sizeof(tmp_path)-1] != '\0') return ENOBUFS;
76347b
     strncpy(base_name, basename(tmp_path), base_name_size);
76347b
@@ -137,6 +138,7 @@ int get_dirname(char *dir_path, size_t dir_path_size, const char *path)
76347b
     if (!path) return EINVAL;
76347b
     if (!dir_path || dir_path_size < 1) return ENOBUFS;
76347b
 
76347b
+    /* coverity[buffer_size_warning : SUPPRESS] */ /* false positive warning */
76347b
     strncpy(tmp_path, path, sizeof(tmp_path));
76347b
     if (tmp_path[sizeof(tmp_path)-1] != '\0') return ENOBUFS;
76347b
     strncpy(dir_path, dirname(tmp_path), dir_path_size);
76347b
@@ -161,11 +163,13 @@ int get_directory_and_base_name(char *dir_path, size_t dir_path_size,
76347b
     if (!dir_path || dir_path_size < 1) return ENOBUFS;
76347b
     if (!base_name || base_name_size < 1) return ENOBUFS;
76347b
 
76347b
+    /* coverity[buffer_size_warning : SUPPRESS] */ /* false positive warning */
76347b
     strncpy(tmp_path, path, sizeof(tmp_path));
76347b
     if (tmp_path[sizeof(tmp_path)-1] != '\0') return ENOBUFS;
76347b
     strncpy(base_name, basename(tmp_path), base_name_size);
76347b
     if (base_name[base_name_size-1] != '\0') return ENOBUFS;
76347b
 
76347b
+    /* coverity[buffer_size_warning : SUPPRESS] */ /* false positive warning */
76347b
     strncpy(tmp_path, path, sizeof(tmp_path));
76347b
     if (tmp_path[sizeof(tmp_path)-1] != '\0') return ENOBUFS;
76347b
     strncpy(dir_path, dirname(tmp_path), dir_path_size);
76347b
@@ -528,6 +532,7 @@ int find_existing_directory_ancestor(char *ancestor, size_t ancestor_size, const
76347b
 
76347b
     if (!ancestor || ancestor_size < 1) return ENOBUFS;
76347b
     *ancestor = 0;
76347b
+    /* coverity[buffer_size_warning : SUPPRESS] */ /* false positive warning */
76347b
     strncpy(dir_path, path, sizeof(dir_path));
76347b
     if (dir_path[sizeof(dir_path)-1] != '\0') return ENOBUFS;
76347b
 
76347b
-- 
76347b
2.26.3
76347b