Fix modification of string literal by swprintf
Renlin Li
renlin.li@foss.arm.com
Thu Jun 15 09:05:00 GMT 2017
Yes, in my configuration, we enable the newlib-mb feature. And the executing path to
handle the trailing '0' is not consistent with how the digits is handled.
Thanks,
Renlin
On 15/06/17 09:00, Thomas Preudhomme wrote:
> Hi Renlin,
>
> Here's Silviu's answer:
>
> "This happens when --enable-newlib-mb is used (which wasn't in my test configuration).
>
> Unfortunately this complicates thing a lot and I have no easy fix for it.
> The best action at the moment would be a revert."
>
> Corinna, could you revert the patch for now?
>
> Sorry for the trouble. Best regards,
>
> Thomas
>
> On 14/06/17 12:05, Renlin Li wrote:
>> Hi there,
>>
>> It seems this patch cause few regressions on arm/aarch64 baremetal targets.
>>
>> libstdc++-v3:
>> FAIL: 21_strings/basic_string/numeric_conversions/wchar_t/dr1261.cc execution test
>> FAIL: 21_strings/basic_string/numeric_conversions/wchar_t/stof.cc execution test
>> FAIL: 21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
>> execution test
>> FAIL: 27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc execution test
>>
>> newlib:
>> FAIL: newlib.stdio/swprintf.c execution
>>
>> Regards,
>> Renlin
>>
>> On 09/06/17 14:32, Corinna Vinschen wrote:
>>> On Jun 8 13:15, Thomas Preudhomme wrote:
>>>> Please find his updated patch attached.
>>>>
>>>> Best regards,
>>>>
>>>> Thomas
>>>
>>>> >From ee96a273969b0bccd308b81bcdf37a6fdefa06f6 Mon Sep 17 00:00:00 2001
>>>> From: Silviu Baranga <silviu.baranga@arm.cm>
>>>> Date: Mon, 5 Jun 2017 09:54:42 +0100
>>>> Subject: [PATCH] Don't overread or write memory returned by _DTOA_R
>>>>
>>>> Don't over-read memory returned by _DTOA_R, and never write to it
>>>> since the result might be a string literal.
>>>>
>>>> For example, when doing:
>>>> swprintf(tt, 20, L"%.*f", 6, 0.0);
>>>>
>>>> we will get back "0".
>>>>
>>>> Instead, write the result returned by _DTOA_R to the output buffer.
>>>> After this, write the 0 chars directly to the the output buffer
>>>> (if there are any). This also has the (marginal) advantage that
>>>> we read/write less memory overall.
>>>
>>> Pushed.
>>>
>>>
>>> Thanks,
>>> Corinna
>>>
More information about the Newlib
mailing list