Fixed findings

List of Findings

Error: COMPILER_WARNING (CWE-704): [#def1]
coreutils-9.7/lib/mbschr.c: scope_hint: In function 'mbschr'
coreutils-9.7/lib/mbschr.c:68:12: warning[-Wdiscarded-qualifiers]: return discards 'const' qualifier from pointer target type
#   68 |     return strchr (string, c);
#      |            ^~~~~~
#   66|       }
#   67|     else
#   68|->     return strchr (string, c);
#   69|   }

Error: COMPILER_WARNING (CWE-704): [#def2]
coreutils-9.7/lib/mbschr.c:68:12: warning[-Wdiscarded-qualifiers]: return discards 'const' qualifier from pointer target type
#   66|       }
#   67|     else
#   68|->     return strchr (string, c);
#   69|   }

Error: COMPILER_WARNING (CWE-704): [#def3]
coreutils-9.7/lib/memchr2.c: scope_hint: In function 'memchr2'
coreutils-9.7/lib/memchr2.c:58:12: warning[-Wdiscarded-qualifiers]: return discards 'const' qualifier from pointer target type
#   58 |     return memchr (s, c1, n);
#      |            ^~~~~~
#   56|   
#   57|     if (c1 == c2)
#   58|->     return memchr (s, c1, n);
#   59|   
#   60|     /* Handle the first few bytes by reading one byte at a time.

Error: COMPILER_WARNING (CWE-704): [#def4]
coreutils-9.7/lib/memchr2.c:58:12: warning[-Wdiscarded-qualifiers]: return discards 'const' qualifier from pointer target type
#   56|   
#   57|     if (c1 == c2)
#   58|->     return memchr (s, c1, n);
#   59|   
#   60|     /* Handle the first few bytes by reading one byte at a time.

Error: GCC_ANALYZER_WARNING (CWE-401): [#def5]
coreutils-9.7/src/basenc.c:1105:15: warning[-Wanalyzer-malloc-leak]: leak of 'xmalloc((long unsigned int)base_length(30720))'
coreutils-9.7/src/basenc.c:1089:1: enter_function: entry to 'do_encode'
coreutils-9.7/src/basenc.c:1110:10: branch_false: following 'false' branch (when 'sum <= 0')...
coreutils-9.7/src/basenc.c:1120:11: call_function: inlined call to 'feof_unlocked' from 'do_encode'
coreutils-9.7/src/basenc.c:1105:15: danger: 'xmalloc((long unsigned int)base_length(30720))' leaks here; was allocated at [(2)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/1)
# 1103|         do
# 1104|           {
# 1105|->           n = fread (inbuf + sum, 1, ENC_BLOCKSIZE - sum, in);
# 1106|             sum += n;
# 1107|           }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def6]
coreutils-9.7/src/basenc.c:1146:3: warning[-Wanalyzer-malloc-leak]: leak of 'xmalloc(4200)'
coreutils-9.7/src/basenc.c:1146:3: throw: if the called function throws an exception...
coreutils-9.7/src/basenc.c:1146:3: danger: 'xmalloc(4200)' leaks here; was allocated at [(1)](sarif:/runs/0/results/9/codeFlows/0/threadFlows/0/locations/0)
# 1144|     ctx.inbuf = nullptr;
# 1145|   #endif
# 1146|->   base_decode_ctx_init (&ctx);
# 1147|   
# 1148|     do

Error: GCC_ANALYZER_WARNING (CWE-401): [#def7]
coreutils-9.7/src/basenc.c:1155:21: warning[-Wanalyzer-malloc-leak]: leak of 'inbuf'
coreutils-9.7/src/basenc.c:1155:21: throw: if the called function throws an exception...
coreutils-9.7/src/basenc.c:1155:21: danger: 'inbuf' leaks here; was allocated at [(1)](sarif:/runs/0/results/15/codeFlows/0/threadFlows/0/locations/0)
# 1153|         do
# 1154|           {
# 1155|->           idx_t n = fread (inbuf + sum,
# 1156|                              1, BASE_LENGTH (DEC_BLOCKSIZE) - sum, in);
# 1157|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def8]
coreutils-9.7/src/basenc.c:1155:21: warning[-Wanalyzer-malloc-leak]: leak of 'xmalloc(3072)'
# 1153|         do
# 1154|           {
# 1155|->           idx_t n = fread (inbuf + sum,
# 1156|                              1, BASE_LENGTH (DEC_BLOCKSIZE) - sum, in);
# 1157|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def9]
coreutils-9.7/src/basenc.c:1155:21: warning[-Wanalyzer-malloc-leak]: leak of 'xmalloc(5120)'
# 1153|         do
# 1154|           {
# 1155|->           idx_t n = fread (inbuf + sum,
# 1156|                              1, BASE_LENGTH (DEC_BLOCKSIZE) - sum, in);
# 1157|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def10]
coreutils-9.7/src/basenc.c:1162:23: warning[-Wanalyzer-malloc-leak]: leak of 'inbuf'
coreutils-9.7/src/basenc.c:1133:1: enter_function: entry to 'do_decode'
coreutils-9.7/src/basenc.c:1155:21: call_function: inlined call to 'fread_unlocked' from 'do_decode'
coreutils-9.7/src/basenc.c:1158:14: branch_true: following 'true' branch (when 'ignore_garbage != 0')...
coreutils-9.7/src/basenc.c:1158:14: branch_true: ...to here
coreutils-9.7/src/basenc.c:1160:33: branch_true: following 'true' branch...
coreutils-9.7/src/basenc.c:1162:23: branch_true: ...to here
coreutils-9.7/src/basenc.c:1162:23: throw: if the called function throws an exception...
coreutils-9.7/src/basenc.c:1162:23: danger: 'inbuf' leaks here; was allocated at [(2)](sarif:/runs/0/results/16/codeFlows/0/threadFlows/0/locations/1)
# 1160|                 for (idx_t i = 0; n > 0 && i < n;)
# 1161|                   {
# 1162|->                   if (isubase (inbuf[sum + i]) || inbuf[sum + i] == '=')
# 1163|                       i++;
# 1164|                     else

Error: GCC_ANALYZER_WARNING (CWE-401): [#def11]
coreutils-9.7/src/basenc.c:1174:20: warning[-Wanalyzer-malloc-leak]: leak of 'inbuf'
coreutils-9.7/src/basenc.c:1133:1: enter_function: entry to 'do_decode'
coreutils-9.7/src/basenc.c:1155:21: call_function: inlined call to 'fread_unlocked' from 'do_decode'
coreutils-9.7/src/basenc.c:1155:17: branch_true: ...to here
coreutils-9.7/src/basenc.c:1158:14: branch_true: following 'true' branch (when 'ignore_garbage != 0')...
coreutils-9.7/src/basenc.c:1158:14: branch_true: ...to here
coreutils-9.7/src/basenc.c:1160:33: branch_false: following 'false' branch...
coreutils-9.7/src/basenc.c:1169:11: branch_false: ...to here
coreutils-9.7/src/basenc.c:1171:14: branch_false: following 'false' branch...
coreutils-9.7/src/basenc.c:1174:20: branch_false: ...to here
coreutils-9.7/src/basenc.c:1174:20: throw: if the called function throws an exception...
coreutils-9.7/src/basenc.c:1174:20: danger: 'inbuf' leaks here; was allocated at [(2)](sarif:/runs/0/results/17/codeFlows/0/threadFlows/0/locations/1)
# 1172|               error (EXIT_FAILURE, errno, _("read error"));
# 1173|           }
# 1174|->       while (sum < BASE_LENGTH (DEC_BLOCKSIZE) && !feof (in));
# 1175|   
# 1176|         /* The following "loop" is usually iterated just once.

Error: GCC_ANALYZER_WARNING (CWE-401): [#def12]
coreutils-9.7/src/basenc.c:1200:16: warning[-Wanalyzer-malloc-leak]: leak of 'inbuf'
coreutils-9.7/src/basenc.c:1133:1: enter_function: entry to 'do_decode'
coreutils-9.7/src/basenc.c:1155:21: call_function: inlined call to 'fread_unlocked' from 'do_decode'
coreutils-9.7/src/basenc.c:1158:14: branch_true: following 'true' branch (when 'ignore_garbage != 0')...
coreutils-9.7/src/basenc.c:1158:14: branch_true: ...to here
coreutils-9.7/src/basenc.c:1160:33: branch_false: following 'false' branch...
coreutils-9.7/src/basenc.c:1169:11: branch_false: ...to here
coreutils-9.7/src/basenc.c:1171:14: branch_false: following 'false' branch...
coreutils-9.7/src/basenc.c:1174:20: branch_false: ...to here
coreutils-9.7/src/basenc.c:1180:23: branch_true: following 'true' branch...
coreutils-9.7/src/basenc.c:1182:14: branch_true: ...to here
coreutils-9.7/src/basenc.c:1182:14: branch_false: following 'false' branch (when 'k != 1')...
coreutils-9.7/src/basenc.c:1199:17: branch_false: ...to here
coreutils-9.7/src/basenc.c:1200:16: throw: if the called function throws an exception...
coreutils-9.7/src/basenc.c:1200:16: danger: 'inbuf' leaks here; was allocated at [(2)](sarif:/runs/0/results/18/codeFlows/0/threadFlows/0/locations/1)
# 1198|               }
# 1199|             idx_t n = DEC_BLOCKSIZE;
# 1200|->           ok = base_decode_ctx (&ctx, inbuf, sum, outbuf, &n);
# 1201|   
# 1202|             if (fwrite (outbuf, 1, n, out) < n)

Error: GCC_ANALYZER_WARNING (CWE-401): [#def13]
coreutils-9.7/src/chcon.c:320:13: warning[-Wanalyzer-malloc-leak]: leak of 'xfts_open(files,  bit_flags, 0)'
coreutils-9.7/src/chcon.c:320:13: throw: if 'rpl_fts_read' throws an exception...
coreutils-9.7/src/chcon.c:320:13: danger: 'xfts_open(files,  bit_flags, 0)' leaks here; was allocated at [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)
#  318|         FTSENT *ent;
#  319|   
#  320|->       ent = fts_read (fts);
#  321|         if (ent == nullptr)
#  322|           {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def14]
coreutils-9.7/src/chmod.c:381:13: warning[-Wanalyzer-malloc-leak]: leak of 'xfts_open(files,  bit_flags, 0)'
coreutils-9.7/src/chmod.c:381:13: throw: if 'rpl_fts_read' throws an exception...
coreutils-9.7/src/chmod.c:381:13: danger: 'xfts_open(files,  bit_flags, 0)' leaks here; was allocated at [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)
#  379|         FTSENT *ent;
#  380|   
#  381|->       ent = fts_read (fts);
#  382|         if (ent == nullptr)
#  383|           {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def15]
coreutils-9.7/src/chown-core.c:556:13: warning[-Wanalyzer-malloc-leak]: leak of 'xfts_open(files,  stat_flags | bit_flags, 0)'
coreutils-9.7/src/chown-core.c:556:13: throw: if 'rpl_fts_read' throws an exception...
coreutils-9.7/src/chown-core.c:556:13: danger: 'xfts_open(files,  stat_flags | bit_flags, 0)' leaks here; was allocated at [(1)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/0)
#  554|         FTSENT *ent;
#  555|   
#  556|->       ent = fts_read (fts);
#  557|         if (ent == nullptr)
#  558|           {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def16]
coreutils-9.7/src/date.c:656:5: warning[-Wanalyzer-malloc-leak]: leak of 'format_res'
coreutils-9.7/src/date.c:397:1: enter_function: entry to 'single_binary_main_date'
coreutils-9.7/src/date.c:510:6: branch_false: following 'false' branch (when 'option_specified_date <= 1')...
coreutils-9.7/src/date.c:517:16: branch_false: ...to here
coreutils-9.7/src/date.c:517:6: branch_false: following 'false' branch...
coreutils-9.7/src/date.c:524:6: branch_false: ...to here
coreutils-9.7/src/date.c:524:6: branch_false: following 'false' branch (when 'discarded_datestr == 0')...
coreutils-9.7/src/date.c:527:6: branch_false: ...to here
coreutils-9.7/src/date.c:527:6: branch_false: following 'false' branch (when 'discarded_set_datestr == 0')...
coreutils-9.7/src/date.c:530:7: branch_false: ...to here
coreutils-9.7/src/date.c:555:6: branch_true: following 'true' branch (when 'format' is NULL)...
coreutils-9.7/src/date.c:557:10: branch_true: ...to here
coreutils-9.7/src/date.c:575:23: call_function: calling 'adjust_resolution' from 'single_binary_main_date'
coreutils-9.7/src/date.c:575:23: return_function: returning to 'single_binary_main_date' from 'adjust_resolution'
coreutils-9.7/src/date.c:576:28: branch_true: following 'true' branch...
coreutils-9.7/src/date.c:577:26: branch_true: ...to here
coreutils-9.7/src/date.c:580:6: branch_false: following 'false' branch (when 'batch_file' is NULL)...
coreutils-9.7/src/date.c:580:6: branch_false: ...to here
coreutils-9.7/src/date.c:635:10: branch_false: following 'false' branch (when 'set_date == 0')...
coreutils-9.7/src/date.c:646:13: branch_false: ...to here
coreutils-9.7/src/date.c:646:13: call_function: calling 'show_date_helper' from 'single_binary_main_date'
#  654|   {
#  655|     if (parse_datetime_flags & PARSE_DATETIME_DEBUG)
#  656|->     error (0, 0, _("output format: %s"), quote (format));
#  657|   
#  658|     if (format == rfc_email_format)

Error: GCC_ANALYZER_WARNING (CWE-401): [#def17]
coreutils-9.7/src/date.c:661:13: warning[-Wanalyzer-malloc-leak]: leak of 'format_res'
coreutils-9.7/src/date.c:397:1: enter_function: entry to 'main'
coreutils-9.7/src/date.c:510:6: branch_false: following 'false' branch (when 'option_specified_date <= 1')...
coreutils-9.7/src/date.c:517:16: branch_false: ...to here
coreutils-9.7/src/date.c:517:6: branch_false: following 'false' branch...
coreutils-9.7/src/date.c:524:6: branch_false: ...to here
coreutils-9.7/src/date.c:524:6: branch_false: following 'false' branch (when 'discarded_datestr == 0')...
coreutils-9.7/src/date.c:527:6: branch_false: ...to here
coreutils-9.7/src/date.c:527:6: branch_false: following 'false' branch (when 'discarded_set_datestr == 0')...
coreutils-9.7/src/date.c:530:7: branch_false: ...to here
coreutils-9.7/src/date.c:555:6: branch_true: following 'true' branch (when 'format' is NULL)...
coreutils-9.7/src/date.c:557:10: branch_true: ...to here
coreutils-9.7/src/date.c:575:23: call_function: calling 'adjust_resolution' from 'main'
coreutils-9.7/src/date.c:575:23: return_function: returning to 'main' from 'adjust_resolution'
coreutils-9.7/src/date.c:576:28: branch_true: following 'true' branch...
coreutils-9.7/src/date.c:577:26: branch_true: ...to here
coreutils-9.7/src/date.c:580:6: branch_false: following 'false' branch (when 'batch_file' is NULL)...
coreutils-9.7/src/date.c:580:6: branch_false: ...to here
coreutils-9.7/src/date.c:635:10: branch_false: following 'false' branch (when 'set_date == 0')...
coreutils-9.7/src/date.c:646:13: branch_false: ...to here
coreutils-9.7/src/date.c:646:13: call_function: calling 'show_date_helper' from 'main'
#  659|       setlocale (LC_TIME, "C");
#  660|   
#  661|->   bool ok = show_date (format, when, tz);
#  662|   
#  663|     if (format == rfc_email_format)

Error: GCC_ANALYZER_WARNING (CWE-401): [#def18]
coreutils-9.7/src/df.c:452:15: warning[-Wanalyzer-malloc-leak]: leak of 'xstrdup(arg)'
coreutils-9.7/src/df.c:1592:1: enter_function: entry to 'main'
coreutils-9.7/src/df.c:1625:10: branch_false: following 'false' branch (when 'c != -1')...
coreutils-9.7/src/df.c:1628:7: branch_false: ...to here
coreutils-9.7/src/df.c:1708:14: branch_false: following 'false' branch...
coreutils-9.7/src/df.c:1713:14: branch_false: ...to here
coreutils-9.7/src/df.c:1713:14: branch_false: following 'false' branch (when 'posix_format == 0')...
coreutils-9.7/src/df.c:1718:15: branch_false: ...to here
coreutils-9.7/src/df.c:1718:14: branch_false: following 'false' branch...
coreutils-9.7/src/df.c:1723:11: branch_false: ...to here
coreutils-9.7/src/df.c:1724:14: branch_true: following 'true' branch...
coreutils-9.7/src/df.c:1725:13: branch_true: ...to here
coreutils-9.7/src/df.c:1725:13: call_function: calling 'decode_output_arg' from 'main'
#  450|         for (idx_t i = 0; i < ARRAY_CARDINALITY (field_data); i++)
#  451|           {
#  452|->           if (STREQ (field_data[i].arg, s))
#  453|               {
#  454|                 field = i;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def19]
coreutils-9.7/src/du.c:669:17: warning[-Wanalyzer-malloc-leak]: leak of 'xfts_open(files,  bit_flags, 0)'
coreutils-9.7/src/du.c:661:6: branch_true: following 'true' branch...
coreutils-9.7/src/du.c:663:18: branch_true: ...to here
coreutils-9.7/src/du.c:669:17: throw: if 'rpl_fts_read' throws an exception...
coreutils-9.7/src/du.c:669:17: danger: 'xfts_open(files,  bit_flags, 0)' leaks here; was allocated at [(3)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/2)
#  667|             FTSENT *ent;
#  668|   
#  669|->           ent = fts_read (fts);
#  670|             if (ent == nullptr)
#  671|               {

Error: GCC_ANALYZER_WARNING (CWE-686): [#def20]
coreutils-9.7/src/factor.c:571:10: warning[-Wanalyzer-va-arg-type-mismatch]: 'va_arg' expected '__mpz_struct (*)[1]' but received 'typeof (nullptr)' for variadic argument 5 of 'ap'
coreutils-9.7/src/factor.c:1359:1: enter_function: entry to 'mp_prime_p'
coreutils-9.7/src/factor.c:1372:3: call_function: calling 'mpz_va_init' from 'mp_prime_p' with 5 variadic arguments
#  569|   
#  570|     mpz_t *mpz;
#  571|->   while ((mpz = va_arg (ap, mpz_t *)))
#  572|       mpz_single_init (*mpz);
#  573|   

Error: GCC_ANALYZER_WARNING (CWE-404): [#def21]
coreutils-9.7/src/factor.c:572:5: warning[-Wanalyzer-va-list-leak]: missing call to 'va_end'
coreutils-9.7/src/factor.c:1359:1: enter_function: entry to 'mp_prime_p'
coreutils-9.7/src/factor.c:1372:3: call_function: calling 'mpz_va_init' from 'mp_prime_p'
#  570|     mpz_t *mpz;
#  571|     while ((mpz = va_arg (ap, mpz_t *)))
#  572|->     mpz_single_init (*mpz);
#  573|   
#  574|     va_end (ap);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def22]
coreutils-9.7/src/paste.c:194:11: warning[-Wanalyzer-malloc-leak]: leak of 'xnmalloc(nfiles + 1, 8)'
coreutils-9.7/src/paste.c:451:1: enter_function: entry to 'main'
coreutils-9.7/src/paste.c:500:7: call_function: calling 'collapse_escapes' from 'main'
coreutils-9.7/src/paste.c:500:7: return_function: returning to 'main' from 'collapse_escapes'
coreutils-9.7/src/paste.c:500:6: branch_false: following 'false' branch...
coreutils-9.7/src/paste.c:509:28: branch_false: ...to here
coreutils-9.7/src/paste.c:509:14: branch_false: following 'false' branch...
coreutils-9.7/src/paste.c:509:14: branch_false: ...to here
coreutils-9.7/src/paste.c:509:13: call_function: calling 'paste_parallel' from 'main'
#  192|     for (files_open = 0; files_open < nfiles; ++files_open)
#  193|       {
#  194|->       if (STREQ (fnamptr[files_open], "-"))
#  195|           {
#  196|             have_read_stdin = true;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def23]
coreutils-9.7/src/remove.c:623:17: warning[-Wanalyzer-malloc-leak]: leak of 'xfts_open(file,  bit_flags, 0)'
coreutils-9.7/src/remove.c:608:6: branch_true: following 'true' branch...
coreutils-9.7/src/remove.c:614:11: branch_true: ...to here
coreutils-9.7/src/remove.c:623:17: throw: if 'rpl_fts_read' throws an exception...
coreutils-9.7/src/remove.c:623:17: danger: 'xfts_open(file,  bit_flags, 0)' leaks here; was allocated at [(3)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/2)
#  621|             FTSENT *ent;
#  622|   
#  623|->           ent = fts_read (fts);
#  624|             if (ent == nullptr)
#  625|               {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def24]
coreutils-9.7/src/rmdir.c:273:39: warning[-Wanalyzer-malloc-leak]: leak of 'xstrdup(dir)'
coreutils-9.7/src/rmdir.c:232:6: branch_false: following 'false' branch...
coreutils-9.7/src/rmdir.c:232:6: branch_false: ...to here
coreutils-9.7/src/rmdir.c:238:10: branch_true: following 'true' branch...
coreutils-9.7/src/rmdir.c:240:23: branch_true: ...to here
coreutils-9.7/src/rmdir.c:246:10: branch_true: following 'true' branch...
coreutils-9.7/src/rmdir.c:248:29: branch_true: ...to here
coreutils-9.7/src/rmdir.c:249:14: branch_false: following 'false' branch...
coreutils-9.7/src/rmdir.c:258:14: branch_false: ...to here
coreutils-9.7/src/rmdir.c:258:14: branch_true: following 'true' branch (when 'rmdir_errno == 20')...
coreutils-9.7/src/rmdir.c:260:45: branch_true: ...to here
coreutils-9.7/src/rmdir.c:261:18: branch_true: following 'true' branch...
coreutils-9.7/src/rmdir.c:267:26: branch_true: following 'true' branch...
coreutils-9.7/src/rmdir.c:270:39: branch_true: ...to here
coreutils-9.7/src/rmdir.c:273:26: branch_true: following 'true' branch...
coreutils-9.7/src/rmdir.c:275:27: throw: if 'quotearg_style' throws an exception...
coreutils-9.7/src/rmdir.c:273:39: danger: 'xstrdup(dir)' leaks here; was allocated at [(15)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/14)
#  271|                         strip_trailing_slashes (dir);
#  272|                         ret = lstat (dir, &st);
#  273|->                       if (ret == 0 && S_ISLNK (st.st_mode))
#  274|                           {
#  275|                             error (0, 0,

Error: GCC_ANALYZER_WARNING (CWE-401): [#def25]
coreutils-9.7/src/selinux.c:314:28: warning[-Wanalyzer-malloc-leak]: leak of 'xfts_open(&ftspath, 16, 0)'
coreutils-9.7/src/selinux.c:290:6: branch_false: following 'false' branch...
coreutils-9.7/src/selinux.c:301:6: branch_false: ...to here
coreutils-9.7/src/selinux.c:301:6: branch_true: following 'true' branch (when 'recurse != 0')...
coreutils-9.7/src/selinux.c:310:15: branch_true: ...to here
coreutils-9.7/src/selinux.c:314:28: throw: if 'rpl_fts_read' throws an exception...
coreutils-9.7/src/selinux.c:314:28: danger: 'xfts_open(&ftspath, 16, 0)' leaks here; was allocated at [(5)](sarif:/runs/0/results/10/codeFlows/0/threadFlows/0/locations/4)
#  312|   
#  313|     int err = 0;
#  314|->   for (FTSENT *ent; (ent = fts_read (fts)); )
#  315|       if (restorecon_private (selabel_handle, fts->fts_path) < 0)
#  316|         err = errno;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def26]
coreutils-9.7/src/shred.c:1255:11: warning[-Wanalyzer-malloc-leak]: leak of 'xstrdup(quotearg_n_style_colon(0, 3, *<unknown>))'
coreutils-9.7/src/shred.c:1161:1: enter_function: entry to 'main'
coreutils-9.7/src/shred.c:1240:6: branch_false: following 'false' branch (when 'n_files != 0')...
coreutils-9.7/src/shred.c:1246:20: branch_false: ...to here
coreutils-9.7/src/shred.c:1247:6: branch_false: following 'false' branch...
coreutils-9.7/src/shred.c:1250:3: branch_false: ...to here
coreutils-9.7/src/shred.c:1252:15: branch_true: following 'true' branch (when 'i < n_files')...
coreutils-9.7/src/shred.c:1254:30: branch_true: ...to here
coreutils-9.7/src/shred.c:1255:10: branch_false: following 'false' branch (when the strings are non-equal)...
coreutils-9.7/src/shred.c:1262:17: branch_false: ...to here
coreutils-9.7/src/shred.c:1262:17: call_function: calling 'wipefile' from 'main'
# 1253|       {
# 1254|         char *qname = xstrdup (quotef (file[i]));
# 1255|->       if (STREQ (file[i], "-"))
# 1256|           {
# 1257|             ok &= wipefd (STDOUT_FILENO, qname, randint_source, &flags);

Error: CPPCHECK_WARNING (CWE-457): [#def27]
coreutils-9.7/src/sort.c:1162: warning[uninitvar]: Uninitialized variable: pid
# 1160|       }
# 1161|   
# 1162|->   if (pid < 0)
# 1163|       {
# 1164|         saved_errno = errno;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def28]
coreutils-9.7/src/split.c:524:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'fd_pair[0]'
coreutils-9.7/src/split.c:1071:1: enter_function: entry to 'ofile_open'
coreutils-9.7/src/split.c:1075:6: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1078:24: branch_true: ...to here
coreutils-9.7/src/split.c:1085:14: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1086:26: branch_true: ...to here
coreutils-9.7/src/split.c:1086:18: call_function: calling 'create' from 'ofile_open'
#  522|                reading an EOF on the corresponding read-pipe.  */
#  523|             for (j = 0; j < n_open_pipes; ++j)
#  524|->             if (close (open_pipes[j]) != 0)
#  525|                 error (EXIT_FAILURE, errno, _("closing prior pipe"));
#  526|             if (close (fd_pair[1]))

Error: GCC_ANALYZER_WARNING (CWE-775): [#def29]
coreutils-9.7/src/split.c:524:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'fd_pair[1]'
coreutils-9.7/src/split.c:1071:1: enter_function: entry to 'ofile_open'
coreutils-9.7/src/split.c:1075:6: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1078:24: branch_true: ...to here
coreutils-9.7/src/split.c:1085:14: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1086:26: branch_true: ...to here
coreutils-9.7/src/split.c:1086:18: call_function: calling 'create' from 'ofile_open'
#  522|                reading an EOF on the corresponding read-pipe.  */
#  523|             for (j = 0; j < n_open_pipes; ++j)
#  524|->             if (close (open_pipes[j]) != 0)
#  525|                 error (EXIT_FAILURE, errno, _("closing prior pipe"));
#  526|             if (close (fd_pair[1]))

Error: GCC_ANALYZER_WARNING (CWE-775): [#def30]
coreutils-9.7/src/split.c:524:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'fd_pair[j]'
coreutils-9.7/src/split.c:1071:1: enter_function: entry to 'ofile_open'
coreutils-9.7/src/split.c:1075:6: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1078:24: branch_true: ...to here
coreutils-9.7/src/split.c:1085:14: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1086:26: branch_true: ...to here
coreutils-9.7/src/split.c:1086:18: call_function: calling 'create' from 'ofile_open'
#  522|                reading an EOF on the corresponding read-pipe.  */
#  523|             for (j = 0; j < n_open_pipes; ++j)
#  524|->             if (close (open_pipes[j]) != 0)
#  525|                 error (EXIT_FAILURE, errno, _("closing prior pipe"));
#  526|             if (close (fd_pair[1]))

Error: GCC_ANALYZER_WARNING (CWE-775): [#def31]
coreutils-9.7/src/split.c:526:15: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'fd_pair[0]'
coreutils-9.7/src/split.c:1071:1: enter_function: entry to 'ofile_open'
coreutils-9.7/src/split.c:1075:6: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1078:24: branch_true: ...to here
coreutils-9.7/src/split.c:1085:14: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1086:26: branch_true: ...to here
coreutils-9.7/src/split.c:1086:18: call_function: calling 'create' from 'ofile_open'
#  524|               if (close (open_pipes[j]) != 0)
#  525|                 error (EXIT_FAILURE, errno, _("closing prior pipe"));
#  526|->           if (close (fd_pair[1]))
#  527|               error (EXIT_FAILURE, errno, _("closing output pipe"));
#  528|             if (fd_pair[0] != STDIN_FILENO)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def32]
coreutils-9.7/src/split.c:526:15: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'fd_pair[1]'
coreutils-9.7/src/split.c:1071:1: enter_function: entry to 'ofile_open'
coreutils-9.7/src/split.c:1075:6: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1078:24: branch_true: ...to here
coreutils-9.7/src/split.c:1085:14: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1086:26: branch_true: ...to here
coreutils-9.7/src/split.c:1086:18: call_function: calling 'create' from 'ofile_open'
#  524|               if (close (open_pipes[j]) != 0)
#  525|                 error (EXIT_FAILURE, errno, _("closing prior pipe"));
#  526|->           if (close (fd_pair[1]))
#  527|               error (EXIT_FAILURE, errno, _("closing output pipe"));
#  528|             if (fd_pair[0] != STDIN_FILENO)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def33]
coreutils-9.7/src/split.c:530:18: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'dup2(fd_pair[0], 0)'
coreutils-9.7/src/split.c:1071:1: enter_function: entry to 'ofile_open'
coreutils-9.7/src/split.c:1075:6: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1078:24: branch_true: ...to here
coreutils-9.7/src/split.c:1085:14: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1086:26: branch_true: ...to here
coreutils-9.7/src/split.c:1086:18: call_function: calling 'create' from 'ofile_open'
#  528|             if (fd_pair[0] != STDIN_FILENO)
#  529|               {
#  530|->               if (dup2 (fd_pair[0], STDIN_FILENO) != STDIN_FILENO)
#  531|                   error (EXIT_FAILURE, errno, _("moving input pipe"));
#  532|                 if (close (fd_pair[0]) != 0)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def34]
coreutils-9.7/src/split.c:544:11: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'fd_pair[0]'
coreutils-9.7/src/split.c:1071:1: enter_function: entry to 'ofile_open'
coreutils-9.7/src/split.c:1075:6: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1078:24: branch_true: ...to here
coreutils-9.7/src/split.c:1085:14: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1086:26: branch_true: ...to here
coreutils-9.7/src/split.c:1086:18: call_function: calling 'create' from 'ofile_open'
#  542|         if (child_pid < 0)
#  543|           error (EXIT_FAILURE, errno, _("fork system call failed"));
#  544|->       if (close (fd_pair[0]) != 0)
#  545|           error (EXIT_FAILURE, errno, _("failed to close input pipe"));
#  546|         filter_pid = child_pid;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def35]
coreutils-9.7/src/split.c:544:11: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'fd_pair[1]'
coreutils-9.7/src/split.c:1071:1: enter_function: entry to 'ofile_open'
coreutils-9.7/src/split.c:1075:6: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1078:24: branch_true: ...to here
coreutils-9.7/src/split.c:1085:14: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1086:26: branch_true: ...to here
coreutils-9.7/src/split.c:1086:18: call_function: calling 'create' from 'ofile_open'
#  542|         if (child_pid < 0)
#  543|           error (EXIT_FAILURE, errno, _("fork system call failed"));
#  544|->       if (close (fd_pair[0]) != 0)
#  545|           error (EXIT_FAILURE, errno, _("failed to close input pipe"));
#  546|         filter_pid = child_pid;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def36]
coreutils-9.7/src/split.c:548:22: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'fd_pair[1]'
coreutils-9.7/src/split.c:1071:1: enter_function: entry to 'ofile_open'
coreutils-9.7/src/split.c:1075:6: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1078:24: branch_true: ...to here
coreutils-9.7/src/split.c:1085:14: branch_true: following 'true' branch...
coreutils-9.7/src/split.c:1086:26: branch_true: ...to here
coreutils-9.7/src/split.c:1086:18: call_function: calling 'create' from 'ofile_open'
#  546|         filter_pid = child_pid;
#  547|         if (n_open_pipes == open_pipes_alloc)
#  548|->         open_pipes = xpalloc (open_pipes, &open_pipes_alloc, 1,
#  549|                                 MIN (INT_MAX, IDX_MAX), sizeof *open_pipes);
#  550|         open_pipes[n_open_pipes++] = fd_pair[1];

Error: GCC_ANALYZER_WARNING (CWE-401): [#def37]
coreutils-9.7/src/tail.c:426:7: warning[-Wanalyzer-malloc-leak]: leak of 'first'
coreutils-9.7/src/tail.c:1923:1: enter_function: entry to 'tail_lines'
coreutils-9.7/src/tail.c:1928:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1934:7: branch_false: ...to here
coreutils-9.7/src/tail.c:1934:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1955:12: branch_false: ...to here
coreutils-9.7/src/tail.c:1975:18: call_function: calling 'pipe_lines' from 'tail_lines'
#  424|       {
#  425|         clearerr (stdout); /* To avoid redundant close_stdout diagnostic.  */
#  426|->       error (EXIT_FAILURE, errno, _("error writing %s"),
#  427|                quoteaf ("standard output"));
#  428|       }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def38]
coreutils-9.7/src/tail.c:548:26: warning[-Wanalyzer-malloc-leak]: leak of 'xmalloc((long unsigned int)bufsize)'
coreutils-9.7/src/tail.c:1923:1: enter_function: entry to 'tail_lines'
coreutils-9.7/src/tail.c:1928:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1934:7: branch_false: ...to here
coreutils-9.7/src/tail.c:1934:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1955:12: branch_false: ...to here
coreutils-9.7/src/tail.c:1955:10: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1956:15: branch_false: ...to here
coreutils-9.7/src/tail.c:1955:12: branch_true: following 'true' branch...
coreutils-9.7/src/tail.c:1957:28: branch_true: ...to here
coreutils-9.7/src/tail.c:1955:12: branch_true: following 'true' branch (when 'start_pos != -1')...
coreutils-9.7/src/tail.c:1958:38: branch_true: ...to here
coreutils-9.7/src/tail.c:1955:12: branch_true: following 'true' branch (when 'start_pos < end_pos')...
coreutils-9.7/src/tail.c:1960:11: branch_true: ...to here
coreutils-9.7/src/tail.c:1961:14: branch_true: following 'true' branch (when 'end_pos != 0')...
coreutils-9.7/src/tail.c:1962:20: branch_true: ...to here
coreutils-9.7/src/tail.c:1962:20: call_function: calling 'file_lines' from 'tail_lines'
#  546|     /* Set 'bytes_read' to the size of the last, probably partial, buffer;
#  547|        0 < 'bytes_read' <= 'bufsize'.  */
#  548|->   ptrdiff_t bytes_read = (pos - start_pos) % bufsize;
#  549|     if (bytes_read == 0)
#  550|       bytes_read = bufsize;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def39]
coreutils-9.7/src/tail.c:651:16: warning[-Wanalyzer-malloc-leak]: leak of 'first'
coreutils-9.7/src/tail.c:1923:1: enter_function: entry to 'tail_lines'
coreutils-9.7/src/tail.c:1928:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1934:7: branch_false: ...to here
coreutils-9.7/src/tail.c:1934:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1955:12: branch_false: ...to here
coreutils-9.7/src/tail.c:1975:18: call_function: calling 'pipe_lines' from 'tail_lines'
#  649|     while (true)
#  650|       {
#  651|->       n_read = safe_read (fd, tmp->buffer, BUFSIZ);
#  652|         if (n_read <= 0)
#  653|           break;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def40]
coreutils-9.7/src/tail.c:651:16: warning[-Wanalyzer-malloc-leak]: leak of 'tmp'
coreutils-9.7/src/tail.c:1923:1: enter_function: entry to 'tail_lines'
coreutils-9.7/src/tail.c:1928:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1934:7: branch_false: ...to here
coreutils-9.7/src/tail.c:1934:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1955:12: branch_false: ...to here
coreutils-9.7/src/tail.c:1975:18: call_function: calling 'pipe_lines' from 'tail_lines'
#  649|     while (true)
#  650|       {
#  651|->       n_read = safe_read (fd, tmp->buffer, BUFSIZ);
#  652|         if (n_read <= 0)
#  653|           break;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def41]
coreutils-9.7/src/tail.c:703:7: warning[-Wanalyzer-malloc-leak]: leak of 'first'
coreutils-9.7/src/tail.c:1923:1: enter_function: entry to 'tail_lines'
coreutils-9.7/src/tail.c:1928:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1934:7: branch_false: ...to here
coreutils-9.7/src/tail.c:1934:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1955:12: branch_false: ...to here
coreutils-9.7/src/tail.c:1975:18: call_function: calling 'pipe_lines' from 'tail_lines'
#  701|     if (n_read < 0 && errno != EAGAIN)
#  702|       {
#  703|->       error (0, errno, _("error reading %s"), quoteaf (pretty_filename));
#  704|         ok = false;
#  705|         goto free_lbuffers;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def42]
coreutils-9.7/src/tail.c:790:16: warning[-Wanalyzer-malloc-leak]: leak of 'first'
coreutils-9.7/src/tail.c:1992:1: enter_function: entry to 'tail'
coreutils-9.7/src/tail.c:1996:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1999:12: branch_false: ...to here
coreutils-9.7/src/tail.c:1999:12: call_function: calling 'tail_bytes' from 'tail'
#  788|     while (true)
#  789|       {
#  790|->       n_read = safe_read (fd, tmp->buffer, BUFSIZ);
#  791|         if (n_read <= 0)
#  792|           break;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def43]
coreutils-9.7/src/tail.c:790:16: warning[-Wanalyzer-malloc-leak]: leak of 'tmp'
coreutils-9.7/src/tail.c:1992:1: enter_function: entry to 'tail'
coreutils-9.7/src/tail.c:1996:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1999:12: branch_false: ...to here
coreutils-9.7/src/tail.c:1999:12: call_function: calling 'tail_bytes' from 'tail'
#  788|     while (true)
#  789|       {
#  790|->       n_read = safe_read (fd, tmp->buffer, BUFSIZ);
#  791|         if (n_read <= 0)
#  792|           break;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def44]
coreutils-9.7/src/tail.c:831:7: warning[-Wanalyzer-malloc-leak]: leak of 'first'
coreutils-9.7/src/tail.c:1992:1: enter_function: entry to 'tail'
coreutils-9.7/src/tail.c:1996:6: branch_false: following 'false' branch...
coreutils-9.7/src/tail.c:1999:12: branch_false: ...to here
coreutils-9.7/src/tail.c:1999:12: call_function: calling 'tail_bytes' from 'tail'
#  829|     if (n_read < 0 && errno != EAGAIN)
#  830|       {
#  831|->       error (0, errno, _("error reading %s"), quoteaf (pretty_filename));
#  832|         ok = false;
#  833|         goto free_cbuffers;

Error: CPPCHECK_WARNING (CWE-758): [#def45]
coreutils-9.7/src/tail.c:2424: warning[objectIndex]: The address of variable 'dummy_stdin' might be accessed at non-zero index.
# 2422|   
# 2423|       for (i = 0; i < n_files; i++)
# 2424|->       if (STREQ (file[i], "-"))
# 2425|           found_hyphen = true;
# 2426|   

Scan Properties

analyzer-version-clippy1.92.0
analyzer-version-cppcheck2.19.1
analyzer-version-gcc16.0.0
analyzer-version-gcc-analyzer16.0.0
analyzer-version-shellcheck0.11.0
analyzer-version-unicontrol0.0.2
diffbase-analyzer-version-clippy1.92.0
diffbase-analyzer-version-cppcheck2.19.1
diffbase-analyzer-version-gcc16.0.0
diffbase-analyzer-version-gcc-analyzer16.0.0
diffbase-analyzer-version-shellcheck0.11.0
diffbase-analyzer-version-unicontrol0.0.2
diffbase-enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
diffbase-exit-code0
diffbase-hostip-172-16-1-198.us-west-2.compute.internal
diffbase-known-false-positives/usr/share/csmock/known-false-positives.js
diffbase-known-false-positives-rpmknown-false-positives-0.0.0.20250521.132812.g8eff701.main-1.el9.noarch
diffbase-mock-configfedora-rawhide-x86_64
diffbase-project-namecoreutils-9.9-1.fc44
diffbase-store-results-to/tmp/tmpebfnyatg/coreutils-9.9-1.fc44.tar.xz
diffbase-time-created2026-01-08 15:54:34
diffbase-time-finished2026-01-08 16:00:19
diffbase-toolcsmock
diffbase-tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'gcc,cppcheck,clippy,shellcheck,unicontrol' '-o' '/tmp/tmpebfnyatg/coreutils-9.9-1.fc44.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmpebfnyatg/coreutils-9.9-1.fc44.src.rpm'
diffbase-tool-versioncsmock-3.8.3.20251215.161544.g62de9a5-1.el9
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-198.us-west-2.compute.internal
known-false-positives/usr/share/csmock/known-false-positives.js
known-false-positives-rpmknown-false-positives-0.0.0.20250521.132812.g8eff701.main-1.el9.noarch
mock-configfedora-rawhide-x86_64
project-namecoreutils-9.7-6.fc43
store-results-to/tmp/tmpii1bet1g/coreutils-9.7-6.fc43.tar.xz
time-created2026-01-08 15:48:05
time-finished2026-01-08 15:54:10
titleFixed findings
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'gcc,cppcheck,clippy,shellcheck,unicontrol' '-o' '/tmp/tmpii1bet1g/coreutils-9.7-6.fc43.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmpii1bet1g/coreutils-9.7-6.fc43.src.rpm'
tool-versioncsmock-3.8.3.20251215.161544.g62de9a5-1.el9