public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/263] New: potential subscript error and superfluous test in Linux getloadavg
@ 2004-07-13  0:01 eggert at gnu dot org
  2004-07-13  0:29 ` [Bug libc/263] " roland at gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: eggert at gnu dot org @ 2004-07-13  0:01 UTC (permalink / raw)
  To: glibc-bugs

While fixing some bugs in gnulib getloadavg I discovered that glibc
Linux getloadavg.c has a bug when the read returns EOF, and an
unnecessary test.  Here's a proposed patch.

2004-07-12  Paul Eggert  <eggert@cs.ucla.edu>

	* sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Don't store
	outside the buffer if the read returns 0.  __strtod_l can't set
	endp to NULL, so remove a test for that case.

--- old/sysdeps/unix/sysv/linux/getloadavg.c	2003-09-03 13:11:54 -0700
+++ new/sysdeps/unix/sysv/linux/getloadavg.c	2004-07-12 11:17:39 -0700
@@ -45,7 +45,7 @@ getloadavg (double loadavg[], int nelem)
 
       nread = read_not_cancel (fd, buf, sizeof buf - 1);
       close_not_cancel_no_status (fd);
-      if (nread < 0)
+      if (nread <= 0)
 	return -1;
       buf[nread - 1] = '\0';
 
@@ -56,7 +56,7 @@ getloadavg (double loadavg[], int nelem)
 	{
 	  char *endp;
 	  loadavg[i] = __strtod_l (p, &endp, &_nl_C_locobj);
-	  if (endp == NULL || endp == p)
+	  if (endp == p)
 	    /* This should not happen.  The format of /proc/loadavg
 	       must have changed.  Don't return with what we have,
 	       signal an error.  */

-- 
           Summary: potential subscript error and superfluous test in Linux
                    getloadavg
           Product: glibc
           Version: 2.3.3
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: eggert at gnu dot org
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sources.redhat.com/bugzilla/show_bug.cgi?id=263

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug libc/263] potential subscript error and superfluous test in Linux getloadavg
  2004-07-13  0:01 [Bug libc/263] New: potential subscript error and superfluous test in Linux getloadavg eggert at gnu dot org
@ 2004-07-13  0:29 ` roland at gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: roland at gnu dot org @ 2004-07-13  0:29 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From roland at gnu dot org  2004-07-13 00:29 -------
I committed the patch today.  Unfortunately, the tracking script is broken so it
didn't show it here.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://sources.redhat.com/bugzilla/show_bug.cgi?id=263

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-07-13  0:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-13  0:01 [Bug libc/263] New: potential subscript error and superfluous test in Linux getloadavg eggert at gnu dot org
2004-07-13  0:29 ` [Bug libc/263] " roland at gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).