Fixed defects
List of Defects
Error: GCC_ANALYZER_WARNING (CWE-401): [#def1]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘readConfig’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:247:19: warning[-Wanalyzer-malloc-leak]: leak of ‘parseLine(&buf)’
# 245| char *end;
# 246|
# 247|-> if (!*buf || !**buf)
# 248| return NULL;
# 249|
Error: COMPILER_WARNING (CWE-704): [#def2]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘readConfig’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:290:10: warning[-Wdiscarded-qualifiers]: assignment discards ‘const’ qualifier from pointer target type
# 288| sprintf(path, "%s/%s", stateDir, title);
# 289|
# 290|-> path = normalize_path(path);
# 291|
# 292| if (FL_VERBOSE(flags))
Error: GCC_ANALYZER_WARNING (CWE-401): [#def3]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:297:20: warning[-Wanalyzer-malloc-leak]: leak of ‘groups’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:18: included_from: Included from here.
# 295| if ((fd = open(path, O_RDONLY)) < 0) {
# 296| if (errno == ENOENT)
# 297|-> return 3;
# 298| fprintf(stderr, _("failed to open %s: %s\n"), path, strerror(errno));
# 299| return 1;
Error: GCC_ANALYZER_WARNING (CWE-401): [#def4]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:297:20: warning[-Wanalyzer-malloc-leak]: leak of ‘line’
# 295| if ((fd = open(path, O_RDONLY)) < 0) {
# 296| if (errno == ENOENT)
# 297|-> return 3;
# 298| fprintf(stderr, _("failed to open %s: %s\n"), path, strerror(errno));
# 299| return 1;
Error: CLANG_WARNING: [#def5]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:323:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'line'
# 321| set->mode = MANUAL;
# 322| } else {
# 323|-> fprintf(stderr, _("bad mode on line 1 of %s\n"), path);
# 324| return 1;
# 325| }
Error: CLANG_WARNING: [#def6]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:330:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'line'
# 328| line = parseLine(&buf);
# 329| if (!line || *line != '/') {
# 330|-> fprintf(stderr, _("bad primary link in %s\n"), path);
# 331| return 1;
# 332| }
Error: GCC_ANALYZER_WARNING (CWE-476): [#def7]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:335:21: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘groups’
# 333|
# 334| groups = realloc(groups, sizeof(*groups));
# 335|-> groups[0].title = strdup(title);
# 336| groups[0].facility = line;
# 337| numGroups = 1;
Error: CLANG_WARNING: [#def8]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:343:13: warning[unix.Malloc]: Potential leak of memory pointed to by 'line'
# 341| if (*line == '/') {
# 342| fprintf(stderr, _("path %s unexpected in %s\n"), line, path);
# 343|-> return 1;
# 344| }
# 345|
Error: GCC_ANALYZER_WARNING (CWE-401): [#def9]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:351:13: warning[-Wanalyzer-malloc-leak]: leak of ‘<unknown>’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:351:29: note: in expansion of macro ‘_’
# 349| line = parseLine(&buf);
# 350| if (!line || !*line) {
# 351|-> fprintf(stderr, _("missing path for follower %s in %s\n"), line, path);
# 352| return 1;
# 353| }
Error: CLANG_WARNING: [#def10]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:351:13: warning[unix.Malloc]: Potential leak of memory pointed to by 'groups'
# 349| line = parseLine(&buf);
# 350| if (!line || !*line) {
# 351|-> fprintf(stderr, _("missing path for follower %s in %s\n"), line, path);
# 352| return 1;
# 353| }
Error: CLANG_WARNING: [#def11]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:352:13: warning[unix.Malloc]: Potential leak of memory pointed to by 'line'
# 350| if (!line || !*line) {
# 351| fprintf(stderr, _("missing path for follower %s in %s\n"), line, path);
# 352|-> return 1;
# 353| }
# 354|
Error: CLANG_WARNING: [#def12]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:361:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'groups'
# 359|
# 360| if (!line) {
# 361|-> fprintf(stderr, _("unexpected end of file in %s\n"), path);
# 362| return 1;
# 363| }
Error: CLANG_WARNING: [#def13]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:366:12: warning[unix.Malloc]: Potential leak of memory pointed to by 'line'
# 364|
# 365| line = parseLine(&buf);
# 366|-> while (line && *line) {
# 367| set->alts = realloc(set->alts, (set->numAlts + 1) * sizeof(*set->alts));
# 368|
Error: CLANG_WARNING: [#def14]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:410:13: warning[unix.Malloc]: Potential leak of memory pointed to by 'line'
# 408| fprintf(stderr, _("numeric priority expected in %s\n"), path);
# 409| fprintf(stderr, _("unexpected line in %s: %s\n"), path, line);
# 410|-> return 1;
# 411| }
# 412| if (end) {
Error: CLANG_WARNING: [#def15]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:446:22: warning[unix.Malloc]: Potential leak of memory pointed to by 'line'
# 444| while (line) {
# 445| line = parseLine(&buf);
# 446|-> if (line && *line) {
# 447| fprintf(stderr, _("unexpected line in %s: %s\n"), path, line);
# 448| return 1;
Error: CLANG_WARNING: [#def16]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:448:13: warning[unix.Malloc]: Potential leak of memory pointed to by 'line'
# 446| if (line && *line) {
# 447| fprintf(stderr, _("unexpected line in %s: %s\n"), path, line);
# 448|-> return 1;
# 449| }
# 450| }
Error: GCC_ANALYZER_WARNING (CWE-688): [#def17]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘fillTemplateFrom’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:729:5: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘template.followers’ where non-null expected
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘fillTemplateFrom’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘fillTemplateFrom’
<built-in>: note: argument 1 of ‘__builtin_memcpy’ must be non-null
# 727| template->numFollowers = source.numFollowers;
# 728| template->followers = malloc(source.numFollowers * sizeof(struct linkSet));
# 729|-> memcpy(template->followers, source.followers,
# 730| source.numFollowers * sizeof(struct linkSet));
# 731| }
Error: GCC_ANALYZER_WARNING (CWE-401): [#def18]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘addFollowerToAlternative’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:741:29: warning[-Wanalyzer-malloc-leak]: leak of ‘template.followers’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘addFollowerToAlternative’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘addFollowerToAlternative’
# 739| }
# 740| if (i == template->numFollowers) {
# 741|-> template->followers =
# 742| realloc(template->followers,
# 743| (template->numFollowers + 1) * sizeof(struct linkSet));
Error: CLANG_WARNING: [#def19]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:780:21: warning[unix.Malloc]: Potential leak of memory pointed to by 'newLinks'
# 778| if (strcmp(set->alts[k].followers[i].facility,
# 779| template.followers[j].facility)) {
# 780|-> fprintf(
# 781| stderr, _("link %s incorrect for follower %s (%s %s)\n"),
# 782| set->alts[k].followers[i].facility,
Error: CLANG_WARNING: [#def20]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1242:20: warning[unix.Malloc]: Potential leak of memory pointed to by 'set.alts'
# 1240|
# 1241| if (readConfig(&set, ent->d_name, altDir, stateDir, flags))
# 1242|-> return 2;
# 1243|
# 1244| printf("%-*s\t%s\t%s\n", max_name, ent->d_name,
Error: CLANG_WARNING: [#def21]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1248:5: warning[unix.Malloc]: Potential leak of memory pointed to by 'set.currentLink'
# 1246| }
# 1247|
# 1248|-> closedir(dir);
# 1249|
# 1250| return 0;
Error: GCC_ANALYZER_WARNING (CWE-401): [#def22]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘main’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1311:31: warning[-Wanalyzer-malloc-leak]: leak of ‘newAlt.initscript’
# 1309| if (!*nextArg)
# 1310| usage(2);
# 1311|-> newAlt.initscript = strdup(*nextArg);
# 1312| nextArg++;
# 1313| } else if (!strcmp(*nextArg, "--family")) {
Error: GCC_ANALYZER_WARNING (CWE-401): [#def23]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1320:27: warning[-Wanalyzer-malloc-leak]: leak of ‘newAlt.family’
# 1318| if (!*nextArg)
# 1319| usage(2);
# 1320|-> newAlt.family = strdup(*nextArg);
# 1321|
# 1322| if (strchr(newAlt.family, '@')) {
Error: GCC_ANALYZER_WARNING (CWE-688): [#def24]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1384:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘altDir’ where non-null expected
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:25: included_from: Included from here.
/usr/include/sys/stat.h:205:12: note: argument 1 of ‘stat’ must be non-null
# 1382| }
# 1383|
# 1384|-> if (stat(altDir, &sb) || !S_ISDIR(sb.st_mode) || access(altDir, F_OK)) {
# 1385| fprintf(stderr, _("altdir %s invalid\n"), altDir);
# 1386| return (2);
Error: CLANG_WARNING: [#def25]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1385:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'stateDir'
# 1383|
# 1384| if (stat(altDir, &sb) || !S_ISDIR(sb.st_mode) || access(altDir, F_OK)) {
# 1385|-> fprintf(stderr, _("altdir %s invalid\n"), altDir);
# 1386| return (2);
# 1387| }
Error: CPPCHECK_WARNING (CWE-401): [#def26]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1386: error[memleak]: Memory leak: newAlt.family
# 1384| if (stat(altDir, &sb) || !S_ISDIR(sb.st_mode) || access(altDir, F_OK)) {
# 1385| fprintf(stderr, _("altdir %s invalid\n"), altDir);
# 1386|-> return (2);
# 1387| }
# 1388|
Error: CPPCHECK_WARNING (CWE-401): [#def27]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1386: error[memleak]: Memory leak: newAlt.initscript
# 1384| if (stat(altDir, &sb) || !S_ISDIR(sb.st_mode) || access(altDir, F_OK)) {
# 1385| fprintf(stderr, _("altdir %s invalid\n"), altDir);
# 1386|-> return (2);
# 1387| }
# 1388|
Error: CLANG_WARNING: [#def28]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1386:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'altDir'
# 1384| if (stat(altDir, &sb) || !S_ISDIR(sb.st_mode) || access(altDir, F_OK)) {
# 1385| fprintf(stderr, _("altdir %s invalid\n"), altDir);
# 1386|-> return (2);
# 1387| }
# 1388|
Error: CLANG_WARNING: [#def29]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1415:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'target'
# 1413| return configService(title, altDir, stateDir, flags);
# 1414| case MODE_SET:
# 1415|-> return setService(title, target, altDir, stateDir, flags);
# 1416| case MODE_REMOVE:
# 1417| return removeService(title, target, altDir, stateDir, flags);
Error: CLANG_WARNING: [#def30]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1417:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'target'
# 1415| return setService(title, target, altDir, stateDir, flags);
# 1416| case MODE_REMOVE:
# 1417|-> return removeService(title, target, altDir, stateDir, flags);
# 1418| case MODE_REMOVE_ALL:
# 1419| return removeAll(title, altDir, stateDir, flags);
Scan Properties
analyzer-version-clang | 18.1.7 |
analyzer-version-cppcheck | 2.14.2 |
analyzer-version-gcc | 14.1.1 |
analyzer-version-gcc-analyzer | 14.1.1 |
analyzer-version-shellcheck | 0.10.0 |
diffbase-analyzer-version-clang | 18.1.7 |
diffbase-analyzer-version-cppcheck | 2.14.2 |
diffbase-analyzer-version-gcc | 14.1.1 |
diffbase-analyzer-version-gcc-analyzer | 14.1.1 |
diffbase-analyzer-version-shellcheck | 0.10.0 |
diffbase-enabled-plugins | clang, cppcheck, gcc, shellcheck |
diffbase-exit-code | 0 |
diffbase-host | ip-172-16-1-183.us-west-2.compute.internal |
diffbase-mock-config | fedora-41-x86_64 |
diffbase-project-name | chkconfig-1.28-1.fc41 |
diffbase-store-results-to | /tmp/tmpwu4z4xt5/chkconfig-1.28-1.fc41.tar.xz |
diffbase-time-created | 2024-07-03 12:13:32 |
diffbase-time-finished | 2024-07-03 12:14:31 |
diffbase-tool | csmock |
diffbase-tool-args | '/usr/bin/csmock' '-r' 'fedora-41-x86_64' '-t' 'cppcheck,gcc,clang,shellcheck' '-o' '/tmp/tmpwu4z4xt5/chkconfig-1.28-1.fc41.tar.xz' '--gcc-analyze' '/tmp/tmpwu4z4xt5/chkconfig-1.28-1.fc41.src.rpm' |
diffbase-tool-version | csmock-3.5.3-1.el9 |
enabled-plugins | clang, cppcheck, gcc, shellcheck |
exit-code | 0 |
host | ip-172-16-1-183.us-west-2.compute.internal |
mock-config | fedora-41-x86_64 |
project-name | chkconfig-1.26-3.fc40 |
store-results-to | /tmp/tmpvu7lxird/chkconfig-1.26-3.fc40.tar.xz |
time-created | 2024-07-03 12:11:31 |
time-finished | 2024-07-03 12:13:03 |
title | Fixed defects |
tool | csmock |
tool-args | '/usr/bin/csmock' '-r' 'fedora-41-x86_64' '-t' 'cppcheck,gcc,clang,shellcheck' '-o' '/tmp/tmpvu7lxird/chkconfig-1.26-3.fc40.tar.xz' '--gcc-analyze' '/tmp/tmpvu7lxird/chkconfig-1.26-3.fc40.src.rpm' |
tool-version | csmock-3.5.3-1.el9 |