Bug 8084
| Summary: | sysctl derefs uninitialized variable, uses feof inappropriately | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Retired] Red Hat Linux | Reporter: | Jonathan Kamens <h1k6zn2m> | ||||
| Component: | procps | Assignee: | Michael K. Johnson <johnsonm> | ||||
| Status: | CLOSED RAWHIDE | QA Contact: | |||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | medium | ||||||
| Version: | 6.1 | CC: | procps-bugs | ||||
| Target Milestone: | --- | ||||||
| Target Release: | --- | ||||||
| Hardware: | All | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2000-02-14 12:26:54 UTC | Type: | --- | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Attachments: |
|
||||||
Created attachment 116 [details]
still broken; here's patch for procps-2.0.6-2
This was fixed in procps-2.0.7 |
Sysctl will randomly decide not to load a config file when "sysctl -p" is specified, depending on what's in memory, because it checks the wrong variable to see if it's null. Furthermore, it will sometimes incorrectly report an invalid line in the file, because it uses feof() to check for EOF when feof() may not be true, even at EOF, if stdio hasn't yet realized that it has read everything. The patch below fixes both of these problem. --- sysctl.c.orig Fri Dec 31 10:09:36 1999 +++ sysctl.c Fri Dec 31 10:11:56 1999 @@ -183,13 +183,12 @@ int n = 0; char *name, *value; - if (!name || ((fp = fopen(filename, "r")) == NULL)) { + if (!filename || ((fp = fopen(filename, "r")) == NULL)) { fprintf(stderr, ERR_PRELOAD_FILE, filename); return 0; } /* endif */ - while (!feof(fp)) { - fgets(oneline, 256, fp); + while (fgets(oneline, 256, fp)) { oneline[256] = 0; n++; t = StripLeadingAndTrailingSpaces(oneline);