Re: [PATCH] Add getenv.so for catching invalid getenv() use via LD_PRELOAD
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jan 5, 2013, 11:37 UTC
- Message-ID
- <CACsJy8A-Q8uDC0fJzspU8khCtWnMgmz66L2G9hLmsRYFYLaumw@mail.gmail.com>
- In-Reply-To
- <20130105103900.GA4200@ftbfs.org>
On Sat, Jan 5, 2013 at 5:39 PM, Matt Kraai <kraai@ftbfs.org> wrote:
Show 7 quoted lines
> On Sat, Jan 05, 2013 at 03:55:46PM +0700, Nguyễn Thái Ngọc Duy wrote: >> Perhaps this will help the getenv bug hunting (I assume we do the >> hunting on Linux platform only). So far it catches this and is stuck >> at getenv in git_pager(). > > It seems like a static analysis tool might be able to detect these > problems. Is there a way to do so using sparse?
That was my first thought. But this may involve flow analysis and I don't think sparse is up to it. ccc-analyzer is still pretty basic. And between static analysis and runtime check, I prefer the latter as it's more reliable as long as you have a good coverage test.
Show 7 quoted lines
>
>> + n = backtrace(buffer, 100);
>> + symbols = backtrace_symbols(buffer, n);
>> + if (symbols) {
>> + for (i = 0;i < n; i++)
>
> s/;i/; i/Thanks. I will fix it later if people actually want this.
-- Duy