On Thu, Jun 18, 2015 at 3:57 PM, Wolfgang Corcoran-Mathe
<first.lord.of.t...@gmail.com> wrote:
> emg,
>
> Quoth Evan Gates on Thu, Jun 18 2015 14:47 -0700:
>>
>> diff --git a/find.c b/find.c
>> index 186263b..0de1951 100644
>> --- a/find.c
>> +++ b/find.c
>> @@ -415,10 +415,9 @@ pri_ok(struct arg *arg)
>>         reply = fgetc(stdin);
>>
>>         /* throw away rest of line */
>> -       while ((c = fgetc(stdin)) != '\n' && c != EOF)
>> -               /* FIXME: what if the first character of the rest of the
>> line is a null
>> -                * byte? */
>> -               ;
>> +       if (c != '\n')
>> +               while ((c = fgetc(stdin)) != '\n' && c != EOF)
>> +                       ;
>
>
> I think you meant
>
>    if (reply != '\n')
>        ...

Yes I most certainly did, this is what I get for submitting patches
without testing. The shame. New patch attached, also protects against
the glibc bug causing fgetc to hang after EOF was received.
-emg
From 9f3e3e5d9d8652e8df91c66aae7ecd9f5e8769ae Mon Sep 17 00:00:00 2001
From: Evan Gates <evan.ga...@gmail.com>
Date: Thu, 18 Jun 2015 18:00:06 -0700
Subject: [PATCH] empty line means no for -ok (also protect against glibc EOF
 bug)

---
 find.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/find.c b/find.c
index 186263b..f56e0bb 100644
--- a/find.c
+++ b/find.c
@@ -415,10 +415,9 @@ pri_ok(struct arg *arg)
        reply = fgetc(stdin);
 
        /* throw away rest of line */
-       while ((c = fgetc(stdin)) != '\n' && c != EOF)
-               /* FIXME: what if the first character of the rest of the line 
is a null
-                * byte? */
-               ;
+       if (reply != '\n' && reply != EOF)
+               while ((c = fgetc(stdin)) != '\n' && c != EOF)
+                       ;
 
        if (feof(stdin)) /* FIXME: ferror()? */
                clearerr(stdin);
-- 
2.4.4

Reply via email to