| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> | 
|---|---|
| To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> | 
| Subject: | Re: Fix inappropriate uses of atol() | 
| Date: | 2024-08-10 06:43:59 | 
| Message-ID: | 56e97e55-a932-428e-aad0-9922c1befa14@eisentraut.org | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On 03.08.24 16:07, Heikki Linnakangas wrote:
> On 03/08/2024 14:04, Peter Eisentraut wrote:
>> I noticed (during [0]) to some uses of the function atol() seem 
>> inappropriate.  Either they assume that sizeof(long)==8 and so might 
>> truncate data if not, or they are gratuitous because the surrounding 
>> code does not use the long type.  This patch fixes these, by using 
>> atoll() or atoi() instead.  (There are still some atol() calls left 
>> after this, which seemed ok to me.)
>>
>> In the past, Windows didn't have atoll(), but the online documentation 
>> appears to indicate that this now works in VS 2015 and later, which is 
>> what we support at the moment.  The Cirrus CI passes.
> +1 except for this one:
> 
>> diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer 
>> b/src/interfaces/ecpg/preproc/ecpg.trailer
>> index b2aa44f36dd..8ac1c5c9eda 100644
>> --- a/src/interfaces/ecpg/preproc/ecpg.trailer
>> +++ b/src/interfaces/ecpg/preproc/ecpg.trailer
>> @@ -217,7 +217,7 @@ char_variable: cvariable
>>              enum ECPGttype type = p->type->type;
>>
>>              /* If we have just one character this is not a string */
>> -            if (atol(p->type->size) == 1)
>> +            if (atoi(p->type->size) == 1)
>>                      mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
>>              else
>>              {
I committed it without this hunk.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2024-08-10 07:10:16 | libpq minor TOCTOU violation | 
| Previous Message | Thomas Munro | 2024-08-10 03:52:23 | Re: On non-Windows, hard depend on uselocale(3) |