Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.

Bug 8084

Summary: sysctl derefs uninitialized variable, uses feof inappropriately
Product: [Retired] Red Hat Linux Reporter: Jonathan Kamens <jik>
Component: procpsAssignee: Michael K. Johnson <johnsonm>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: procps-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
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: ---
Description Flags
still broken; here's patch for procps-2.0.6-2 none

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;
       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