[Top][All Lists]

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

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

From: Paul Eggert
Subject: Re: [PATCH 1/6] parse-datetime, posixtm: avoid uninit access
Date: Fri, 24 Nov 2017 00:31:38 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

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?

Attachment: 0001-posixtm-remove-PDS_LEADING_YEAR.txt
Description: Text document

reply via email to

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