bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 1/6] parse-datetime, posixtm: avoid uninit access


From: Pádraig Brady
Subject: Re: [PATCH 1/6] parse-datetime, posixtm: avoid uninit access
Date: Fri, 24 Nov 2017 11:47:01 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 24/11/17 00:31, Paul Eggert wrote:
> Pádraig Brady wrote:
>> It's not introducing any new issue I think, but
>> seems to be triggering the compiler warning due
>> to tm_year being explicitly set?
> 
> Actually, I think it's pointing out an issue with the API. If the caller to 
> posixtime were to specify neither PDS_LEADING_YEAR nor PDS_TRAILING_YEAR, the 
> 'year' function would never get called, which means that tm0.tm_year would be 
> uninitialized.
> 
> No caller ever does that. In practice, PDS_LEADING_YEAR and PDS_TRAILING_YEAR 
> are mutually exclusive and one or the other should always be specified. This 
> suggests that there should be just a single bit in the API, not two bits. I 
> installed the attached patch, which changes the API accordingly, in a way 
> that I 
> think will not break any current callers. Does it pacify your GCC?

It does indeed since bitwise ops are not in all paths to initializing tm_year.

thanks!
Pádraig



reply via email to

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