[klibc] overflow in fgets()

Adrian Drzewiecki z at drze.net
Thu May 26 16:33:46 PDT 2005


Currently, the mainloop in fgets() does:

	while (n > 1) {
		...
	}

But it never decrements n.

-Adrian
-------------- next part --------------
--- fgets.c-old	2005-05-26 16:30:58.000000000 -0700
+++ fgets.c	2005-05-26 16:32:33.000000000 -0700
@@ -22,6 +22,7 @@
     *p++ = ch;
     if ( ch == '\n' )
       break;
+    n --;
   }
   if ( n )
     *p = '\0';


More information about the klibc mailing list