[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#57729: libc6: fgets() doesn't work properly on socket



On Fri, 28 Jul 2000, Ben Collins wrote:
>I've read the info page on fgets(), and found this:
>
>     *Warning:*  If the input data has a null character, you can't tell.
>     So don't use `fgets' unless you know the data cannot contain a
>     null.  Don't use it to read files edited by the user because, if
>     the user inserts a null character, you should either handle it
>     properly or print a clear error message.  We recommend using
>     `getline' instead of `fgets'.
>
>I suspect this is causing your problem (null chars). If this satisfies
>your problem, but you are still disatisfied with the man page, please
>reassign this bug to the manpages-dev package (which is not maintained as
>part of glibc).

I really don't think that is the problem.  I was reading SMTP data from a
connection to Postfix.  Postfix was not sending any nulls.

It appeared that it was only doing a single read and not doing another
blocking read if there was not a full line's worth of data.

If it is deemed that libc is operating correctly and fgets() should not block
on a socket then it should be documented as such in the man page and I will
file a bug report against the man pages.  However at the moment I have no
evidence to suggest that is the case.


Russell Coker



Reply to: