bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] af_alg: avoid hangs when reading from streams


From: Pádraig Brady
Subject: Re: [PATCH] af_alg: avoid hangs when reading from streams
Date: Sun, 24 Jun 2018 15:15:04 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 24/06/18 14:34, Bruno Haible wrote:
> Hi Pádraig,
> 
> The patch looks good. Just nitpicking about the comments:
> 
>> +          /* Either process a partial fread() from this loop,
>> +             or the fread() in afalg_stream may have gotten EOF.
>> +             We need to avoid a subsequent fread() due to glibc BZ 1190.  */
> 
> We need to avoid a subsequent fread(), not only for glibc, but also on
> platforms with SystemV heritage. [1]
> 
>> +          /* Assume EOF is not sticky. See:
>> +             <https://sourceware.org/bugzilla/show_bug.cgi?id=19476>.  */
>> +          if (feof (stream))
> 
> You can't assume that EOF is not sticky, because per [1]
> "BSDs always had sticky EOF". How about
> 
>           /* Don't assume that EOF is sticky. See:
>              <https://sourceware.org/bugzilla/show_bug.cgi?id=19476>.  */
> 
> Bruno
> 
> [1] https://sourceware.org/bugzilla/show_bug.cgi?id=1190

Yes that should have been clearer.

I'll push this in a while.

cheers,
Pádraig

diff --git a/lib/af_alg.c b/lib/af_alg.c
index 9630d03..5c227fa 100644
--- a/lib/af_alg.c
+++ b/lib/af_alg.c
@@ -140,7 +140,7 @@ afalg_stream (FILE *stream, const char *alg,
               break;
             }

-          /* Assume EOF is not sticky. See:
+          /* Don't assume that EOF is sticky. See:
              <https://sourceware.org/bugzilla/show_bug.cgi?id=19476>.  */
           if (feof (stream))
             {
diff --git a/lib/md5.c b/lib/md5.c
index ea69a59..2b55cc6 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -172,7 +172,9 @@ md5_stream (FILE *stream, void *resblock)
         {
           /* Either process a partial fread() from this loop,
              or the fread() in afalg_stream may have gotten EOF.
-             We need to avoid a subsequent fread() due to glibc BZ 1190.  */
+             We need to avoid a subsequent fread() as EOF may
+             not be sticky.  For details of such systems, see:
+             https://sourceware.org/bugzilla/show_bug.cgi?id=1190  */
           if (feof (stream))
             goto process_partial_block;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]