[tz] Bug in 2022f version of zic.c

Paul Eggert eggert at cs.ucla.edu
Sat Nov 5 01:24:59 UTC 2022


On 2022-11-04 16:11, Guy Harris via tz wrote:

> In what cases in zic is emalloc() - or erealloc() - called with 0 as the size argument?

It's when zic sees a Zone with no continuation lines. I didn't notice 
the bug in testing, since I don't test with AIX. The portability bug was 
triggered by the removal of the Qt bug workaround in tzcode 2022f, which 
when combined with the -bslim option introduced in tzcode 2019b means 
that zic can generate TZif files with no time transitions.

Thanks for reporting the bug, Tim. I installed the first attached patch; 
please give it a try. I think this fixes the only place that might call 
malloc(0) or realloc(p, 0).

It's unfortunate that the C standard allows malloc to return NULL on 
success, as this complicates error checking. Of course zic.c should be 
portable even to platforms that exploit this glitch in C.


> (ecpyalloc() - which should probably be called estrdup() to make it clearer that it's "strdup() with quit on out-of-memory"

Good suggestion, thanks. I installed the attached second patch to do that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Port-to-AIX-6.1-malloc.patch
Type: text/x-patch
Size: 1956 bytes
Desc: not available
URL: <https://mm.icann.org/pipermail/tz/attachments/20221104/bf273505/0001-Port-to-AIX-6.1-malloc-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Rename-ecpyalloc-to-estrdup.patch
Type: text/x-patch
Size: 3109 bytes
Desc: not available
URL: <https://mm.icann.org/pipermail/tz/attachments/20221104/bf273505/0002-Rename-ecpyalloc-to-estrdup-0001.patch>


More information about the tz mailing list