Task #311 - chkconfig-1.28-1.fc41/scan-results.err
back to task #311download
Error: CPPCHECK_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches. Error: GCC_ANALYZER_WARNING (CWE-476): chkconfig-1.28-build/chkconfig-1.28/alternatives.c: scope_hint: In function ‘setupLinkSet’ chkconfig-1.28-build/chkconfig-1.28/alternatives.c:240:19: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘set’ chkconfig-1.28-build/chkconfig-1.28/alternatives.c: scope_hint: In function ‘setupLinkSet’ # 238| if (!*nextArg || **nextArg != '/') # 239| usage(2); # 240|-> set->facility = normalize_path_alloc(*nextArg); # 241| nextArg++; # 242| Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:354: error[memleakOnRealloc]: Common realloc mistake: 'groups' nulled but not freed upon failure # 352| } # 353| # 354|-> groups = realloc(groups, sizeof(*groups)); # 355| groups[0].title = strdup(title); # 356| groups[0].facility = strsteal(&line); Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:367: error[memleakOnRealloc]: Common realloc mistake: 'groups' nulled but not freed upon failure # 365| } # 366| # 367|-> groups = realloc(groups, sizeof(*groups) * (numGroups + 1)); # 368| groups[numGroups].title = strsteal(&line); # 369| Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c:432:44: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull' # 430| } # 431| # 432|-> set->alts[set->numAlts].priority = strtol(ptr, &end, 0); # 433| # 434| if (!end || (end == ptr)) { Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c:482:50: warning[core.NullDereference]: Dereference of null pointer # 480| } # 481| # 482|-> leader_path = alloca(strlen(altDir) + strlen(set->alts[0].leader.title) + 2); # 483| sprintf(leader_path, "%s/%s", altDir, set->alts[0].leader.title); # 484| Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c: scope_hint: In function ‘makeLinks’ chkconfig-1.28-build/chkconfig-1.28/alternatives.c:596:13: warning[-Wunused-result]: ignoring return value of ‘readlink’ declared with attribute ‘warn_unused_result’ # 596 | readlink(l->facility, buf, sizeof(buf)-1); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 594| } else { # 595| memset(buf, 0, sizeof(buf)); # 596|-> readlink(l->facility, buf, sizeof(buf)-1); # 597| # 598| if(!streq(sl, buf)) { Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:614:9: warning[-Wunused-result]: ignoring return value of ‘readlink’ declared with attribute ‘warn_unused_result’ # 614 | readlink(sl, buf, sizeof(buf)-1); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 612| } else { # 613| memset(buf, 0, sizeof(buf)); # 614|-> readlink(sl, buf, sizeof(buf)-1); # 615| # 616| if(!streq(l->target, buf)) { Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c: scope_hint: In function ‘writeState’ chkconfig-1.28-build/chkconfig-1.28/alternatives.c:716:17: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 716 | asprintf(&path, "/bin/systemctl -q is-enabled %s.service || " # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 717 | "/bin/systemctl -q preset %s.service", # | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 718 | alt->initscript, alt->initscript); # | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 714| if (alt->initscript) { # 715| if (isSystemd(alt->initscript)) { # 716|-> asprintf(&path, "/bin/systemctl -q is-enabled %s.service || " # 717| "/bin/systemctl -q preset %s.service", # 718| alt->initscript, alt->initscript); Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:721:17: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ # 721 | system(path); # | ^~~~~~~~~~~~ # 719| if (FL_VERBOSE(flags)) # 720| printf(_("running %s\n"), path); # 721|-> system(path); # 722| free(path); # 723| } else { Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:724:17: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 724 | asprintf(&path, "/sbin/chkconfig --add %s", alt->initscript); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 722| free(path); # 723| } else { # 724|-> asprintf(&path, "/sbin/chkconfig --add %s", alt->initscript); # 725| if (FL_VERBOSE(flags)) # 726| printf(_("running %s\n"), path); Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:727:17: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ # 727 | system(path); # | ^~~~~~~~~~~~ # 725| if (FL_VERBOSE(flags)) # 726| printf(_("running %s\n"), path); # 727|-> system(path); # 728| free(path); # 729| } Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:735:21: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 735 | asprintf(&path, "/bin/systemctl -q disable %s.service", # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 736 | tmpalt->initscript); # | ~~~~~~~~~~~~~~~~~~~ # 733| if (tmpalt != alt && tmpalt->initscript) { # 734| if (isSystemd(tmpalt->initscript)) { # 735|-> asprintf(&path, "/bin/systemctl -q disable %s.service", # 736| tmpalt->initscript); # 737| if (FL_VERBOSE(flags)) Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:739:21: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ # 739 | system(path); # | ^~~~~~~~~~~~ # 737| if (FL_VERBOSE(flags)) # 738| printf(_("running %s\n"), path); # 739|-> system(path); # 740| free(path); # 741| } else { Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:742:21: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 742 | asprintf(&path, "/sbin/chkconfig --del %s", # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 743 | tmpalt->initscript); # | ~~~~~~~~~~~~~~~~~~~ # 740| free(path); # 741| } else { # 742|-> asprintf(&path, "/sbin/chkconfig --del %s", # 743| tmpalt->initscript); # 744| if (FL_VERBOSE(flags)) Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c:746:21: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ # 746 | system(path); # | ^~~~~~~~~~~~ # 744| if (FL_VERBOSE(flags)) # 745| printf(_("running %s\n"), path); # 746|-> system(path); # 747| free(path); # 748| } Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c:995:20: warning[unix.Malloc]: Potential leak of memory pointed to by 'set.alts' # 993| # 994| if (matchFollowers(&set, template)) # 995|-> return 2; # 996| } else { # 997| set.alts = realloc(set.alts, sizeof(*set.alts) * (set.numAlts + 1)); Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/alternatives.c: scope_hint: In function ‘configService’ chkconfig-1.28-build/chkconfig-1.28/alternatives.c:1083:17: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 1083 | asprintf(&nicer, "%s (%s)", set.alts[i].family, # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 1084 | set.alts[i].leader.target); # | ~~~~~~~~~~~~~~~~~~~~~~~~~~ # 1081| for (i = 0; i < set.numAlts; i++) { # 1082| if (set.alts[i].family) # 1083|-> asprintf(&nicer, "%s (%s)", set.alts[i].family, # 1084| set.alts[i].leader.target); # 1085| printf("%c%c %-4d %s\n", i == set.best ? '*' : ' ', Error: GCC_ANALYZER_WARNING (CWE-688): chkconfig-1.28-build/chkconfig-1.28/alternatives.c: scope_hint: In function ‘main’ chkconfig-1.28-build/chkconfig-1.28/alternatives.c:1364:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘newAlt.family’ where non-null expected <built-in>: note: argument 1 of ‘__builtin_strchr’ must be non-null # 1362| newAlt.family = strdup(*nextArg); # 1363| # 1364|-> if (strchr(newAlt.family, '@')) { # 1365| printf(_("--family can't contain the symbol '@'\n")); # 1366| usage(2); Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c:1451:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title' # 1449| return removeFollower(title, target, followerTitle, altDir, stateDir, flags); # 1450| case MODE_DISPLAY: # 1451|-> return displayService(title, altDir, stateDir, flags); # 1452| case MODE_AUTO: # 1453| return autoService(title, altDir, stateDir, flags); Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c:1453:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title' # 1451| return displayService(title, altDir, stateDir, flags); # 1452| case MODE_AUTO: # 1453|-> return autoService(title, altDir, stateDir, flags); # 1454| case MODE_CONFIG: # 1455| return configService(title, altDir, stateDir, flags); Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c:1455:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title' # 1453| return autoService(title, altDir, stateDir, flags); # 1454| case MODE_CONFIG: # 1455|-> return configService(title, altDir, stateDir, flags); # 1456| case MODE_SET: # 1457| return setService(title, target, altDir, stateDir, flags); Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c:1457:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title' # 1455| return configService(title, altDir, stateDir, flags); # 1456| case MODE_SET: # 1457|-> return setService(title, target, altDir, stateDir, flags); # 1458| case MODE_REMOVE: # 1459| return removeService(title, target, altDir, stateDir, flags); Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c:1459:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title' # 1457| return setService(title, target, altDir, stateDir, flags); # 1458| case MODE_REMOVE: # 1459|-> return removeService(title, target, altDir, stateDir, flags); # 1460| case MODE_REMOVE_ALL: # 1461| return removeAll(title, altDir, stateDir, flags); Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/alternatives.c:1461:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title' # 1459| return removeService(title, target, altDir, stateDir, flags); # 1460| case MODE_REMOVE_ALL: # 1461|-> return removeAll(title, altDir, stateDir, flags); # 1462| case MODE_FOLLOWER: # 1463| usage(2); Error: CPPCHECK_WARNING: chkconfig-1.28-build/chkconfig-1.28/chkconfig.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches. Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/chkconfig.c: scope_hint: In function ‘reloadSystemd’ chkconfig-1.28-build/chkconfig-1.28/chkconfig.c:106:9: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ # 106 | system("systemctl daemon-reload > /dev/null 2>&1"); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 104| static void reloadSystemd(void) { # 105| if (systemdActive()) # 106|-> system("systemctl daemon-reload > /dev/null 2>&1"); # 107| } # 108| Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/chkconfig.c:373:10: warning[deadcode.DeadStores]: Although the value stored to 'rc' is used in the enclosing expression, the value is never actually read from 'rc' # 371| int thisLevelAdded, thisLevelOn; # 372| # 373|-> if ((rc = readServiceDifferences(name, srvtype, &s, &o, 0))) { # 374| return 0; # 375| } Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/chkconfig.c:572: error[memleakOnRealloc]: Common realloc mistake: 's' nulled but not freed upon failure # 570| if (numServices == numServicesAlloced) { # 571| numServicesAlloced += 10; # 572|-> s = realloc(s, numServicesAlloced * sizeof(*s)); # 573| } # 574| if (readXinetdServiceInfo(ent->d_name, s + numServices) != -1) Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/chkconfig.c:580:38: warning[unix.Malloc]: Potential leak of memory pointed to by 'tmp' # 578| qsort(s, numServices, sizeof(*s), serviceNameCmp); # 579| t = s; # 580|-> for (i = 0; i < numServices; i++, s++) { # 581| char *tmp = malloc(strlen(s->name) + 5); # 582| sprintf(tmp, "%s:", s->name); Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/chkconfig.c: scope_hint: In function ‘setService’ chkconfig-1.28-build/chkconfig-1.28/chkconfig.c:654:9: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ # 654 | system("/sbin/service xinetd reload >/dev/null 2>&1"); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 652| return 1; # 653| } # 654|-> system("/sbin/service xinetd reload >/dev/null 2>&1"); # 655| } # 656| Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/chkconfig.c: scope_hint: In function ‘forwardSystemd’ chkconfig-1.28-build/chkconfig-1.28/chkconfig.c:673:13: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 673 | asprintf(&p, "%s.service", name); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 671| # 672| if (!socket) # 673|-> asprintf(&p, "%s.service", name); # 674| else # 675| asprintf(&p, "%s.socket", name); Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/chkconfig.c:675:13: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 675 | asprintf(&p, "%s.socket", name); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 673| asprintf(&p, "%s.service", name); # 674| else # 675|-> asprintf(&p, "%s.socket", name); # 676| # 677| fprintf(stderr, _("Note: Forwarding request to 'systemctl %s %s'.\n"), Error: CPPCHECK_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches. Error: COMPILER_WARNING (CWE-477): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘selinux_restore’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:47:5: warning[-Wdeprecated-declarations]: ‘security_context_t’ is deprecated # 45| struct selabel_handle *hnd = NULL; # 46| struct stat buf; # 47|-> security_context_t newcon = NULL; # 48| int r = -1; # 49| Error: GCC_ANALYZER_WARNING (CWE-688): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘readDescription’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:143:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘desc’ where non-null expected <built-in>: note: argument 1 of ‘__builtin_strncpy’ must be non-null # 141| { # 142| char *desc = malloc(end - start + 1); # 143|-> strncpy(desc, start, end - start); # 144| desc[end - start] = '\0'; # 145| Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:146:9: warning[deadcode.DeadStores]: Value stored to 'start' is never read # 144| desc[end - start] = '\0'; # 145| # 146|-> start = next; # 147| # 148| while (desc[strlen(desc) - 1] == '\\') { Error: GCC_ANALYZER_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:154:16: warning[-Wanalyzer-malloc-leak]: leak of ‘desc’ # 152| while (isspace(*start) && start < bufstop) # 153| start++; # 154|-> if (start == bufstop || *start != '#') { # 155| return 1; # 156| } Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:155:24: warning[unix.Malloc]: Potential leak of memory pointed to by 'desc' # 153| start++; # 154| if (start == bufstop || *start != '#') { # 155|-> return 1; # 156| } # 157| Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:173: error[memleakOnRealloc]: Common realloc mistake: 'desc' nulled but not freed upon failure # 171| # 172| i = strlen(desc); # 173|-> desc = realloc(desc, i + end - start + 1); # 174| strncat(desc, start, end - start); # 175| desc[i + end - start] = '\0'; Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:177:13: warning[deadcode.DeadStores]: Value stored to 'start' is never read # 175| desc[i + end - start] = '\0'; # 176| # 177|-> start = next; # 178| } # 179| Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘readXinetdServiceInfo’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:226:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 226 | asprintf(&filename, XINETDDIR "/%s", name); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 224| char *eng_desc = NULL, *start; # 225| # 226|-> asprintf(&filename, XINETDDIR "/%s", name); # 227| # 228| if ((fd = open(filename, O_RDONLY)) < 0) Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:349: error[memleakOnRealloc]: Common realloc mistake: 'servs' nulled but not freed upon failure # 347| if (!S_ISREG(sb.st_mode)) # 348| continue; # 349|-> servs = realloc(servs, (numservs + 1) * sizeof(struct service)); # 350| if (!readServiceInfo(ent->d_name, TYPE_INIT_D, servs + numservs, 0)) # 351| numservs++; Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘readServiceInfo’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:367:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 367 | asprintf(&filename, RUNLEVELS "/init.d/%s", name); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 365| goto try_xinetd; # 366| # 367|-> asprintf(&filename, RUNLEVELS "/init.d/%s", name); # 368| # 369| if ((fd = open(filename, O_RDONLY)) < 0) Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:377:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 377 | asprintf(&filename, RUNLEVELS "/chkconfig.d/%s", name); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 375| return parseret; # 376| # 377|-> asprintf(&filename, RUNLEVELS "/chkconfig.d/%s", name); # 378| if ((fd = open(filename, O_RDONLY)) >= 0) { # 379| parseret = parseServiceInfo(fd, name, &serv_overrides, honorHide, 1); Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘readServiceDifferences’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:428:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 428 | asprintf(&filename, RUNLEVELS "/init.d/%s", name); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 426| goto try_xinetd; # 427| # 428|-> asprintf(&filename, RUNLEVELS "/init.d/%s", name); # 429| # 430| if ((fd = open(filename, O_RDONLY)) < 0) { Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:440:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 440 | asprintf(&filename, RUNLEVELS "/chkconfig.d/%s", name); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 438| } # 439| # 440|-> asprintf(&filename, RUNLEVELS "/chkconfig.d/%s", name); # 441| if ((fd = open(filename, O_RDONLY)) >= 0) { # 442| parseret = parseServiceInfo(fd, name, &serv_overrides, honorHide, 1); Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:481: error[memleakOnRealloc]: Common realloc mistake: 'deps' nulled but not freed upon failure # 479| } # 480| numdeps++; # 481|-> deps = realloc(deps, (numdeps + 1) * sizeof(struct dep)); # 482| deps[numdeps - 1].name = strdup(pos); # 483| deps[numdeps - 1].handled = 0; Error: GCC_ANALYZER_WARNING (CWE-415): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘parseDeps’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:481:16: warning[-Wanalyzer-double-free]: double-‘free’ of ‘deps’ # 479| } # 480| numdeps++; # 481|-> deps = realloc(deps, (numdeps + 1) * sizeof(struct dep)); # 482| deps[numdeps - 1].name = strdup(pos); # 483| deps[numdeps - 1].handled = 0; Error: GCC_ANALYZER_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:482:13: warning[-Wanalyzer-malloc-leak]: leak of ‘<unknown>’ # 480| numdeps++; # 481| deps = realloc(deps, (numdeps + 1) * sizeof(struct dep)); # 482|-> deps[numdeps - 1].name = strdup(pos); # 483| deps[numdeps - 1].handled = 0; # 484| memset(&deps[numdeps], '\0', sizeof(struct dep)); Error: GCC_ANALYZER_WARNING (CWE-476): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:482:32: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘deps’ # 480| numdeps++; # 481| deps = realloc(deps, (numdeps + 1) * sizeof(struct dep)); # 482|-> deps[numdeps - 1].name = strdup(pos); # 483| deps[numdeps - 1].handled = 0; # 484| memset(&deps[numdeps], '\0', sizeof(struct dep)); Error: GCC_ANALYZER_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘parseServiceInfo’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:697:31: warning[-Wanalyzer-malloc-leak]: leak of ‘<unknown>’ # 695| } # 696| numdeps++; # 697|-> serv.provides = # 698| realloc(serv.provides, (numdeps + 1) * sizeof(char *)); # 699| serv.provides[numdeps - 1] = strdup(start); Error: GCC_ANALYZER_WARNING (CWE-476): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:699:44: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘0’ # 697| serv.provides = # 698| realloc(serv.provides, (numdeps + 1) * sizeof(char *)); # 699|-> serv.provides[numdeps - 1] = strdup(start); # 700| serv.provides[numdeps] = NULL; # 701| if (!t || t >= end) Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:722: error[memleak]: Memory leak: serv.desc # 720| ((serv.levels == -1) || !serv.desc || # 721| (!serv.isLSB && (serv.sPriority == -1 || serv.kPriority == 100)))) { # 722|-> return 1; # 723| } # 724| Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:722:16: warning[unix.Malloc]: Potential leak of memory pointed to by 'serv.desc' # 720| ((serv.levels == -1) || !serv.desc || # 721| (!serv.isLSB && (serv.sPriority == -1 || serv.kPriority == 100)))) { # 722|-> return 1; # 723| } # 724| Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:722:16: warning[unix.Malloc]: Potential leak of memory pointed to by 'serv.provides' # 720| ((serv.levels == -1) || !serv.desc || # 721| (!serv.isLSB && (serv.sPriority == -1 || serv.kPriority == 100)))) { # 722|-> return 1; # 723| } # 724| Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:722:16: warning[unix.Malloc]: Potential leak of memory pointed to by 'serv.softStartDeps' # 720| ((serv.levels == -1) || !serv.desc || # 721| (!serv.isLSB && (serv.sPriority == -1 || serv.kPriority == 100)))) { # 722|-> return 1; # 723| } # 724| Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:722:16: warning[unix.Malloc]: Potential leak of memory pointed to by 'serv.softStopDeps' # 720| ((serv.levels == -1) || !serv.desc || # 721| (!serv.isLSB && (serv.sPriority == -1 || serv.kPriority == 100)))) { # 722|-> return 1; # 723| } # 724| Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:722:16: warning[unix.Malloc]: Potential leak of memory pointed to by 'serv.startDeps' # 720| ((serv.levels == -1) || !serv.desc || # 721| (!serv.isLSB && (serv.sPriority == -1 || serv.kPriority == 100)))) { # 722|-> return 1; # 723| } # 724| Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:722:16: warning[unix.Malloc]: Potential leak of memory pointed to by 'serv.stopDeps' # 720| ((serv.levels == -1) || !serv.desc || # 721| (!serv.isLSB && (serv.sPriority == -1 || serv.kPriority == 100)))) { # 722|-> return 1; # 723| } # 724| Error: GCC_ANALYZER_WARNING (CWE-476): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:728:26: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘serv.provides’ # 726| if (!serv.provides) { # 727| serv.provides = malloc(2 * sizeof(char *)); # 728|-> serv.provides[0] = strdup(name); # 729| serv.provides[1] = NULL; # 730| } Error: GCC_ANALYZER_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘setXinetdService’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:858:16: warning[-Wanalyzer-malloc-leak]: leak of ‘buf’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:17: included_from: Included from here. # 856| snprintf(oldfname, 100, "%s/%s", XINETDDIR, s.name); # 857| if ((oldfd = open(oldfname, O_RDONLY)) == -1) { # 858|-> return -1; # 859| } # 860| fstat(oldfd, &sb); Error: GCC_ANALYZER_WARNING (CWE-688): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:879:15: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘buf’ where non-null expected <built-in>: note: argument 1 of ‘__builtin_strchr’ must be non-null # 877| while (buf) { # 878| tmp = buf; # 879|-> ptr = strchr(buf, '\n'); # 880| if (ptr) { # 881| *ptr = '\0'; Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘setXinetdService’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:887:13: warning[-Wunused-result]: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ # 887 | write(newfd, tmp, strlen(tmp)); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 885| buf++; # 886| if (strncmp(buf, "disable", 7) && strlen(buf)) { # 887|-> write(newfd, tmp, strlen(tmp)); # 888| write(newfd, "\n", 1); # 889| if (buf[0] == '{') { Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:888:13: warning[-Wunused-result]: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ # 888 | write(newfd, "\n", 1); # | ^~~~~~~~~~~~~~~~~~~~~ # 886| if (strncmp(buf, "disable", 7) && strlen(buf)) { # 887| write(newfd, tmp, strlen(tmp)); # 888|-> write(newfd, "\n", 1); # 889| if (buf[0] == '{') { # 890| snprintf(tmpstr, 50, "\tdisable\t= %s", on ? "no" : "yes"); Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:891:17: warning[-Wunused-result]: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ # 891 | write(newfd, tmpstr, strlen(tmpstr)); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 889| if (buf[0] == '{') { # 890| snprintf(tmpstr, 50, "\tdisable\t= %s", on ? "no" : "yes"); # 891|-> write(newfd, tmpstr, strlen(tmpstr)); # 892| write(newfd, "\n", 1); # 893| } Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:892:17: warning[-Wunused-result]: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ # 892 | write(newfd, "\n", 1); # | ^~~~~~~~~~~~~~~~~~~~~ # 890| snprintf(tmpstr, 50, "\tdisable\t= %s", on ? "no" : "yes"); # 891| write(newfd, tmpstr, strlen(tmpstr)); # 892|-> write(newfd, "\n", 1); # 893| } # 894| } Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘isOverriddenBySystemd’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:960:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 960 | asprintf(&p, SYSTEMD_SERVICE_PATH "/%s.service", service); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 958| int rc = 0; # 959| # 960|-> asprintf(&p, SYSTEMD_SERVICE_PATH "/%s.service", service); # 961| # 962| if (access(p, F_OK) >= 0) { Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:967:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 967 | asprintf(&p, SYSTEMD_LOCAL_SERVICE_PATH "/%s.service", service); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 965| } # 966| free(p); # 967|-> asprintf(&p, SYSTEMD_LOCAL_SERVICE_PATH "/%s.service", service); # 968| if (access(p, F_OK) >= 0) { # 969| rc = 1; Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘isSocketActivatedBySystemd’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:981:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 981 | asprintf(&p, SYSTEMD_SERVICE_PATH "/%s@.service", service); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 979| int rc = 0; # 980| # 981|-> asprintf(&p, SYSTEMD_SERVICE_PATH "/%s@.service", service); # 982| asprintf(&s, SYSTEMD_SERVICE_PATH "/%s.socket", service); # 983| Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:982:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 982 | asprintf(&s, SYSTEMD_SERVICE_PATH "/%s.socket", service); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 980| # 981| asprintf(&p, SYSTEMD_SERVICE_PATH "/%s@.service", service); # 982|-> asprintf(&s, SYSTEMD_SERVICE_PATH "/%s.socket", service); # 983| # 984| if (access(p, F_OK) >= 0 && access(s, F_OK) >= 0) { Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:991:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 991 | asprintf(&p, SYSTEMD_LOCAL_SERVICE_PATH "/%s@.service", service); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 989| free(s); # 990| # 991|-> asprintf(&p, SYSTEMD_LOCAL_SERVICE_PATH "/%s@.service", service); # 992| asprintf(&s, SYSTEMD_LOCAL_SERVICE_PATH "/%s.socket", service); # 993| if (access(p, F_OK) >= 0 && access(s, F_OK) >= 0) { Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c:992:5: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 992 | asprintf(&s, SYSTEMD_LOCAL_SERVICE_PATH "/%s.socket", service); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 990| # 991| asprintf(&p, SYSTEMD_LOCAL_SERVICE_PATH "/%s@.service", service); # 992|-> asprintf(&s, SYSTEMD_LOCAL_SERVICE_PATH "/%s.socket", service); # 993| if (access(p, F_OK) >= 0 && access(s, F_OK) >= 0) { # 994| rc = 1; Error: GCC_ANALYZER_WARNING (CWE-415): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘runlevelsToTargets’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:1110:32: warning[-Wanalyzer-double-free]: double-‘free’ of ‘ret’ # 1108| # 1109| if (!found) { # 1110|-> tmp = (char **)realloc(ret, sizeof(char *) * (n_ret + 1)); # 1111| if (tmp == NULL) { # 1112| r = -ENOMEM; Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:1112:26: warning[unix.Malloc]: Potential leak of memory pointed to by 't' # 1110| tmp = (char **)realloc(ret, sizeof(char *) * (n_ret + 1)); # 1111| if (tmp == NULL) { # 1112|-> r = -ENOMEM; # 1113| goto fail; # 1114| } Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘serviceNameToUnit’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:1158:9: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 1158 | asprintf(&ret, "%s.service", service); # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 1156| ret = strdup("time-sync.target"); # 1157| } else { # 1158|-> asprintf(&ret, "%s.service", service); # 1159| } # 1160| Error: GCC_ANALYZER_WARNING (CWE-688): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘unitIsSimilarlyConfigure’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:1273:5: warning[-Wanalyzer-null-argument]: use of NULL ‘deps’ where non-null expected chkconfig-1.28-build/chkconfig-1.28/leveldb.c:28: included_from: Included from here. /usr/include/stdlib.h:970:13: note: argument 1 of ‘qsort’ must be non-null # 1271| return 0; # 1272| # 1273|-> qsort(deps, n_deps, sizeof(char *), cmpstringp); # 1274| # 1275| r = systemdIsSimilarlyConfiguredDeps(star, n_star, deps, n_deps); Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/leveldb.c:1273:5: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull' # 1271| return 0; # 1272| # 1273|-> qsort(deps, n_deps, sizeof(char *), cmpstringp); # 1274| # 1275| r = systemdIsSimilarlyConfiguredDeps(star, n_star, deps, n_deps); Error: GCC_ANALYZER_WARNING (CWE-688): chkconfig-1.28-build/chkconfig-1.28/leveldb.c: scope_hint: In function ‘checkSystemdDependencies’ chkconfig-1.28-build/chkconfig-1.28/leveldb.c:1298:5: warning[-Wanalyzer-null-argument]: use of NULL ‘star’ where non-null expected /usr/include/stdlib.h:970:13: note: argument 1 of ‘qsort’ must be non-null # 1296| return; # 1297| # 1298|-> qsort(star, n_star, sizeof(char *), cmpstringp); # 1299| # 1300| if (s->startDeps) { Error: CPPCHECK_WARNING: chkconfig-1.28-build/chkconfig-1.28/ntsysv.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches. Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/ntsysv.c: scope_hint: In function ‘servicesWindow’ chkconfig-1.28-build/chkconfig-1.28/ntsysv.c:166:13: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ # 166 | asprintf(&cmd, "/usr/bin/systemctl %s %s >/dev/null 2>&1", # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 167 | en ? "enable" : "disable", services[i].name); # | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 164| else # 165| continue; # 166|-> asprintf(&cmd, "/usr/bin/systemctl %s %s >/dev/null 2>&1", # 167| en ? "enable" : "disable", services[i].name); # 168| if (cmd == NULL) Error: COMPILER_WARNING (CWE-252): chkconfig-1.28-build/chkconfig-1.28/ntsysv.c:170:13: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ # 170 | system(cmd); # | ^~~~~~~~~~~ # 168| if (cmd == NULL) # 169| return 1; # 170|-> system(cmd); # 171| free(cmd); # 172| } else { Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/ntsysv.c:319:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'services' # 317| # 318| if (!(dir = opendir(RUNLEVELS "/init.d"))) { # 319|-> fprintf(stderr, "failed to open " RUNLEVELS "/init.d: %s\n", # 320| strerror(errno)); # 321| return 2; Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/ntsysv.c:321: error[memleak]: Memory leak: services # 319| fprintf(stderr, "failed to open " RUNLEVELS "/init.d: %s\n", # 320| strerror(errno)); # 321|-> return 2; # 322| } # 323| Error: GCC_ANALYZER_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/ntsysv.c: scope_hint: In function ‘getServices’ chkconfig-1.28-build/chkconfig-1.28/ntsysv.c:321:16: warning[-Wanalyzer-malloc-leak]: leak of ‘services’ # 319| fprintf(stderr, "failed to open " RUNLEVELS "/init.d: %s\n", # 320| strerror(errno)); # 321|-> return 2; # 322| } # 323| Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/ntsysv.c:342: error[memleakOnRealloc]: Common realloc mistake: 'services' nulled but not freed upon failure # 340| if (numServices == numServicesAlloced) { # 341| numServicesAlloced += 10; # 342|-> services = # 343| realloc(services, numServicesAlloced * sizeof(*services)); # 344| } Error: CPPCHECK_WARNING (CWE-401): chkconfig-1.28-build/chkconfig-1.28/ntsysv.c:393: error[memleakOnRealloc]: Common realloc mistake: 'services' nulled but not freed upon failure # 391| if (numServices == numServicesAlloced) { # 392| numServicesAlloced += 10; # 393|-> services = # 394| realloc(services, numServicesAlloced * sizeof(*services)); # 395| } Error: CLANG_WARNING: chkconfig-1.28-build/chkconfig-1.28/ntsysv.c:417:5: warning[unix.Malloc]: Use of memory after it is freed # 415| getSystemdServices(&services, &numServices); # 416| # 417|-> qsort(services, numServices, sizeof(*services), serviceNameCmp); # 418| # 419| *servicesPtr = services;