dracut-059-22.fc40

List of Defects

Error: CLANG_WARNING: [#def1]
dracut-059-build/dracut-059/src/install/dracut-install.c:182:18: warning[unix.Malloc]: Potential leak of memory pointed to by 'from_dir_p'
#  180|           /* dir_len() skips double /'s e.g. //lib64, so we can't skip just one
#  181|            * character - need to skip all leading /'s */
#  182|->         for (i = dirlen + 1; from[i] == '/'; ++i)
#  183|                   ;
#  184|           _asprintf(&realfrom, "%s/%s", buf, from + i);

Error: CLANG_WARNING: [#def2]
dracut-059-build/dracut-059/src/install/dracut-install.c:195:18: warning[unix.Malloc]: Potential leak of memory pointed to by 'target_dir_p'
#  193|           }
#  194|   
#  195|->         for (i = dirlen + 1; target[i] == '/'; ++i)
#  196|                   ;
#  197|           _asprintf(&realtarget, "%s/%s", buf, target + i);

Error: CLANG_WARNING: [#def3]
dracut-059-build/dracut-059/src/install/dracut-install.c:323:17: warning[deadcode.DeadStores]: Value stored to 'dest_desc' is never read
#  321|                   }
#  322|                   close(dest_desc);
#  323|->                 dest_desc = -1;
#  324|                   /* clone did not work, remove the file */
#  325|                   unlink(dst);

Error: CLANG_WARNING: [#def4]
dracut-059-build/dracut-059/src/install/dracut-install.c:392:24: warning[unix.Malloc]: Potential leak of memory pointed to by 'p'
#  390|           pdir = dirname_malloc(p);
#  391|           if (!pdir)
#  392|->                 return ret;
#  393|   
#  394|           ppdir = dirname_malloc(pdir);

Error: CLANG_WARNING: [#def5]
dracut-059-build/dracut-059/src/install/dracut-install.c:507:33: warning[unix.Malloc]: Potential leak of memory pointed to by 'buf'
#  505|                   fd = open(fullsrcpath, O_RDONLY | O_CLOEXEC);
#  506|                   if (fd < 0)
#  507|->                         return -errno;
#  508|   
#  509|                   ret = read(fd, buf, linesize - 1);

Error: CLANG_WARNING: [#def6]
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: [#def7]
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: CLANG_WARNING: [#def8]
dracut-059-build/dracut-059/src/install/dracut-install.c:740:16: warning[unix.Malloc]: Potential leak of memory pointed to by 'parent'
#  738|           }
#  739|   
#  740|->         return 0;
#  741|   }
#  742|   

Error: CLANG_WARNING: [#def9]
dracut-059-build/dracut-059/src/install/dracut-install.c:740:16: warning[unix.Malloc]: Potential leak of memory pointed to by 'path'
#  738|           }
#  739|   
#  740|->         return 0;
#  741|   }
#  742|   

Error: CLANG_WARNING: [#def10]
dracut-059-build/dracut-059/src/install/dracut-install.c:779:17: warning[unix.Malloc]: Potential leak of memory pointed to by 'fullsrcpath'
#  777|   
#  778|           if (check_hashmap(items_failed, src)) {
#  779|->                 log_debug("hash hit items_failed for '%s'", src);
#  780|                   return 1;
#  781|           }

Error: CLANG_WARNING: [#def11]
dracut-059-build/dracut-059/src/install/dracut-install.c:844:29: warning[unix.Malloc]: Potential leak of memory pointed to by 'dname'
#  842|                           if (!dname)
#  843|                                   return 1;
#  844|->                         ret = dracut_install(dname, dname, true, false, true);
#  845|   
#  846|                           if (ret != 0) {

Error: CLANG_WARNING: [#def12]
dracut-059-build/dracut-059/src/install/dracut-install.c:852:21: warning[unix.Malloc]: Potential leak of memory pointed to by 'fulldstdir'
#  850|                   }
#  851|   
#  852|->                 if (src_isdir) {
#  853|                           if (dst_exists) {
#  854|                                   if (S_ISDIR(sb.st_mode)) {

Error: GCC_ANALYZER_WARNING (CWE-688): [#def13]
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: [#def14]
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: CLANG_WARNING: [#def15]
dracut-059-build/dracut-059/src/install/dracut-install.c:1416:17: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1414|                   value = kmod_module_info_get_value(l);
# 1415|                   log_debug("Firmware %s", value);
# 1416|->                 ret = -1;
# 1417|                   STRV_FOREACH(q, firmwaredirs) {
# 1418|                           _cleanup_free_ char *fwpath = NULL;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def16]
dracut-059-build/dracut-059/src/install/dracut-install.c: scope_hint: In function ‘modalias_list’
dracut-059-build/dracut-059/src/install/dracut-install.c:1648:27: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(*ftsent.fts_accpath, "r")’
# 1646|                   if (strncmp("modalias", ftsent->fts_name, 8) != 0)
# 1647|                           continue;
# 1648|->                 if (!(f = fopen(ftsent->fts_accpath, "r")))
# 1649|                           continue;
# 1650|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def17]
dracut-059-build/dracut-059/src/install/dracut-install.c:1648:27: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(*ftsent.fts_accpath, "r")’
# 1646|                   if (strncmp("modalias", ftsent->fts_name, 8) != 0)
# 1647|                           continue;
# 1648|->                 if (!(f = fopen(ftsent->fts_accpath, "r")))
# 1649|                           continue;
# 1650|   

Error: CLANG_WARNING: [#def18]
dracut-059-build/dracut-059/src/install/dracut-install.c:1799:49: warning[unix.Malloc]: Potential leak of memory pointed to by 'modname'
# 1797|                                           if (!arg_silent)
# 1798|                                                   log_error("3 Failed to lookup alias '%s': %d", modname, r);
# 1799|->                                         return -ENOENT;
# 1800|                                   }
# 1801|                                   log_info("3 Failed to lookup alias '%s': %d", modname, r);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def19]
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: CLANG_WARNING: [#def20]
dracut-059-build/dracut-059/src/install/dracut-install.c:2067:9: warning[deadcode.DeadStores]: Value stored to 'r' is never read
# 2065|           }
# 2066|   
# 2067|->         r = EXIT_SUCCESS;
# 2068|   
# 2069|           if (((optind + 1) < argc) && (strcmp(argv[optind + 1], destrootdir) == 0)) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def21]
dracut-059-build/dracut-059/src/install/strv.c: scope_hint: In function ‘strv_push’
dracut-059-build/dracut-059/src/install/strv.c:416:12: warning[-Wanalyzer-malloc-leak]: leak of ‘<unknown>’
dracut-059-build/dracut-059/src/install/strv.c:26: included_from: Included from here.
dracut-059-build/dracut-059/src/install/strv.c:562:9: note: in expansion of macro ‘NULSTR_FOREACH’
dracut-059-build/dracut-059/src/install/strv.c: scope_hint: In function ‘strv_push’
dracut-059-build/dracut-059/src/install/strv.c: scope_hint: In function ‘strv_push’
dracut-059-build/dracut-059/src/install/strv.c: scope_hint: In function ‘strv_push’
dracut-059-build/dracut-059/src/install/strv.c:562:9: note: in expansion of macro ‘NULSTR_FOREACH’
dracut-059-build/dracut-059/src/install/strv.c:562:9: note: in expansion of macro ‘NULSTR_FOREACH’
dracut-059-build/dracut-059/src/install/strv.c: scope_hint: In function ‘strv_push’
dracut-059-build/dracut-059/src/install/strv.c: scope_hint: In function ‘strv_push’
dracut-059-build/dracut-059/src/install/strv.c: scope_hint: In function ‘strv_push’
#  414|           n = strv_length(*l);
#  415|           c = realloc(*l, sizeof(char *) * (n + 2));
#  416|->         if (!c)
#  417|                   return -ENOMEM;
#  418|   

Error: GCC_ANALYZER_WARNING (CWE-1341): [#def22]
dracut-059-build/dracut-059/src/install/util.c: scope_hint: In function ‘close_nointr’
dracut-059-build/dracut-059/src/install/util.c:75:21: warning[-Wanalyzer-fd-double-close]: double ‘close’ of file descriptor ‘fd’
dracut-059-build/dracut-059/src/install/util.h:40: included_from: Included from here.
dracut-059-build/dracut-059/src/install/util.c:30: included_from: Included from here.
dracut-059-build/dracut-059/src/install/macro.h:136:22: note: in expansion of macro ‘assert_se’
dracut-059-build/dracut-059/src/install/util.c:70:9: note: in expansion of macro ‘assert’
dracut-059-build/dracut-059/src/install/util.c:24: included_from: Included from here.
#   73|                   int r;
#   74|   
#   75|->                 r = close(fd);
#   76|                   if (r >= 0)
#   77|                           return r;

Error: COMPILER_WARNING (CWE-457): [#def23]
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: CPPCHECK_WARNING: [#def24]
dracut-059-build/dracut-059/src/util/util.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

Error: GCC_ANALYZER_WARNING (CWE-476): [#def25]
dracut-059-build/dracut-059/src/util/util.c: scope_hint: In function ‘next_arg’
dracut-059-build/dracut-059/src/util/util.c:70:13: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘args’
#   68|           char *next;
#   69|   
#   70|->         if (*args == '"') {
#   71|                   args++;
#   72|                   in_quote = 1;

Error: CLANG_WARNING: [#def26]
dracut-059-build/dracut-059/src/util/util.c:211:29: warning[unix.Malloc]: Potential leak of memory pointed to by 'cmdline'
#  209|                   cmdline = next_arg(cmdline, &key, &value);
#  210|                   if (strcmp(key, search_key) == 0) {
#  211|->                         if (value) {
#  212|                                   end_value = value;
#  213|                                   bool_value = -1;

Error: CLANG_WARNING: [#def27]
dracut-059-build/dracut-059/src/util/util.c:211:29: warning[unix.Malloc]: Potential leak of memory pointed to by 'key'
#  209|                   cmdline = next_arg(cmdline, &key, &value);
#  210|                   if (strcmp(key, search_key) == 0) {
#  211|->                         if (value) {
#  212|                                   end_value = value;
#  213|                                   bool_value = -1;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def28]
dracut-059-build/dracut-059/src/util/util.c: scope_hint: In function ‘getarg’
dracut-059-build/dracut-059/src/util/util.c:234:12: warning[-Wanalyzer-malloc-leak]: leak of ‘cmdline’
dracut-059-build/dracut-059/src/util/util.c:54:16: note: in expansion of macro ‘kernel_isspace’
dracut-059-build/dracut-059/src/util/util.c: scope_hint: In function ‘getarg’
#  232|           }
#  233|   
#  234|->         if (bool_value) {
#  235|                   return EXIT_SUCCESS;
#  236|           }

Error: CLANG_WARNING: [#def29]
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;

Error: CLANG_WARNING: [#def30]
dracut-059-build/dracut-059/src/util/util.c:289:18: warning[unix.Malloc]: Potential leak of memory pointed to by 'key'
#  287|                           }
#  288|                   }
#  289|->         } while (cmdline[0]);
#  290|           return found_value ? EXIT_SUCCESS : EXIT_FAILURE;
#  291|   }

Error: CLANG_WARNING: [#def31]
dracut-059-build/dracut-059/src/util/util.c:290:16: warning[unix.Malloc]: Potential leak of memory pointed to by 'cmdline'
#  288|                   }
#  289|           } while (cmdline[0]);
#  290|->         return found_value ? EXIT_SUCCESS : EXIT_FAILURE;
#  291|   }
#  292|   

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
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
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