-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternatives: Fix issues found by static analyzers #126
Merged
Commits on May 7, 2024
-
Error: RESOURCE_LEAK (CWE-772): chkconfig-1.26/alternatives.c:328: alloc_fn: Storage is returned from allocation function "parseLine". chkconfig-1.26/alternatives.c:328: var_assign: Assigning: "line" = storage returned from "parseLine(&buf)". chkconfig-1.26/alternatives.c:331: leaked_storage: Variable "line" going out of scope leaks the storage it points to. 329| if (!line || *line != '/') { 330| fprintf(stderr, _("bad primary link in %s\n"), path); 331|-> return 1; 332| } 333|
Configuration menu - View commit details
-
Copy full SHA for e47405e - Browse repository at this point
Copy the full SHA e47405eView commit details -
alternatives: initialize parameters in main to NULL
This should be a no-op but it hardens the code and also makes static analyzers a bit more happy.
Configuration menu - View commit details
-
Copy full SHA for 5140aa7 - Browse repository at this point
Copy the full SHA 5140aa7View commit details -
Error: RESOURCE_LEAK (CWE-772): chkconfig-1.26/alternatives.c:441: alloc_fn: Storage is returned from allocation function "parseLine". chkconfig-1.26/alternatives.c:441: var_assign: Assigning: "line" = storage returned from "parseLine(&buf)". chkconfig-1.26/alternatives.c:445: overwrite_var: Overwriting "line" in "line = parseLine(&buf)" leaks the storage that "line" points to. 443| 444| while (line) { 445|-> line = parseLine(&buf); 446| if (line && *line) { 447| fprintf(stderr, _("unexpected line in %s: %s\n"), path, line);
Configuration menu - View commit details
-
Copy full SHA for caaa4d6 - Browse repository at this point
Copy the full SHA caaa4d6View commit details -
Error: RESOURCE_LEAK (CWE-772): chkconfig-1.26/alternatives.c:339: alloc_fn: Storage is returned from allocation function "parseLine". chkconfig-1.26/alternatives.c:339: var_assign: Assigning: "line" = storage returned from "parseLine(&buf)". chkconfig-1.26/alternatives.c:342: noescape: Resource "line" is not freed or pointed-to in "fprintf". [Note: The source code implementation of the function has been overridden by a builtin model.] chkconfig-1.26/alternatives.c:343: leaked_storage: Variable "line" going out of scope leaks the storage it points to. 341| if (*line == '/') { 342| fprintf(stderr, _("path %s unexpected in %s\n"), line, path); 343|-> return 1; 344| } 345|
Configuration menu - View commit details
-
Copy full SHA for c296618 - Browse repository at this point
Copy the full SHA c296618View commit details -
Error: RESOURCE_LEAK (CWE-772): [#def1] [important] chkconfig-1.26/alternatives.c:312:5: alloc_fn: Storage is returned from allocation function "parseLine". chkconfig-1.26/alternatives.c:312:5: var_assign: Assigning: "line" = storage returned from "parseLine(&buf)". chkconfig-1.26/alternatives.c:318:5: noescape: Resource "line" is not freed or pointed-to in "strcmp". chkconfig-1.26/alternatives.c:320:12: noescape: Resource "line" is not freed or pointed-to in "strcmp". chkconfig-1.26/alternatives.c:324:9: leaked_storage: Variable "line" going out of scope leaks the storage it points to. 322| } else { 323| fprintf(stderr, _("bad mode on line 1 of %s\n"), path); 324|-> return 1; 325| } 326| free(line);
Configuration menu - View commit details
-
Copy full SHA for ec56116 - Browse repository at this point
Copy the full SHA ec56116View commit details -
Configuration menu - View commit details
-
Copy full SHA for e8dd7ab - Browse repository at this point
Copy the full SHA e8dd7abView commit details -
Configuration menu - View commit details
-
Copy full SHA for 44ba44f - Browse repository at this point
Copy the full SHA 44ba44fView commit details -
alternatives: fix possible overrun
Error: STRING_NULL (CWE-170): [#def1] [important] chkconfig-1.26/alternatives.c:591:13: string_null_source: Function "readlink" does not terminate string "buf". [Note: The source code implementation of the function has been overridden by a builtin model.] chkconfig-1.26/alternatives.c:593:13: string_null: Passing unterminated string "buf" to "streq", which expects a null-terminated string. 591| readlink(l->facility, buf, sizeof(buf)); 592| 593|-> if(!streq(sl, buf)) { 594| unlink(l->facility); 595| Error: STRING_NULL (CWE-170): [#def2] [important] chkconfig-1.26/alternatives.c:609:9: string_null_source: Function "readlink" does not terminate string "buf". [Note: The source code implementation of the function has been overridden by a builtin model.] chkconfig-1.26/alternatives.c:611:9: string_null: Passing unterminated string "buf" to "streq", which expects a null-terminated string. 609| readlink(sl, buf, sizeof(buf)); 610| 611|-> if(!streq(l->target, buf)) { 612| if (unlink(sl) && errno != ENOENT) { 613| fprintf(stderr, _("failed to remove link %s: %s\n"), sl,
Configuration menu - View commit details
-
Copy full SHA for c247ff1 - Browse repository at this point
Copy the full SHA c247ff1View commit details -
Error: RESOURCE_LEAK (CWE-772): [#def3] [important] chkconfig-1.26/alternatives.c:794:9: alloc_fn: Storage is returned from allocation function "malloc". chkconfig-1.26/alternatives.c:794:9: var_assign: Assigning: "newLinks" = storage returned from "malloc(24UL * template.numFollowers)". chkconfig-1.26/alternatives.c:798:9: identity_transfer: Passing "newLinks" as argument 1 to function "memset", which returns that argument. [Note: The source code implementation of the function has been overridden by a builtin model.] chkconfig-1.26/alternatives.c:798:9: noescape: Resource "newLinks" is not freed or pointed-to in "memset". [Note: The source code implementation of the function has been overridden by a builtin model.] chkconfig-1.26/alternatives.c:798:9: var_assign: Assigning: "newLinks" = storage returned from "memset(newLinks, 0, 24UL * template.numFollowers)". chkconfig-1.26/alternatives.c:817:21: leaked_storage: Variable "newLinks" going out of scope leaks the storage it points to. 815| set->alts[k].followers[i].title, 816| template.followers[j].facility, template.followers[j].title); 817|-> return 2; 818| } 819| newLinks[j] = set->alts[k].followers[i];
Configuration menu - View commit details
-
Copy full SHA for d71bac5 - Browse repository at this point
Copy the full SHA d71bac5View commit details -
Error: RESOURCE_LEAK (CWE-772): [#def4] [important] chkconfig-1.26/alternatives.c:1255:5: alloc_fn: Storage is returned from allocation function "opendir". chkconfig-1.26/alternatives.c:1255:5: var_assign: Assigning: "dir" = storage returned from "opendir(stateDir)". chkconfig-1.26/alternatives.c:1259:5: noescape: Resource "dir" is not freed or pointed-to in "readdir". chkconfig-1.26/alternatives.c:1259:5: noescape: Resource "dir" is not freed or pointed-to in "readdir". chkconfig-1.26/alternatives.c:1267:5: noescape: Resource "dir" is not freed or pointed-to in "rewinddir". chkconfig-1.26/alternatives.c:1269:5: noescape: Resource "dir" is not freed or pointed-to in "readdir". chkconfig-1.26/alternatives.c:1274:13: leaked_storage: Variable "dir" going out of scope leaks the storage it points to. 1272| 1273| if (readConfig(&set, ent->d_name, altDir, stateDir, flags)) 1274|-> return 2; 1275| 1276| printf("%-*s\t%s\t%s\n", max_name, ent->d_name,
Configuration menu - View commit details
-
Copy full SHA for 0268377 - Browse repository at this point
Copy the full SHA 0268377View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5e2658d - Browse repository at this point
Copy the full SHA 5e2658dView commit details
Commits on May 13, 2024
-
Configuration menu - View commit details
-
Copy full SHA for e406ed8 - Browse repository at this point
Copy the full SHA e406ed8View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.