[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] posix: Remove alloca usage for internal fnmatch implemen
From: |
Florian Weimer |
Subject: |
Re: [PATCH 2/2] posix: Remove alloca usage for internal fnmatch implementation |
Date: |
Thu, 21 Oct 2021 11:54:47 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
* Adhemerval Zanella:
> On 08/03/2021 09:59, Florian Weimer wrote:
>> * Adhemerval Zanella via Libc-alpha:
>>
>>> - else if (*p == L_('|'))
>>> + else if (*p == L_(')') || *p == L_('|'))
>>> {
>>> if (level == 0)
>>> {
>>> - NEW_PATTERN;
>>> - startp = p + 1;
>>> + size_t slen = opt == L_('?') || opt == L_('@')
>>> + ? pattern_len : p - startp + 1;
>>> + CHAR *newp = malloc (slen * sizeof (CHAR));
>>> + if (newp != NULL)
>>> + {
>>> + *((CHAR *) MEMPCPY (newp, startp, p - startp)) = L_('\0');
>>> + PASTE (PATTERN_PREFIX,_add) (&list, newp);
>>> + }
>>> + if (newp == NULL || PASTE (PATTERN_PREFIX, _has_failed)
>>> (&list))
>>> + {
>>> + retval = -2;
>>> + goto out;
>>> + }
>>> +
>>> + if (*p == L_('|'))
>>> + startp = p + 1;
>>> }
>>
>> slen seems to be the wrong variable name. But I don't know wh the
>> original code computes plen conditionally and then uses p - startp
>> unconditionally. That seems wrong. The discrepancy goes back to
>> 821a6bb4360. Do you see a case where the difference matters?
>>
>> The == 0 checks for the recursive FCT calls are wrong because they treat
>> match failure the same as OOM and other errors (the -2 return value),
>> but that also is a pre-existing issue.
>>
>> The conversation itself appears to be faithful.
>
> Hi Florian,
>
> I noted this patch [1] is marked accepted, was you the one that
> accepted it? In any case, are you still ok with the change?
>
>
> [1]
> https://patchwork.sourceware.org/project/glibc/patch/20210202130804.1920933-2-adhemerval.zanella@linaro.org/
I think all the issues I identified are pre-existing, and as I said, the
conversion to remove alloca appears to be correct.
Thanks,
Florian