Bug 8084 - sysctl derefs uninitialized variable, uses feof inappropriately
sysctl derefs uninitialized variable, uses feof inappropriately
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: procps (Show other bugs)
6.1
All Linux
medium Severity medium
: ---
: ---
Assigned To: Michael K. Johnson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-12-31 10:16 EST by Jonathan Kamens
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-02-14 07:26:54 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
still broken; here's patch for procps-2.0.6-2 (320 bytes, patch)
2000-02-14 07:26 EST, Jonathan Kamens
no flags Details | Diff

  None (edit)
Description Jonathan Kamens 1999-12-31 10:16:01 EST
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);
Comment 1 Jonathan Kamens 2000-02-14 07:26:59 EST
Created attachment 116 [details]
still broken; here's patch for procps-2.0.6-2
Comment 2 Michael K. Johnson 2000-07-31 16:09:26 EDT
This was fixed in procps-2.0.7

Note You need to log in before you can comment on or make changes to this bug.