[PATCH] time: Use struct alloc_buffer in __tzfile_read

Florian Weimer fweimer@redhat.com
Sun Feb 3 08:31:00 GMT 2019


* Paul Eggert:

> Florian Weimer wrote:
>> +  if (alloc_buffer_alloc_array (&buf, __time64_t, num_transitions)
>> +      != transitions)
>> +    /* Either the start of the allocation moved unexpectedly
>> +       (misaligned heap pointer, should not happen), or we had an
>> +       overflow.  */
>> +    goto lose;
>
> Is this comparison needed? The overflow will be caught later anyway,
> and the != comparison cannot fail.
>
> Otherwise it looks good; thanks.

Okay, I will remove that.  Even if the allocation moves the pointer
(after removal of the alignment code), we will not cause heap corruption
because the deallocation will use the original (non-moved) pointer.

Thanks,
Florian



More information about the Libc-alpha mailing list