… | |
… | |
62 | return TRUE; |
62 | return TRUE; |
63 | } |
63 | } |
64 | #endif |
64 | #endif |
65 | #endif |
65 | #endif |
66 | |
66 | |
67 | char * fptools_id = "$Id: fptools.c,v 1.5 2002/03/31 20:08:42 root Exp $"; |
67 | char * fptools_id = "$Id: fptools.c,v 1.6 2002/08/19 23:25:36 root Exp $"; |
68 | |
68 | |
69 | /* |
69 | /* |
70 | * some versions of free can't handle a NULL pointer properly |
70 | * some versions of free can't handle a NULL pointer properly |
71 | * (ANSI says, free ignores a NULL pointer, but some machines |
71 | * (ANSI says, free ignores a NULL pointer, but some machines |
72 | * prefer to SIGSEGV on it) |
72 | * prefer to SIGSEGV on it) |
… | |
… | |
438 | char * TOOLEXPORT |
438 | char * TOOLEXPORT |
439 | _FP_fgets (char *buf, int n, FILE *stream) |
439 | _FP_fgets (char *buf, int n, FILE *stream) |
440 | { |
440 | { |
441 | char *obp = buf; |
441 | char *obp = buf; |
442 | int c; |
442 | int c; |
|
|
443 | |
|
|
444 | /* shield against buffer overflows caused by "255 - bytes_left"-kind of bugs when bytes_left > 255 */ |
|
|
445 | if (n <= 0) |
|
|
446 | return NULL; |
443 | |
447 | |
444 | if (feof (stream)) |
448 | if (feof (stream)) |
445 | return NULL; |
449 | return NULL; |
446 | |
450 | |
447 | while (--n) { |
451 | while (--n) { |