[Top][All Lists]

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

Re: [PATCH 1/4] localename: -Wtautological-pointer-compare

From: Paul Eggert
Subject: Re: [PATCH 1/4] localename: -Wtautological-pointer-compare
Date: Fri, 13 Jan 2023 15:36:55 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 2023-01-13 14:59, Bruno Haible wrote:
Replacing a function that starts with an entry check — which is a good
practice [1]

It's a good practice in some contexts, bad in others.

In this particular case, on practical Gnulib targets the input should be checked anyway, both statically by the compiler at the call point and dynamically by the MMU.

There is a downside of the extra runtime check, in that if static checking is disabled (a mistake if you ask me, but many people do it), then the calling code won't immediately crash like it should. Instead, the function simply sets errno and returns, and the calling code might go on to do the wrong thing because there's a lot of sloppy calling code that either doesn't check errno or that has never been tested to do the right thing when the function fails.

So my guess is that for this particular case on practical hosts, the additional runtime check is more likely to introduce a security bug, than to prevent one. Of course this is just a guess. But that's why I wrote the patch the way I did.

reply via email to

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