chkconfig-1.26-3.fc40

List of Defects

Error: CPPCHECK_WARNING: [#def1]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

Error: GCC_ANALYZER_WARNING (CWE-476): [#def2]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘setupLinkSet’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:229:19: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘set’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘setupLinkSet’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘setupLinkSet’
#  227|       if (!*nextArg || **nextArg != '/')
#  228|           usage(2);
#  229|->     set->facility = strdup(normalize_path(*nextArg));
#  230|       nextArg++;
#  231|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def3]
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): [#def4]
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): [#def5]
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): [#def6]
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: [#def7]
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: [#def8]
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: CPPCHECK_WARNING (CWE-401): [#def9]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:334: error[memleakOnRealloc]: Common realloc mistake: 'groups' nulled but not freed upon failure
#  332|       }
#  333|   
#  334|->     groups = realloc(groups, sizeof(*groups));
#  335|       groups[0].title = strdup(title);
#  336|       groups[0].facility = line;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def10]
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: [#def11]
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: CPPCHECK_WARNING (CWE-401): [#def12]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:346: error[memleakOnRealloc]: Common realloc mistake: 'groups' nulled but not freed upon failure
#  344|           }
#  345|   
#  346|->         groups = realloc(groups, sizeof(*groups) * (numGroups + 1));
#  347|           groups[numGroups].title = line;
#  348|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def13]
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: [#def14]
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: [#def15]
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: [#def16]
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: [#def17]
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: [#def18]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:405:44: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
#  403|           }
#  404|   
#  405|->         set->alts[set->numAlts].priority = strtol(line, &end, 0);
#  406|   
#  407|           if (!end || (end == line)) {

Error: CLANG_WARNING: [#def19]
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: [#def20]
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: [#def21]
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: CLANG_WARNING: [#def22]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:452:50: warning[core.NullDereference]: Dereference of null pointer
#  450|       }
#  451|   
#  452|->     leader_path = alloca(strlen(altDir) + strlen(set->alts[0].leader.title) + 2);
#  453|       sprintf(leader_path, "%s/%s", altDir, set->alts[0].leader.title);
#  454|   

Error: COMPILER_WARNING (CWE-252): [#def23]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘makeLinks’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:559:13: warning[-Wunused-result]: ignoring return value of ‘readlink’ declared with attribute ‘warn_unused_result’
#  559 |             readlink(l->facility, buf, sizeof(buf));
#      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  557|           } else {
#  558|               memset(buf, 0, sizeof(buf));
#  559|->             readlink(l->facility, buf, sizeof(buf));
#  560|   
#  561|               if(!streq(sl, buf)) {

Error: COMPILER_WARNING (CWE-252): [#def24]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:577:9: warning[-Wunused-result]: ignoring return value of ‘readlink’ declared with attribute ‘warn_unused_result’
#  577 |         readlink(sl, buf, sizeof(buf));
#      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  575|       } else {
#  576|           memset(buf, 0, sizeof(buf));
#  577|->         readlink(sl, buf, sizeof(buf));
#  578|   
#  579|           if(!streq(l->target, buf)) {

Error: COMPILER_WARNING (CWE-252): [#def25]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘writeState’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:679:17: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’
#  679 |                 asprintf(&path, "/bin/systemctl -q is-enabled %s.service || "
#      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  680 |                                 "/bin/systemctl -q preset %s.service",
#      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  681 |                          alt->initscript, alt->initscript);
#      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  677|           if (alt->initscript) {
#  678|               if (isSystemd(alt->initscript)) {
#  679|->                 asprintf(&path, "/bin/systemctl -q is-enabled %s.service || "
#  680|                                   "/bin/systemctl -q preset %s.service",
#  681|                            alt->initscript, alt->initscript);

Error: COMPILER_WARNING (CWE-252): [#def26]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:684:17: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’
#  684 |                 system(path);
#      |                 ^~~~~~~~~~~~
#  682|                   if (FL_VERBOSE(flags))
#  683|                       printf(_("running %s\n"), path);
#  684|->                 system(path);
#  685|                   free(path);
#  686|               } else {

Error: COMPILER_WARNING (CWE-252): [#def27]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:687:17: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’
#  687 |                 asprintf(&path, "/sbin/chkconfig --add %s", alt->initscript);
#      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  685|                   free(path);
#  686|               } else {
#  687|->                 asprintf(&path, "/sbin/chkconfig --add %s", alt->initscript);
#  688|                   if (FL_VERBOSE(flags))
#  689|                       printf(_("running %s\n"), path);

Error: COMPILER_WARNING (CWE-252): [#def28]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:690:17: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’
#  690 |                 system(path);
#      |                 ^~~~~~~~~~~~
#  688|                   if (FL_VERBOSE(flags))
#  689|                       printf(_("running %s\n"), path);
#  690|->                 system(path);
#  691|                   free(path);
#  692|               }

Error: COMPILER_WARNING (CWE-252): [#def29]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:698:21: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’
#  698 |                     asprintf(&path, "/bin/systemctl -q disable %s.service",
#      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  699 |                              tmpalt->initscript);
#      |                              ~~~~~~~~~~~~~~~~~~~
#  696|               if (tmpalt != alt && tmpalt->initscript) {
#  697|                   if (isSystemd(tmpalt->initscript)) {
#  698|->                     asprintf(&path, "/bin/systemctl -q disable %s.service",
#  699|                                tmpalt->initscript);
#  700|                       if (FL_VERBOSE(flags))

Error: COMPILER_WARNING (CWE-252): [#def30]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:702:21: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’
#  702 |                     system(path);
#      |                     ^~~~~~~~~~~~
#  700|                       if (FL_VERBOSE(flags))
#  701|                           printf(_("running %s\n"), path);
#  702|->                     system(path);
#  703|                       free(path);
#  704|                   } else {

Error: COMPILER_WARNING (CWE-252): [#def31]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:705:21: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’
#  705 |                     asprintf(&path, "/sbin/chkconfig --del %s",
#      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  706 |                              tmpalt->initscript);
#      |                              ~~~~~~~~~~~~~~~~~~~
#  703|                       free(path);
#  704|                   } else {
#  705|->                     asprintf(&path, "/sbin/chkconfig --del %s",
#  706|                                tmpalt->initscript);
#  707|                       if (FL_VERBOSE(flags))

Error: COMPILER_WARNING (CWE-252): [#def32]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:709:21: warning[-Wunused-result]: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’
#  709 |                     system(path);
#      |                     ^~~~~~~~~~~~
#  707|                       if (FL_VERBOSE(flags))
#  708|                           printf(_("running %s\n"), path);
#  709|->                     system(path);
#  710|                       free(path);
#  711|                   }

Error: GCC_ANALYZER_WARNING (CWE-688): [#def33]
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): [#def34]
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: [#def35]
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: [#def36]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:957:20: warning[unix.Malloc]: Potential leak of memory pointed to by 'set.alts'
#  955|   
#  956|           if (matchFollowers(&set, template))
#  957|->             return 2;
#  958|       } else {
#  959|           set.alts = realloc(set.alts, sizeof(*set.alts) * (set.numAlts + 1));

Error: COMPILER_WARNING (CWE-252): [#def37]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c: scope_hint: In function ‘configService’
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1045:17: warning[-Wunused-result]: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’
# 1045 |                 asprintf(&nicer, "%s (%s)", set.alts[i].family,
#      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1046 |                          set.alts[i].leader.target);
#      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1043|           for (i = 0; i < set.numAlts; i++) {
# 1044|               if (set.alts[i].family)
# 1045|->                 asprintf(&nicer, "%s (%s)", set.alts[i].family,
# 1046|                            set.alts[i].leader.target);
# 1047|               printf("%c%c %-4d        %s\n", i == set.best ? '*' : ' ',

Error: CLANG_WARNING: [#def38]
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: [#def39]
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): [#def40]
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): [#def41]
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): [#def42]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1322: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
# 1320|               newAlt.family = strdup(*nextArg);
# 1321|   
# 1322|->             if (strchr(newAlt.family, '@')) {
# 1323|                   printf(_("--family can't contain the symbol '@'\n"));
# 1324|                   usage(2);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def43]
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: [#def44]
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): [#def45]
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): [#def46]
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: [#def47]
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: [#def48]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1409:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title'
# 1407|           return removeFollower(title, target, followerTitle, altDir, stateDir, flags);
# 1408|       case MODE_DISPLAY:
# 1409|->         return displayService(title, altDir, stateDir, flags);
# 1410|       case MODE_AUTO:
# 1411|           return autoService(title, altDir, stateDir, flags);

Error: CLANG_WARNING: [#def49]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1411:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title'
# 1409|           return displayService(title, altDir, stateDir, flags);
# 1410|       case MODE_AUTO:
# 1411|->         return autoService(title, altDir, stateDir, flags);
# 1412|       case MODE_CONFIG:
# 1413|           return configService(title, altDir, stateDir, flags);

Error: CLANG_WARNING: [#def50]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1413:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title'
# 1411|           return autoService(title, altDir, stateDir, flags);
# 1412|       case MODE_CONFIG:
# 1413|->         return configService(title, altDir, stateDir, flags);
# 1414|       case MODE_SET:
# 1415|           return setService(title, target, altDir, stateDir, flags);

Error: CLANG_WARNING: [#def51]
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: [#def52]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1415:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title'
# 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: [#def53]
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);

Error: CLANG_WARNING: [#def54]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1417:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title'
# 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);

Error: CLANG_WARNING: [#def55]
chkconfig-1.26-build/chkconfig-1.26/alternatives.c:1419:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'title'
# 1417|           return removeService(title, target, altDir, stateDir, flags);
# 1418|       case MODE_REMOVE_ALL:
# 1419|->         return removeAll(title, altDir, stateDir, flags);
# 1420|       case MODE_FOLLOWER:
# 1421|           usage(2);

Error: CPPCHECK_WARNING: [#def56]
chkconfig-1.26-build/chkconfig-1.26/chkconfig.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

Error: COMPILER_WARNING (CWE-252): [#def57]
chkconfig-1.26-build/chkconfig-1.26/chkconfig.c: scope_hint: In function ‘reloadSystemd’
chkconfig-1.26-build/chkconfig-1.26/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: [#def58]
chkconfig-1.26-build/chkconfig-1.26/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): [#def59]
chkconfig-1.26-build/chkconfig-1.26/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: [#def60]
chkconfig-1.26-build/chkconfig-1.26/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): [#def61]
chkconfig-1.26-build/chkconfig-1.26/chkconfig.c: scope_hint: In function ‘setService’
chkconfig-1.26-build/chkconfig-1.26/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): [#def62]
chkconfig-1.26-build/chkconfig-1.26/chkconfig.c: scope_hint: In function ‘forwardSystemd’
chkconfig-1.26-build/chkconfig-1.26/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): [#def63]
chkconfig-1.26-build/chkconfig-1.26/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: [#def64]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

Error: COMPILER_WARNING (CWE-477): [#def65]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘selinux_restore’
chkconfig-1.26-build/chkconfig-1.26/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): [#def66]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘readDescription’
chkconfig-1.26-build/chkconfig-1.26/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: [#def67]
chkconfig-1.26-build/chkconfig-1.26/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): [#def68]
chkconfig-1.26-build/chkconfig-1.26/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: [#def69]
chkconfig-1.26-build/chkconfig-1.26/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): [#def70]
chkconfig-1.26-build/chkconfig-1.26/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: [#def71]
chkconfig-1.26-build/chkconfig-1.26/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): [#def72]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘readXinetdServiceInfo’
chkconfig-1.26-build/chkconfig-1.26/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): [#def73]
chkconfig-1.26-build/chkconfig-1.26/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): [#def74]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘readServiceInfo’
chkconfig-1.26-build/chkconfig-1.26/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): [#def75]
chkconfig-1.26-build/chkconfig-1.26/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): [#def76]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘readServiceDifferences’
chkconfig-1.26-build/chkconfig-1.26/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): [#def77]
chkconfig-1.26-build/chkconfig-1.26/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): [#def78]
chkconfig-1.26-build/chkconfig-1.26/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): [#def79]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘parseDeps’
chkconfig-1.26-build/chkconfig-1.26/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): [#def80]
chkconfig-1.26-build/chkconfig-1.26/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): [#def81]
chkconfig-1.26-build/chkconfig-1.26/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): [#def82]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘parseServiceInfo’
chkconfig-1.26-build/chkconfig-1.26/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): [#def83]
chkconfig-1.26-build/chkconfig-1.26/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): [#def84]
chkconfig-1.26-build/chkconfig-1.26/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: [#def85]
chkconfig-1.26-build/chkconfig-1.26/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: [#def86]
chkconfig-1.26-build/chkconfig-1.26/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: [#def87]
chkconfig-1.26-build/chkconfig-1.26/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: [#def88]
chkconfig-1.26-build/chkconfig-1.26/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: [#def89]
chkconfig-1.26-build/chkconfig-1.26/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: [#def90]
chkconfig-1.26-build/chkconfig-1.26/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): [#def91]
chkconfig-1.26-build/chkconfig-1.26/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): [#def92]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘setXinetdService’
chkconfig-1.26-build/chkconfig-1.26/leveldb.c:858:16: warning[-Wanalyzer-malloc-leak]: leak of ‘buf’
chkconfig-1.26-build/chkconfig-1.26/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): [#def93]
chkconfig-1.26-build/chkconfig-1.26/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): [#def94]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘setXinetdService’
chkconfig-1.26-build/chkconfig-1.26/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): [#def95]
chkconfig-1.26-build/chkconfig-1.26/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): [#def96]
chkconfig-1.26-build/chkconfig-1.26/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): [#def97]
chkconfig-1.26-build/chkconfig-1.26/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): [#def98]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘isOverriddenBySystemd’
chkconfig-1.26-build/chkconfig-1.26/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): [#def99]
chkconfig-1.26-build/chkconfig-1.26/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): [#def100]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘isSocketActivatedBySystemd’
chkconfig-1.26-build/chkconfig-1.26/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): [#def101]
chkconfig-1.26-build/chkconfig-1.26/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): [#def102]
chkconfig-1.26-build/chkconfig-1.26/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): [#def103]
chkconfig-1.26-build/chkconfig-1.26/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): [#def104]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘runlevelsToTargets’
chkconfig-1.26-build/chkconfig-1.26/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: [#def105]
chkconfig-1.26-build/chkconfig-1.26/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): [#def106]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘serviceNameToUnit’
chkconfig-1.26-build/chkconfig-1.26/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): [#def107]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘unitIsSimilarlyConfigure’
chkconfig-1.26-build/chkconfig-1.26/leveldb.c:1273:5: warning[-Wanalyzer-null-argument]: use of NULL ‘deps’ where non-null expected
chkconfig-1.26-build/chkconfig-1.26/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: [#def108]
chkconfig-1.26-build/chkconfig-1.26/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): [#def109]
chkconfig-1.26-build/chkconfig-1.26/leveldb.c: scope_hint: In function ‘checkSystemdDependencies’
chkconfig-1.26-build/chkconfig-1.26/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: [#def110]
chkconfig-1.26-build/chkconfig-1.26/ntsysv.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

Error: COMPILER_WARNING (CWE-252): [#def111]
chkconfig-1.26-build/chkconfig-1.26/ntsysv.c: scope_hint: In function ‘servicesWindow’
chkconfig-1.26-build/chkconfig-1.26/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): [#def112]
chkconfig-1.26-build/chkconfig-1.26/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: [#def113]
chkconfig-1.26-build/chkconfig-1.26/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): [#def114]
chkconfig-1.26-build/chkconfig-1.26/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): [#def115]
chkconfig-1.26-build/chkconfig-1.26/ntsysv.c: scope_hint: In function ‘getServices’
chkconfig-1.26-build/chkconfig-1.26/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): [#def116]
chkconfig-1.26-build/chkconfig-1.26/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): [#def117]
chkconfig-1.26-build/chkconfig-1.26/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: [#def118]
chkconfig-1.26-build/chkconfig-1.26/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;

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-183.us-west-2.compute.internal
mock-configfedora-41-x86_64
project-namechkconfig-1.26-3.fc40
store-results-to/tmp/tmpvu7lxird/chkconfig-1.26-3.fc40.tar.xz
time-created2024-07-03 12:11:31
time-finished2024-07-03 12:13:03
toolcsmock
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-versioncsmock-3.5.3-1.el9