Fixed defects

List of Defects

Error: CLANG_WARNING: [#def1]
dracut-059-build/dracut-059/src/install/dracut-install.c:638:25: warning[unix.Malloc]: Potential leak of memory pointed to by 'dstpath'
#  636|   
#  637|           if (!(srcpath && dstpath))
#  638|->                 return -ENOMEM;
#  639|   
#  640|           size_t dlen = dir_len(src);

Error: CLANG_WARNING: [#def2]
dracut-059-build/dracut-059/src/install/dracut-install.c:638:25: warning[unix.Malloc]: Potential leak of memory pointed to by 'srcpath'
#  636|   
#  637|           if (!(srcpath && dstpath))
#  638|->                 return -ENOMEM;
#  639|   
#  640|           size_t dlen = dir_len(src);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def3]
dracut-059-build/dracut-059/src/install/dracut-install.c: scope_hint: In function ‘parse_argv’
dracut-059-build/dracut-059/src/install/dracut-install.c:1089:41: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘sysrootdir’ where non-null expected
<built-in>: note: argument 1 of ‘__builtin_strlen’ must be non-null
# 1087|                   case 'r':
# 1088|                           sysrootdir = strdup(optarg);
# 1089|->                         sysrootdirlen = strlen(sysrootdir);
# 1090|                           break;
# 1091|                   case 'p':

Error: CLANG_WARNING: [#def4]
dracut-059-build/dracut-059/src/install/dracut-install.c:1340:37: warning[unix.Malloc]: Potential leak of memory pointed to by 'dest'
# 1338|                           if (strchr(argv[i], '*') == NULL) {
# 1339|                                   _cleanup_free_ char *dest = strdup(argv[i]);
# 1340|->                                 ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps, true);
# 1341|                           } else {
# 1342|                                   _cleanup_free_ char *realsrc = NULL;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def5]
dracut-059-build/dracut-059/src/install/dracut-install.c: scope_hint: In function ‘main’
dracut-059-build/dracut-059/src/install/dracut-install.c:2033:13: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘destrootdir’ where non-null expected
dracut-059-build/dracut-059/src/install/dracut-install.c:47: included_from: Included from here.
dracut-059-build/dracut-059/src/install/dracut-install.c:1996:9: note: in expansion of macro ‘log_debug’
dracut-059-build/dracut-059/src/install/dracut-install.c:36: included_from: Included from here.
/usr/include/string.h:156:12: note: argument 1 of ‘strcmp’ must be non-null
# 2031|           }
# 2032|   
# 2033|->         if (strcmp(destrootdir, "/") == 0) {
# 2034|                   log_error("Environment DESTROOTDIR or argument -D is set to '/'!");
# 2035|                   usage(EXIT_FAILURE);

Error: COMPILER_WARNING (CWE-457): [#def6]
dracut-059-build/dracut-059/src/install/util.h:535:9: warning[-Wmaybe-uninitialized]: ‘dst’ may be used uninitialized
#  535 |         free(*(void **)p);
#      |         ^~~~~~~~~~~~~~~~~
dracut-059-build/dracut-059/src/install/dracut-install.c: scope_hint: In function ‘dracut_install’
dracut-059-build/dracut-059/src/install/dracut-install.c:756:30: note: ‘dst’ was declared here
#  756 |         _cleanup_free_ char *dst;
#      |                              ^~~
#  533|   static inline void freep(void *p)
#  534|   {
#  535|->         free(*(void **)p);
#  536|   }
#  537|   

Error: CLANG_WARNING: [#def7]
dracut-059-build/dracut-059/src/util/util.c:276:37: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
#  274|                   if (strcmp(key, search_key) == 0) {
#  275|                           if (search_value) {
#  276|->                                 if (strcmp(value, search_value) == 0) {
#  277|                                           printf("%s\n", value);
#  278|                                           found_value = true;

Scan Properties

analyzer-version-clang18.1.7
analyzer-version-cppcheck2.14.2
analyzer-version-gcc14.1.1
analyzer-version-gcc-analyzer14.1.1
analyzer-version-shellcheck0.10.0
diffbase-analyzer-version-clang18.1.7
diffbase-analyzer-version-cppcheck2.14.2
diffbase-analyzer-version-gcc14.1.1
diffbase-analyzer-version-gcc-analyzer14.1.1
diffbase-analyzer-version-shellcheck0.10.0
diffbase-enabled-pluginsclang, cppcheck, gcc, shellcheck
diffbase-exit-code0
diffbase-hostip-172-16-1-6.us-west-2.compute.internal
diffbase-mock-configfedora-41-x86_64
diffbase-project-namedracut-102-1.fc41
diffbase-store-results-to/tmp/tmpubiola33/dracut-102-1.fc41.tar.xz
diffbase-time-created2024-07-03 12:29:00
diffbase-time-finished2024-07-03 12:30:25
diffbase-toolcsmock
diffbase-tool-args'/usr/bin/csmock' '-r' 'fedora-41-x86_64' '-t' 'cppcheck,gcc,clang,shellcheck' '-o' '/tmp/tmpubiola33/dracut-102-1.fc41.tar.xz' '--gcc-analyze' '/tmp/tmpubiola33/dracut-102-1.fc41.src.rpm'
diffbase-tool-versioncsmock-3.5.3-1.el9
enabled-pluginsclang, cppcheck, gcc, shellcheck
exit-code0
hostip-172-16-1-6.us-west-2.compute.internal
mock-configfedora-41-x86_64
project-namedracut-059-22.fc40
store-results-to/tmp/tmp923e0qga/dracut-059-22.fc40.tar.xz
time-created2024-07-03 12:26:58
time-finished2024-07-03 12:28:47
titleFixed defects
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-41-x86_64' '-t' 'cppcheck,gcc,clang,shellcheck' '-o' '/tmp/tmp923e0qga/dracut-059-22.fc40.tar.xz' '--gcc-analyze' '/tmp/tmp923e0qga/dracut-059-22.fc40.src.rpm'
tool-versioncsmock-3.5.3-1.el9