On 04/25/2013 02:34 AM, Pádraig Brady wrote:
> On 01/23/2013 11:58 PM, Lei Zhang wrote:
>> Hi All,
>>
>> In the `split' program of coreutils 8.20, we found a bug which is similar
>> to the bug reported in bug#13530:
>>
>> Invoking `split -C T' or `split -C P' or `split -C E' will cause memory
>> exhaustion.
>>
>> However, smaller units (e.g., K, M, G) work fine; bigger units (e.g., Z, Y)
>> fail properly (by outputing "invalid number of bytes").
>>
>> A bit dig reveals that the bug is introduced at line 1412 of split.c
>> (coreutils 8.20):
>>
>> 1400: switch (split_type)
>> 1401: {
>> ...
>> 1411: case type_byteslines:
>> 1412: line_bytes_split (n_units); /* this function calls
>> xmalloc(n_bytes), which fails. */
>> 1413: break;
>> ...
>> 1434: }
>>
>> `n_units' before that statement can be very large. In the case of `split -C
>> T', it is 1099511627776.
>>
>> We think this is a bug similar to the one reported in bug#13530, so we
>> bring this issue to your attention. Thanks!
>
> I intend to push the attached soon to fix this.
Bernhard Voelker kindly reviewed this and noticed
I had an '|| fail=1' inside a subshell in the test.
Also he questioned the open coding of:
error (EXIT_FAILURE, 0, "%s", _("memory exhausted"));
It's better to use the more abstract xalloc_die()
in this case (and another in lines_rr()).
I'm pushing now with these two adjustments.
thanks,
Pádraig.