Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Integer overflow during brace expansion



On 27 February 2012 17:54, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>>
>> The fix is fairly simple, just change the types involved to zlong. A
>> problem is that sprintf is used to convert the generated numbers back
>> to a string, and zlong can be an int or a long, but I forgot if we
>> have a modifier macro that expands to the correct thing. I remember
>> asking about it before (and possibly saying I would look in to fixing
>> it), but at the moment I don't remember what the result was.

I found the old thread now, pws suggested just using %ld and casting
the value to long, to which I replied something incomprehensibly
stupid, "but %d won't work if I cast to long". If nobody sees a
problem with the above patch, I can commit it with this change.

-               sprintf(p + strp, "%0*ld", minw, rend);
+               sprintf(p + strp, "%0*ld", minw, (long)rend);

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author