Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 122294 Details for
Bug 182288
fgets goes into infinite loop when called with size set to less than 2 bytes
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
*Correct* test case demonstrating correct behaviour.
fgets.c (text/plain), 657 bytes, created by
Nick Bowler
on 2007-06-17 06:08:21 UTC
(
hide
)
Description:
*Correct* test case demonstrating correct behaviour.
Filename:
MIME Type:
Creator:
Nick Bowler
Created:
2007-06-17 06:08:21 UTC
Size:
657 bytes
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <string.h> > >int main(void) >{ > FILE *f; > char buf[256]; /* Change 256 to 1, and you can see the wierd behaviour > * of fgets if run against glibc-2.3.5 */ > unsigned lines = 0; > > /* Create this file before starting! */ > f = fopen("/tmp/null_file", "r"); > if (!f) { > perror("fopen"); > return EXIT_FAILURE; > } > > while (1) { > if (!fgets(buf, sizeof buf, f)) { > if (feof(f)) > puts("End of File"); > else if (ferror(f)) > puts("Error"); > else > puts("Wierd behaviour"); > break; > } > > if (strchr(buf, '\n')) { > printf("Read %u lines.\n", ++lines); > } > } > > fclose(f); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 182288
:
122293
| 122294