bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH] vasnprintf: Don't use %n on android
@ 2018-12-19  9:54 Hugo Beauzée-Luyssen
  2018-12-20  1:53 ` Bruno Haible
  0 siblings, 1 reply; 9+ messages in thread
From: Hugo Beauzée-Luyssen @ 2018-12-19  9:54 UTC (permalink / raw)
  To: bug-gnulib

12-14 19:10:02.633 F DEBUG   : pid: 31664, tid: 32389, name: VlcObject  >>> org.videolan.vlc <<<
12-14 19:10:02.633 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
12-14 19:10:02.633 F DEBUG   : Abort message: 'FORTIFY: %n not allowed on Android'
---
 lib/vasnprintf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index af3fcd1c7..e41d5f706 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -4874,7 +4874,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 # if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))        \
          && !defined __UCLIBC__)                                            \
         || (defined __APPLE__ && defined __MACH__)                          \
-        || (defined _WIN32 && ! defined __CYGWIN__))
+        || (defined _WIN32 && ! defined __CYGWIN__)                         \
+        || defined __ANDROID__)
                 fbp[1] = '%';
                 fbp[2] = 'n';
                 fbp[3] = '\0';
-- 
2.19.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] vasnprintf: Don't use %n on android
  2018-12-19  9:54 [PATCH] vasnprintf: Don't use %n on android Hugo Beauzée-Luyssen
@ 2018-12-20  1:53 ` Bruno Haible
  2019-01-08 13:22   ` Hugo Beauzée-Luyssen
  0 siblings, 1 reply; 9+ messages in thread
From: Bruno Haible @ 2018-12-20  1:53 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Hugo Beauzée-Luyssen

Hi,

Hugo Beauzée-Luyssen wrote:
> 12-14 19:10:02.633 F DEBUG   : pid: 31664, tid: 32389, name: VlcObject  >>> org.videolan.vlc <<<
> 12-14 19:10:02.633 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
> 12-14 19:10:02.633 F DEBUG   : Abort message: 'FORTIFY: %n not allowed on Android'

Indeed, %n in *printf is not allowed on Android, see
https://android.googlesource.com/platform/bionic/+/master/libc/stdio/vfprintf.cpp
https://android.googlesource.com/platform/bionic/+/master/docs/status.md

> diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
> index af3fcd1c7..e41d5f706 100644
> --- a/lib/vasnprintf.c
> +++ b/lib/vasnprintf.c
> @@ -4874,7 +4874,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
>  # if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))        \
>           && !defined __UCLIBC__)                                            \
>          || (defined __APPLE__ && defined __MACH__)                          \
> -        || (defined _WIN32 && ! defined __CYGWIN__))
> +        || (defined _WIN32 && ! defined __CYGWIN__)                         \
> +        || defined __ANDROID__)
>                  fbp[1] = '%';
>                  fbp[2] = 'n';
>                  fbp[3] = '\0';

The patch looks good at first sight. But when you look at the comments a
couple of lines before it, you see that one can avoid %n only
if snprintf behaves well enough. To this effect, can you please report
the configure results (from a *native* Android compilation, not a cross-
compilation) of these tests:

1 = checking whether printf supports size specifiers as in C99...
2 = checking whether printf supports 'long double' arguments...
3 = checking whether printf supports infinite 'double' arguments...
4 = checking whether printf supports infinite 'long double' arguments...
5 = checking whether printf supports the 'a' and 'A' directives...
6 = checking whether printf supports the 'F' directive...
7 = checking whether printf supports the 'n' directive...
8 = checking whether printf supports the 'ls' directive...
9 = checking whether printf supports POSIX/XSI format strings with positions...
10 = checking whether printf supports the grouping flag...
11 = checking whether printf supports the left-adjust flag correctly...
12 = checking whether printf supports the zero flag correctly...
13 = checking whether printf supports large precisions...
14 = checking whether printf survives out-of-memory conditions...
15 = checking for snprintf...
16 = checking whether snprintf truncates the result as in C99...
17 = checking whether snprintf returns a byte count as in C99...
18 = checking whether snprintf fully supports the 'n' directive...
19 = checking whether snprintf respects a size of 1...
20 = checking whether vsnprintf respects a zero size as in C99...

You should find these in the configure output of any package that
uses gnulib's 'vasnprintf' module. If you don't have one at hand,
create one using
  ./gnulib-tool --create-testdir --dir=testdir --single-configure vasnprintf

Thanks.

Bruno



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] vasnprintf: Don't use %n on android
  2018-12-20  1:53 ` Bruno Haible
@ 2019-01-08 13:22   ` Hugo Beauzée-Luyssen
  2019-01-21 15:58     ` Tim Rühsen
  0 siblings, 1 reply; 9+ messages in thread
From: Hugo Beauzée-Luyssen @ 2019-01-08 13:22 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib

On Thu, Dec 20, 2018, at 2:53 AM, Bruno Haible wrote:
> Hi,
> 
> Hugo Beauzée-Luyssen wrote:
> > 12-14 19:10:02.633 F DEBUG   : pid: 31664, tid: 32389, name: VlcObject  >>> org.videolan.vlc <<<
> > 12-14 19:10:02.633 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
> > 12-14 19:10:02.633 F DEBUG   : Abort message: 'FORTIFY: %n not allowed on Android'
> 
> Indeed, %n in *printf is not allowed on Android, see
> https://android.googlesource.com/platform/bionic/+/master/libc/stdio/vfprintf.cpp
> https://android.googlesource.com/platform/bionic/+/master/docs/status.md
> 
> > diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
> > index af3fcd1c7..e41d5f706 100644
> > --- a/lib/vasnprintf.c
> > +++ b/lib/vasnprintf.c
> > @@ -4874,7 +4874,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
> >  # if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))        \
> >           && !defined __UCLIBC__)                                            \
> >          || (defined __APPLE__ && defined __MACH__)                          \
> > -        || (defined _WIN32 && ! defined __CYGWIN__))
> > +        || (defined _WIN32 && ! defined __CYGWIN__)                         \
> > +        || defined __ANDROID__)
> >                  fbp[1] = '%';
> >                  fbp[2] = 'n';
> >                  fbp[3] = '\0';
> 
> The patch looks good at first sight. But when you look at the comments a
> couple of lines before it, you see that one can avoid %n only
> if snprintf behaves well enough. To this effect, can you please report
> the configure results (from a *native* Android compilation, not a cross-
> compilation) of these tests:
> 
> 1 = checking whether printf supports size specifiers as in C99...
> 2 = checking whether printf supports 'long double' arguments...
> 3 = checking whether printf supports infinite 'double' arguments...
> 4 = checking whether printf supports infinite 'long double' arguments...
> 5 = checking whether printf supports the 'a' and 'A' directives...
> 6 = checking whether printf supports the 'F' directive...
> 7 = checking whether printf supports the 'n' directive...
> 8 = checking whether printf supports the 'ls' directive...
> 9 = checking whether printf supports POSIX/XSI format strings with positions...
> 10 = checking whether printf supports the grouping flag...
> 11 = checking whether printf supports the left-adjust flag correctly...
> 12 = checking whether printf supports the zero flag correctly...
> 13 = checking whether printf supports large precisions...
> 14 = checking whether printf survives out-of-memory conditions...
> 15 = checking for snprintf...
> 16 = checking whether snprintf truncates the result as in C99...
> 17 = checking whether snprintf returns a byte count as in C99...
> 18 = checking whether snprintf fully supports the 'n' directive...
> 19 = checking whether snprintf respects a size of 1...
> 20 = checking whether vsnprintf respects a zero size as in C99...
> 
> You should find these in the configure output of any package that
> uses gnulib's 'vasnprintf' module. If you don't have one at hand,
> create one using
>   ./gnulib-tool --create-testdir --dir=testdir --single-configure vasnprintf
> 
> Thanks.
> 
> Bruno
> 

Hi,

I'm probably missing something, but for me this only seems to test for snprintf/printf/vasnprintf availability (including running configure in the generated test directory)

Regards,

-- 
  Hugo Beauzée-Luyssen
  hugo@beauzee.fr


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] vasnprintf: Don't use %n on android
  2019-01-08 13:22   ` Hugo Beauzée-Luyssen
@ 2019-01-21 15:58     ` Tim Rühsen
  2019-01-21 16:00       ` Hugo Beauzée-Luyssen
  0 siblings, 1 reply; 9+ messages in thread
From: Tim Rühsen @ 2019-01-21 15:58 UTC (permalink / raw)
  To: Hugo Beauzée-Luyssen, Bruno Haible, bug-gnulib


[-- Attachment #1.1: Type: text/plain, Size: 3761 bytes --]

On 1/8/19 2:22 PM, Hugo Beauzée-Luyssen wrote:
> On Thu, Dec 20, 2018, at 2:53 AM, Bruno Haible wrote:
>> Hi,
>>
>> Hugo Beauzée-Luyssen wrote:
>>> 12-14 19:10:02.633 F DEBUG   : pid: 31664, tid: 32389, name: VlcObject  >>> org.videolan.vlc <<<
>>> 12-14 19:10:02.633 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
>>> 12-14 19:10:02.633 F DEBUG   : Abort message: 'FORTIFY: %n not allowed on Android'
>>
>> Indeed, %n in *printf is not allowed on Android, see
>> https://android.googlesource.com/platform/bionic/+/master/libc/stdio/vfprintf.cpp
>> https://android.googlesource.com/platform/bionic/+/master/docs/status.md
>>
>>> diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
>>> index af3fcd1c7..e41d5f706 100644
>>> --- a/lib/vasnprintf.c
>>> +++ b/lib/vasnprintf.c
>>> @@ -4874,7 +4874,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
>>>  # if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))        \
>>>           && !defined __UCLIBC__)                                            \
>>>          || (defined __APPLE__ && defined __MACH__)                          \
>>> -        || (defined _WIN32 && ! defined __CYGWIN__))
>>> +        || (defined _WIN32 && ! defined __CYGWIN__)                         \
>>> +        || defined __ANDROID__)
>>>                  fbp[1] = '%';
>>>                  fbp[2] = 'n';
>>>                  fbp[3] = '\0';
>>
>> The patch looks good at first sight. But when you look at the comments a
>> couple of lines before it, you see that one can avoid %n only
>> if snprintf behaves well enough. To this effect, can you please report
>> the configure results (from a *native* Android compilation, not a cross-
>> compilation) of these tests:
>>
>> 1 = checking whether printf supports size specifiers as in C99...
>> 2 = checking whether printf supports 'long double' arguments...
>> 3 = checking whether printf supports infinite 'double' arguments...
>> 4 = checking whether printf supports infinite 'long double' arguments...
>> 5 = checking whether printf supports the 'a' and 'A' directives...
>> 6 = checking whether printf supports the 'F' directive...
>> 7 = checking whether printf supports the 'n' directive...
>> 8 = checking whether printf supports the 'ls' directive...
>> 9 = checking whether printf supports POSIX/XSI format strings with positions...
>> 10 = checking whether printf supports the grouping flag...
>> 11 = checking whether printf supports the left-adjust flag correctly...
>> 12 = checking whether printf supports the zero flag correctly...
>> 13 = checking whether printf supports large precisions...
>> 14 = checking whether printf survives out-of-memory conditions...
>> 15 = checking for snprintf...
>> 16 = checking whether snprintf truncates the result as in C99...
>> 17 = checking whether snprintf returns a byte count as in C99...
>> 18 = checking whether snprintf fully supports the 'n' directive...
>> 19 = checking whether snprintf respects a size of 1...
>> 20 = checking whether vsnprintf respects a zero size as in C99...
>>
>> You should find these in the configure output of any package that
>> uses gnulib's 'vasnprintf' module. If you don't have one at hand,
>> create one using
>>   ./gnulib-tool --create-testdir --dir=testdir --single-configure vasnprintf
>>
>> Thanks.
>>
>> Bruno
>>
> 
> Hi,
> 
> I'm probably missing something, but for me this only seems to test for snprintf/printf/vasnprintf availability (including running configure in the generated test directory)

I would really like to see the patch in gnulib as soon as possible.

@hugo If it's not too much hassle, could you please provide the
requested information ?

Regards, Tim


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] vasnprintf: Don't use %n on android
  2019-01-21 15:58     ` Tim Rühsen
@ 2019-01-21 16:00       ` Hugo Beauzée-Luyssen
  2019-01-21 16:11         ` Tim Rühsen
  0 siblings, 1 reply; 9+ messages in thread
From: Hugo Beauzée-Luyssen @ 2019-01-21 16:00 UTC (permalink / raw)
  To: Tim Rühsen, Bruno Haible, bug-gnulib

On Mon, Jan 21, 2019, at 4:58 PM, Tim Rühsen wrote:
> On 1/8/19 2:22 PM, Hugo Beauzée-Luyssen wrote:
> > On Thu, Dec 20, 2018, at 2:53 AM, Bruno Haible wrote:
> >> Hi,
> >>
> >> Hugo Beauzée-Luyssen wrote:
> >>> 12-14 19:10:02.633 F DEBUG   : pid: 31664, tid: 32389, name: VlcObject  >>> org.videolan.vlc <<<
> >>> 12-14 19:10:02.633 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
> >>> 12-14 19:10:02.633 F DEBUG   : Abort message: 'FORTIFY: %n not allowed on Android'
> >>
> >> Indeed, %n in *printf is not allowed on Android, see
> >> https://android.googlesource.com/platform/bionic/+/master/libc/stdio/vfprintf.cpp
> >> https://android.googlesource.com/platform/bionic/+/master/docs/status.md
> >>
> >>> diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
> >>> index af3fcd1c7..e41d5f706 100644
> >>> --- a/lib/vasnprintf.c
> >>> +++ b/lib/vasnprintf.c
> >>> @@ -4874,7 +4874,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
> >>>  # if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))        \
> >>>           && !defined __UCLIBC__)                                            \
> >>>          || (defined __APPLE__ && defined __MACH__)                          \
> >>> -        || (defined _WIN32 && ! defined __CYGWIN__))
> >>> +        || (defined _WIN32 && ! defined __CYGWIN__)                         \
> >>> +        || defined __ANDROID__)
> >>>                  fbp[1] = '%';
> >>>                  fbp[2] = 'n';
> >>>                  fbp[3] = '\0';
> >>
> >> The patch looks good at first sight. But when you look at the comments a
> >> couple of lines before it, you see that one can avoid %n only
> >> if snprintf behaves well enough. To this effect, can you please report
> >> the configure results (from a *native* Android compilation, not a cross-
> >> compilation) of these tests:
> >>
> >> 1 = checking whether printf supports size specifiers as in C99...
> >> 2 = checking whether printf supports 'long double' arguments...
> >> 3 = checking whether printf supports infinite 'double' arguments...
> >> 4 = checking whether printf supports infinite 'long double' arguments...
> >> 5 = checking whether printf supports the 'a' and 'A' directives...
> >> 6 = checking whether printf supports the 'F' directive...
> >> 7 = checking whether printf supports the 'n' directive...
> >> 8 = checking whether printf supports the 'ls' directive...
> >> 9 = checking whether printf supports POSIX/XSI format strings with positions...
> >> 10 = checking whether printf supports the grouping flag...
> >> 11 = checking whether printf supports the left-adjust flag correctly...
> >> 12 = checking whether printf supports the zero flag correctly...
> >> 13 = checking whether printf supports large precisions...
> >> 14 = checking whether printf survives out-of-memory conditions...
> >> 15 = checking for snprintf...
> >> 16 = checking whether snprintf truncates the result as in C99...
> >> 17 = checking whether snprintf returns a byte count as in C99...
> >> 18 = checking whether snprintf fully supports the 'n' directive...
> >> 19 = checking whether snprintf respects a size of 1...
> >> 20 = checking whether vsnprintf respects a zero size as in C99...
> >>
> >> You should find these in the configure output of any package that
> >> uses gnulib's 'vasnprintf' module. If you don't have one at hand,
> >> create one using
> >>   ./gnulib-tool --create-testdir --dir=testdir --single-configure vasnprintf
> >>
> >> Thanks.
> >>
> >> Bruno
> >>
> > 
> > Hi,
> > 
> > I'm probably missing something, but for me this only seems to test for snprintf/printf/vasnprintf availability (including running configure in the generated test directory)
> 
> I would really like to see the patch in gnulib as soon as possible.
> 
> @hugo If it's not too much hassle, could you please provide the
> requested information ?
> 
> Regards, Tim
> 

Hi,

I'd love to, but I failed to fetch those so far. The provided command line didn't return any valuable information, and simply tested for the presence of various printf family function.

Regards,

-- 
  Hugo Beauzée-Luyssen
  hugo@beauzee.fr


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] vasnprintf: Don't use %n on android
  2019-01-21 16:00       ` Hugo Beauzée-Luyssen
@ 2019-01-21 16:11         ` Tim Rühsen
  2019-01-21 16:51           ` Hugo Beauzée-Luyssen
  0 siblings, 1 reply; 9+ messages in thread
From: Tim Rühsen @ 2019-01-21 16:11 UTC (permalink / raw)
  To: Hugo Beauzée-Luyssen, Bruno Haible, bug-gnulib


[-- Attachment #1.1: Type: text/plain, Size: 4886 bytes --]

On 1/21/19 5:00 PM, Hugo Beauzée-Luyssen wrote:
> On Mon, Jan 21, 2019, at 4:58 PM, Tim Rühsen wrote:
>> On 1/8/19 2:22 PM, Hugo Beauzée-Luyssen wrote:
>>> On Thu, Dec 20, 2018, at 2:53 AM, Bruno Haible wrote:
>>>> Hi,
>>>>
>>>> Hugo Beauzée-Luyssen wrote:
>>>>> 12-14 19:10:02.633 F DEBUG   : pid: 31664, tid: 32389, name: VlcObject  >>> org.videolan.vlc <<<
>>>>> 12-14 19:10:02.633 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
>>>>> 12-14 19:10:02.633 F DEBUG   : Abort message: 'FORTIFY: %n not allowed on Android'
>>>>
>>>> Indeed, %n in *printf is not allowed on Android, see
>>>> https://android.googlesource.com/platform/bionic/+/master/libc/stdio/vfprintf.cpp
>>>> https://android.googlesource.com/platform/bionic/+/master/docs/status.md
>>>>
>>>>> diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
>>>>> index af3fcd1c7..e41d5f706 100644
>>>>> --- a/lib/vasnprintf.c
>>>>> +++ b/lib/vasnprintf.c
>>>>> @@ -4874,7 +4874,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
>>>>>  # if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))        \
>>>>>           && !defined __UCLIBC__)                                            \
>>>>>          || (defined __APPLE__ && defined __MACH__)                          \
>>>>> -        || (defined _WIN32 && ! defined __CYGWIN__))
>>>>> +        || (defined _WIN32 && ! defined __CYGWIN__)                         \
>>>>> +        || defined __ANDROID__)
>>>>>                  fbp[1] = '%';
>>>>>                  fbp[2] = 'n';
>>>>>                  fbp[3] = '\0';
>>>>
>>>> The patch looks good at first sight. But when you look at the comments a
>>>> couple of lines before it, you see that one can avoid %n only
>>>> if snprintf behaves well enough. To this effect, can you please report
>>>> the configure results (from a *native* Android compilation, not a cross-
>>>> compilation) of these tests:
>>>>
>>>> 1 = checking whether printf supports size specifiers as in C99...
>>>> 2 = checking whether printf supports 'long double' arguments...
>>>> 3 = checking whether printf supports infinite 'double' arguments...
>>>> 4 = checking whether printf supports infinite 'long double' arguments...
>>>> 5 = checking whether printf supports the 'a' and 'A' directives...
>>>> 6 = checking whether printf supports the 'F' directive...
>>>> 7 = checking whether printf supports the 'n' directive...
>>>> 8 = checking whether printf supports the 'ls' directive...
>>>> 9 = checking whether printf supports POSIX/XSI format strings with positions...
>>>> 10 = checking whether printf supports the grouping flag...
>>>> 11 = checking whether printf supports the left-adjust flag correctly...
>>>> 12 = checking whether printf supports the zero flag correctly...
>>>> 13 = checking whether printf supports large precisions...
>>>> 14 = checking whether printf survives out-of-memory conditions...
>>>> 15 = checking for snprintf...
>>>> 16 = checking whether snprintf truncates the result as in C99...
>>>> 17 = checking whether snprintf returns a byte count as in C99...
>>>> 18 = checking whether snprintf fully supports the 'n' directive...
>>>> 19 = checking whether snprintf respects a size of 1...
>>>> 20 = checking whether vsnprintf respects a zero size as in C99...
>>>>
>>>> You should find these in the configure output of any package that
>>>> uses gnulib's 'vasnprintf' module. If you don't have one at hand,
>>>> create one using
>>>>   ./gnulib-tool --create-testdir --dir=testdir --single-configure vasnprintf
>>>>
>>>> Thanks.
>>>>
>>>> Bruno
>>>>
>>>
>>> Hi,
>>>
>>> I'm probably missing something, but for me this only seems to test for snprintf/printf/vasnprintf availability (including running configure in the generated test directory)
>>
>> I would really like to see the patch in gnulib as soon as possible.
>>
>> @hugo If it's not too much hassle, could you please provide the
>> requested information ?
>>
>> Regards, Tim
>>
> 
> Hi,
> 
> I'd love to, but I failed to fetch those so far. The provided command line didn't return any valuable information, and simply tested for the presence of various printf family function.
> 
> Regards,

So you cd'ed into testdir and run `./configure` !?

I also don't see much here (Debian unstable):

$ grep -A1 -i 'checking.*printf' config.log
configure:6305: checking for vasnprintf
configure:6305: result: no
configure:6305: checking for snprintf
configure:6305: result: yes
--
configure:8450: checking whether snprintf returns a byte count as in C99
configure:8548: result: yes
configure:8559: checking for snprintf
configure:8559: result: yes
--
configure:8568: checking whether _snprintf is declared
configure:8568: result: no

What does that grep look for you ?

@Bruno Is there something missing ?

Regards, Tim


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] vasnprintf: Don't use %n on android
  2019-01-21 16:11         ` Tim Rühsen
@ 2019-01-21 16:51           ` Hugo Beauzée-Luyssen
  2019-01-23  0:25             ` Bruno Haible
  0 siblings, 1 reply; 9+ messages in thread
From: Hugo Beauzée-Luyssen @ 2019-01-21 16:51 UTC (permalink / raw)
  To: Tim Rühsen, Bruno Haible, bug-gnulib

On Mon, Jan 21, 2019, at 5:11 PM, Tim Rühsen wrote:
> On 1/21/19 5:00 PM, Hugo Beauzée-Luyssen wrote:
> > On Mon, Jan 21, 2019, at 4:58 PM, Tim Rühsen wrote:
> >> On 1/8/19 2:22 PM, Hugo Beauzée-Luyssen wrote:
> >>> On Thu, Dec 20, 2018, at 2:53 AM, Bruno Haible wrote:
> >>>> Hi,
> >>>>
> >>>> Hugo Beauzée-Luyssen wrote:
> >>>>> 12-14 19:10:02.633 F DEBUG   : pid: 31664, tid: 32389, name: VlcObject  >>> org.videolan.vlc <<<
> >>>>> 12-14 19:10:02.633 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
> >>>>> 12-14 19:10:02.633 F DEBUG   : Abort message: 'FORTIFY: %n not allowed on Android'
> >>>>
> >>>> Indeed, %n in *printf is not allowed on Android, see
> >>>> https://android.googlesource.com/platform/bionic/+/master/libc/stdio/vfprintf.cpp
> >>>> https://android.googlesource.com/platform/bionic/+/master/docs/status.md
> >>>>
> >>>>> diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
> >>>>> index af3fcd1c7..e41d5f706 100644
> >>>>> --- a/lib/vasnprintf.c
> >>>>> +++ b/lib/vasnprintf.c
> >>>>> @@ -4874,7 +4874,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
> >>>>>  # if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))        \
> >>>>>           && !defined __UCLIBC__)                                            \
> >>>>>          || (defined __APPLE__ && defined __MACH__)                          \
> >>>>> -        || (defined _WIN32 && ! defined __CYGWIN__))
> >>>>> +        || (defined _WIN32 && ! defined __CYGWIN__)                         \
> >>>>> +        || defined __ANDROID__)
> >>>>>                  fbp[1] = '%';
> >>>>>                  fbp[2] = 'n';
> >>>>>                  fbp[3] = '\0';
> >>>>
> >>>> The patch looks good at first sight. But when you look at the comments a
> >>>> couple of lines before it, you see that one can avoid %n only
> >>>> if snprintf behaves well enough. To this effect, can you please report
> >>>> the configure results (from a *native* Android compilation, not a cross-
> >>>> compilation) of these tests:
> >>>>
> >>>> 1 = checking whether printf supports size specifiers as in C99...
> >>>> 2 = checking whether printf supports 'long double' arguments...
> >>>> 3 = checking whether printf supports infinite 'double' arguments...
> >>>> 4 = checking whether printf supports infinite 'long double' arguments...
> >>>> 5 = checking whether printf supports the 'a' and 'A' directives...
> >>>> 6 = checking whether printf supports the 'F' directive...
> >>>> 7 = checking whether printf supports the 'n' directive...
> >>>> 8 = checking whether printf supports the 'ls' directive...
> >>>> 9 = checking whether printf supports POSIX/XSI format strings with positions...
> >>>> 10 = checking whether printf supports the grouping flag...
> >>>> 11 = checking whether printf supports the left-adjust flag correctly...
> >>>> 12 = checking whether printf supports the zero flag correctly...
> >>>> 13 = checking whether printf supports large precisions...
> >>>> 14 = checking whether printf survives out-of-memory conditions...
> >>>> 15 = checking for snprintf...
> >>>> 16 = checking whether snprintf truncates the result as in C99...
> >>>> 17 = checking whether snprintf returns a byte count as in C99...
> >>>> 18 = checking whether snprintf fully supports the 'n' directive...
> >>>> 19 = checking whether snprintf respects a size of 1...
> >>>> 20 = checking whether vsnprintf respects a zero size as in C99...
> >>>>
> >>>> You should find these in the configure output of any package that
> >>>> uses gnulib's 'vasnprintf' module. If you don't have one at hand,
> >>>> create one using
> >>>>   ./gnulib-tool --create-testdir --dir=testdir --single-configure vasnprintf
> >>>>
> >>>> Thanks.
> >>>>
> >>>> Bruno
> >>>>
> >>>
> >>> Hi,
> >>>
> >>> I'm probably missing something, but for me this only seems to test for snprintf/printf/vasnprintf availability (including running configure in the generated test directory)
> >>
> >> I would really like to see the patch in gnulib as soon as possible.
> >>
> >> @hugo If it's not too much hassle, could you please provide the
> >> requested information ?
> >>
> >> Regards, Tim
> >>
> > 
> > Hi,
> > 
> > I'd love to, but I failed to fetch those so far. The provided command line didn't return any valuable information, and simply tested for the presence of various printf family function.
> > 
> > Regards,
> 
> So you cd'ed into testdir and run `./configure` !?
> 

Yes

> I also don't see much here (Debian unstable):
> 
> $ grep -A1 -i 'checking.*printf' config.log
> configure:6305: checking for vasnprintf
> configure:6305: result: no
> configure:6305: checking for snprintf
> configure:6305: result: yes
> --
> configure:8450: checking whether snprintf returns a byte count as in C99
> configure:8548: result: yes
> configure:8559: checking for snprintf
> configure:8559: result: yes
> --
> configure:8568: checking whether _snprintf is declared
> configure:8568: result: no
> 
> What does that grep look for you ?

$ grep -A1 'checking .*printf' config.log
configure:6326: checking for vasnprintf
configure:6326: gcc -o conftest -g -O2   conftest.c  >&5
--
configure:6326: checking for snprintf
configure:6326: gcc -o conftest -g -O2   conftest.c  >&5
--
configure:8471: checking whether snprintf returns a byte count as in C99
configure:8558: gcc -o conftest -g -O2   conftest.c  >&5
--
configure:8580: checking for snprintf
configure:8580: result: yes
--
configure:8589: checking whether _snprintf is declared
configure:8589: gcc -c -g -O2  conftest.c >&5


FWIW, I ran the test using termux on a chromebook, since that's the only way I know of doing a native android compile (beside cross compiling an android compiler, but I'd like to avoid having doing that if possible) 

> 
> @Bruno Is there something missing ?
> 
> Regards, Tim
> 
> Email had 1 attachment:
> + signature.asc
>   1k (application/pgp-signature)


-- 
  Hugo Beauzée-Luyssen
  hugo@beauzee.fr


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] vasnprintf: Don't use %n on android
  2019-01-21 16:51           ` Hugo Beauzée-Luyssen
@ 2019-01-23  0:25             ` Bruno Haible
  2019-01-23 18:38               ` Tim Rühsen
  0 siblings, 1 reply; 9+ messages in thread
From: Bruno Haible @ 2019-01-23  0:25 UTC (permalink / raw)
  To: Hugo Beauzée-Luyssen; +Cc: Tim Rühsen, bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 3254 bytes --]

Hi Tim and Hugo,

> > I also don't see much here (Debian unstable):
> > 
> > $ grep -A1 -i 'checking.*printf' config.log
> > configure:6305: checking for vasnprintf
> > configure:6305: result: no
> > configure:6305: checking for snprintf
> > configure:6305: result: yes
> > --
> > configure:8450: checking whether snprintf returns a byte count as in C99
> > configure:8548: result: yes
> > configure:8559: checking for snprintf
> > configure:8559: result: yes
> > --
> > configure:8568: checking whether _snprintf is declared
> > configure:8568: result: no
> > 
> > What does that grep look for you ?
> 
> $ grep -A1 'checking .*printf' config.log
> configure:6326: checking for vasnprintf
> configure:6326: gcc -o conftest -g -O2   conftest.c  >&5
> --
> configure:6326: checking for snprintf
> configure:6326: gcc -o conftest -g -O2   conftest.c  >&5
> --
> configure:8471: checking whether snprintf returns a byte count as in C99
> configure:8558: gcc -o conftest -g -O2   conftest.c  >&5
> --
> configure:8580: checking for snprintf
> configure:8580: result: yes
> --
> configure:8589: checking whether _snprintf is declared
> configure:8589: gcc -c -g -O2  conftest.c >&5

I did these steps:
1) Create a testdir
   ./gnulib-tool --create-testdir --dir=../testdir-printf-posix --single-configure \
                 dprintf-posix fprintf-posix printf-posix snprintf-posix \
                 sprintf-posix vasnprintf-posix vasprintf-posix vdprintf-posix \
                 vfprintf-posix vprintf-posix vsnprintf-posix vsprintf-posix
2) Tarred the resulting directory
3) Transfered it to the device (Android 4.3 with 'Terminal IDE' app in my case),
4) Unpacked it there,
5) configured it,
6) Copy&pasted the configure output.

The configure output contains the lines

checking whether printf supports size specifiers as in C99... yes
checking whether printf supports 'long double' arguments... yes
checking whether printf supports infinite 'double' arguments... no
checking whether printf supports infinite 'long double' arguments... no
checking whether printf supports the 'a' and 'A' directives... no
checking whether printf supports the 'F' directive... no
checking whether printf supports the 'n' directive... no
checking whether printf supports the 'ls' directive... no
checking whether printf supports POSIX/XSI format strings with positions... yes
checking whether printf supports the grouping flag... no
checking whether printf supports the left-adjust flag correctly... yes
checking whether printf supports the zero flag correctly... no
checking whether printf supports large precisions... yes
checking whether printf survives out-of-memory conditions... no
checking for snprintf... yes
checking whether snprintf truncates the result as in C99... yes
checking whether snprintf returns a byte count as in C99... yes
checking whether snprintf fully supports the 'n' directive... no
checking whether snprintf respects a size of 1... yes
checking whether vsnprintf respects a zero size as in C99... yes

With this, I am in the position to update the results in printf.m4, and
even add cross-compilation guesses.

Since snprintf is behaving well enough, we can disable the use of %n,
like you suggested.

Done through the attached patches.

Bruno



[-- Attachment #2: 0001-printf-Support-cross-compilation-to-Android.patch --]
[-- Type: text/x-patch, Size: 19749 bytes --]

From 5447f440ef927283e63d5a1290dab292f7af1aea Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Tue, 22 Jan 2019 22:44:49 +0100
Subject: [PATCH 1/2] *printf: Support cross-compilation to Android.

* m4/printf.m4: Add cross-compilation guesses for Android.
---
 ChangeLog    |   5 ++
 m4/printf.m4 | 190 ++++++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 120 insertions(+), 75 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c496144..e3ec57b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-22  Bruno Haible  <bruno@clisp.org>
+
+	*printf: Support cross-compilation to Android.
+	* m4/printf.m4: Add cross-compilation guesses for Android.
+
 2019-01-21  Bruno Haible  <bruno@clisp.org>
 
 	diacrit: Mark deprecated.
diff --git a/m4/printf.m4 b/m4/printf.m4
index 1db13bf..cbf6ae4 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -1,4 +1,4 @@
-# printf.m4 serial 59
+# printf.m4 serial 60
 dnl Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -79,6 +79,8 @@ changequote(,)dnl
            netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
                                  gl_cv_func_printf_sizes_c99="guessing no";;
            netbsd*)              gl_cv_func_printf_sizes_c99="guessing yes";;
+                                 # Guess yes on Android.
+           linux*-android*)      gl_cv_func_printf_sizes_c99="guessing yes";;
 changequote([,])dnl
                                  # Guess yes on MSVC, no on mingw.
            mingw*)               AC_EGREP_CPP([Known], [
@@ -132,17 +134,20 @@ int main ()
         [gl_cv_func_printf_long_double=yes],
         [gl_cv_func_printf_long_double=no],
         [case "$host_os" in
-           beos*)  gl_cv_func_printf_long_double="guessing no";;
-                   # Guess yes on MSVC, no on mingw.
-           mingw*) AC_EGREP_CPP([Known], [
+                            # Guess no on BeOS.
+           beos*)           gl_cv_func_printf_long_double="guessing no";;
+                            # Guess yes on Android.
+           linux*-android*) gl_cv_func_printf_long_double="guessing yes";;
+                            # Guess yes on MSVC, no on mingw.
+           mingw*)          AC_EGREP_CPP([Known], [
 #ifdef _MSC_VER
  Known
 #endif
-                     ],
-                     [gl_cv_func_printf_long_double="guessing yes"],
-                     [gl_cv_func_printf_long_double="guessing no"])
-                   ;;
-           *)      gl_cv_func_printf_long_double="guessing yes";;
+                              ],
+                              [gl_cv_func_printf_long_double="guessing yes"],
+                              [gl_cv_func_printf_long_double="guessing no"])
+                            ;;
+           *)               gl_cv_func_printf_long_double="guessing yes";;
          esac
         ])
     ])
@@ -250,6 +255,8 @@ changequote(,)dnl
            netbsd*)              gl_cv_func_printf_infinite="guessing yes";;
                                  # Guess yes on BeOS.
            beos*)                gl_cv_func_printf_infinite="guessing yes";;
+                                 # Guess no on Android.
+           linux*-android*)      gl_cv_func_printf_infinite="guessing no";;
 changequote([,])dnl
                                  # Guess yes on MSVC, no on mingw.
            mingw*)               AC_EGREP_CPP([Known], [
@@ -456,6 +463,8 @@ changequote(,)dnl
                                          # Guess yes on HP-UX >= 11.
                    hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
                    hpux*)                gl_cv_func_printf_infinite_long_double="guessing yes";;
+                                         # Guess no on Android.
+                   linux*-android*)      gl_cv_func_printf_infinite_long_double="guessing no";;
 changequote([,])dnl
                                          # Guess yes on MSVC, no on mingw.
                    mingw*)               AC_EGREP_CPP([Known], [
@@ -566,6 +575,8 @@ int main ()
                [gl_cv_func_printf_directive_a="guessing yes"],
                [gl_cv_func_printf_directive_a="guessing no"])
              ;;
+                                 # Guess no on Android.
+           linux*-android*)      gl_cv_func_printf_directive_a="guessing no";;
                                  # Guess no on native Windows.
            mingw*)               gl_cv_func_printf_directive_a="guessing no";;
                                  # If we don't know, assume the worst.
@@ -623,6 +634,8 @@ changequote(,)dnl
                                  # Guess yes on Solaris >= 2.10.
            solaris2.[1-9][0-9]*) gl_cv_func_printf_directive_f="guessing yes";;
            solaris*)             gl_cv_func_printf_directive_f="guessing no";;
+                                 # Guess no on Android.
+           linux*-android*)      gl_cv_func_printf_directive_f="guessing no";;
 changequote([,])dnl
                                  # Guess yes on MSVC, no on mingw.
            mingw*)               AC_EGREP_CPP([Known], [
@@ -688,9 +701,11 @@ int main ()
         [gl_cv_func_printf_directive_n=yes],
         [gl_cv_func_printf_directive_n=no],
         [case "$host_os" in
-                   # Guess no on native Windows.
-           mingw*) gl_cv_func_printf_directive_n="guessing no";;
-           *)      gl_cv_func_printf_directive_n="guessing yes";;
+                            # Guess no on Android.
+           linux*-android*) gl_cv_func_printf_directive_n="guessing no";;
+                            # Guess no on native Windows.
+           mingw*)          gl_cv_func_printf_directive_n="guessing no";;
+           *)               gl_cv_func_printf_directive_n="guessing yes";;
          esac
         ])
     ])
@@ -766,14 +781,16 @@ int main ()
         [
 changequote(,)dnl
          case "$host_os" in
-           openbsd*)       gl_cv_func_printf_directive_ls="guessing no";;
-           irix*)          gl_cv_func_printf_directive_ls="guessing no";;
-           solaris*)       gl_cv_func_printf_directive_ls="guessing no";;
-           cygwin*)        gl_cv_func_printf_directive_ls="guessing no";;
-           beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
-                           # Guess yes on native Windows.
-           mingw*)         gl_cv_func_printf_directive_ls="guessing yes";;
-           *)              gl_cv_func_printf_directive_ls="guessing yes";;
+           openbsd*)        gl_cv_func_printf_directive_ls="guessing no";;
+           irix*)           gl_cv_func_printf_directive_ls="guessing no";;
+           solaris*)        gl_cv_func_printf_directive_ls="guessing no";;
+           cygwin*)         gl_cv_func_printf_directive_ls="guessing no";;
+           beos* | haiku*)  gl_cv_func_printf_directive_ls="guessing no";;
+                            # Guess no on Android.
+           linux*-android*) gl_cv_func_printf_directive_ls="guessing no";;
+                            # Guess yes on native Windows.
+           mingw*)          gl_cv_func_printf_directive_ls="guessing yes";;
+           *)               gl_cv_func_printf_directive_ls="guessing yes";;
          esac
 changequote([,])dnl
         ])
@@ -810,11 +827,13 @@ int main ()
 changequote(,)dnl
          case "$host_os" in
            netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
-                         gl_cv_func_printf_positions="guessing no";;
-           beos*)        gl_cv_func_printf_positions="guessing no";;
-                         # Guess no on native Windows.
-           mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
-           *)            gl_cv_func_printf_positions="guessing yes";;
+                            gl_cv_func_printf_positions="guessing no";;
+           beos*)           gl_cv_func_printf_positions="guessing no";;
+                            # Guess yes on Android.
+           linux*-android*) gl_cv_func_printf_positions="guessing yes";;
+                            # Guess no on native Windows.
+           mingw* | pw*)    gl_cv_func_printf_positions="guessing no";;
+           *)               gl_cv_func_printf_positions="guessing yes";;
          esac
 changequote([,])dnl
         ])
@@ -849,11 +868,13 @@ int main ()
         [
 changequote(,)dnl
          case "$host_os" in
-           cygwin*)      gl_cv_func_printf_flag_grouping="guessing no";;
-           netbsd*)      gl_cv_func_printf_flag_grouping="guessing no";;
-                         # Guess no on native Windows.
-           mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
-           *)            gl_cv_func_printf_flag_grouping="guessing yes";;
+           cygwin*)         gl_cv_func_printf_flag_grouping="guessing no";;
+           netbsd*)         gl_cv_func_printf_flag_grouping="guessing no";;
+                            # Guess no on Android.
+           linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";;
+                            # Guess no on native Windows.
+           mingw* | pw*)    gl_cv_func_printf_flag_grouping="guessing no";;
+           *)               gl_cv_func_printf_flag_grouping="guessing yes";;
          esac
 changequote([,])dnl
         ])
@@ -890,14 +911,16 @@ int main ()
         [
 changequote(,)dnl
          case "$host_os" in
-                    # Guess yes on HP-UX 11.
-           hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
-                    # Guess no on HP-UX 10 and older.
-           hpux*)   gl_cv_func_printf_flag_leftadjust="guessing no";;
-                    # Guess yes on native Windows.
-           mingw*)  gl_cv_func_printf_flag_leftadjust="guessing yes";;
-                    # Guess yes otherwise.
-           *)       gl_cv_func_printf_flag_leftadjust="guessing yes";;
+                            # Guess yes on HP-UX 11.
+           hpux11*)         gl_cv_func_printf_flag_leftadjust="guessing yes";;
+                            # Guess no on HP-UX 10 and older.
+           hpux*)           gl_cv_func_printf_flag_leftadjust="guessing no";;
+                            # Guess yes on Android.
+           linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
+                            # Guess yes on native Windows.
+           mingw*)          gl_cv_func_printf_flag_leftadjust="guessing yes";;
+                            # Guess yes otherwise.
+           *)               gl_cv_func_printf_flag_leftadjust="guessing yes";;
          esac
 changequote([,])dnl
         ])
@@ -935,14 +958,16 @@ int main ()
         [
 changequote(,)dnl
          case "$host_os" in
-                          # Guess yes on glibc systems.
-           *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
-                          # Guess yes on BeOS.
-           beos*)         gl_cv_func_printf_flag_zero="guessing yes";;
-                          # Guess no on native Windows.
-           mingw*)        gl_cv_func_printf_flag_zero="guessing no";;
-                          # If we don't know, assume the worst.
-           *)             gl_cv_func_printf_flag_zero="guessing no";;
+                            # Guess yes on glibc systems.
+           *-gnu* | gnu*)   gl_cv_func_printf_flag_zero="guessing yes";;
+                            # Guess yes on BeOS.
+           beos*)           gl_cv_func_printf_flag_zero="guessing yes";;
+                            # Guess no on Android.
+           linux*-android*) gl_cv_func_printf_flag_zero="guessing no";;
+                            # Guess no on native Windows.
+           mingw*)          gl_cv_func_printf_flag_zero="guessing no";;
+                            # If we don't know, assume the worst.
+           *)               gl_cv_func_printf_flag_zero="guessing no";;
          esac
 changequote([,])dnl
         ])
@@ -995,10 +1020,12 @@ int main ()
 changequote(,)dnl
          case "$host_os" in
            # Guess no only on Solaris, native Windows, and BeOS systems.
-           solaris*)     gl_cv_func_printf_precision="guessing no" ;;
-           mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
-           beos*)        gl_cv_func_printf_precision="guessing no" ;;
-           *)            gl_cv_func_printf_precision="guessing yes" ;;
+           solaris*)        gl_cv_func_printf_precision="guessing no" ;;
+           mingw* | pw*)    gl_cv_func_printf_precision="guessing no" ;;
+           beos*)           gl_cv_func_printf_precision="guessing no" ;;
+                            # Guess yes on Android.
+           linux*-android*) gl_cv_func_printf_precision="guessing yes" ;;
+           *)               gl_cv_func_printf_precision="guessing yes" ;;
          esac
 changequote([,])dnl
         ])
@@ -1095,28 +1122,30 @@ changequote([,])dnl
       if test "$gl_cv_func_printf_enomem" = "guessing no"; then
 changequote(,)dnl
         case "$host_os" in
-                         # Guess yes on glibc systems.
-          *-gnu* | gnu*) gl_cv_func_printf_enomem="guessing yes";;
-                         # Guess yes on Solaris.
-          solaris*)      gl_cv_func_printf_enomem="guessing yes";;
-                         # Guess yes on AIX.
-          aix*)          gl_cv_func_printf_enomem="guessing yes";;
-                         # Guess yes on HP-UX/hppa.
-          hpux*)         case "$host_cpu" in
-                           hppa*) gl_cv_func_printf_enomem="guessing yes";;
-                           *)     gl_cv_func_printf_enomem="guessing no";;
-                         esac
-                         ;;
-                         # Guess yes on IRIX.
-          irix*)         gl_cv_func_printf_enomem="guessing yes";;
-                         # Guess yes on OSF/1.
-          osf*)          gl_cv_func_printf_enomem="guessing yes";;
-                         # Guess yes on BeOS.
-          beos*)         gl_cv_func_printf_enomem="guessing yes";;
-                         # Guess yes on Haiku.
-          haiku*)        gl_cv_func_printf_enomem="guessing yes";;
-                         # If we don't know, assume the worst.
-          *)             gl_cv_func_printf_enomem="guessing no";;
+                           # Guess yes on glibc systems.
+          *-gnu* | gnu*)   gl_cv_func_printf_enomem="guessing yes";;
+                           # Guess yes on Solaris.
+          solaris*)        gl_cv_func_printf_enomem="guessing yes";;
+                           # Guess yes on AIX.
+          aix*)            gl_cv_func_printf_enomem="guessing yes";;
+                           # Guess yes on HP-UX/hppa.
+          hpux*)           case "$host_cpu" in
+                             hppa*) gl_cv_func_printf_enomem="guessing yes";;
+                             *)     gl_cv_func_printf_enomem="guessing no";;
+                           esac
+                           ;;
+                           # Guess yes on IRIX.
+          irix*)           gl_cv_func_printf_enomem="guessing yes";;
+                           # Guess yes on OSF/1.
+          osf*)            gl_cv_func_printf_enomem="guessing yes";;
+                           # Guess yes on BeOS.
+          beos*)           gl_cv_func_printf_enomem="guessing yes";;
+                           # Guess yes on Haiku.
+          haiku*)          gl_cv_func_printf_enomem="guessing yes";;
+                           # Guess no on Android.
+          linux*-android*) gl_cv_func_printf_enomem="guessing no";;
+                           # If we don't know, assume the worst.
+          *)               gl_cv_func_printf_enomem="guessing no";;
         esac
 changequote([,])dnl
       fi
@@ -1208,6 +1237,8 @@ changequote(,)dnl
            netbsd*)              gl_cv_func_snprintf_truncation_c99="guessing yes";;
                                  # Guess yes on BeOS.
            beos*)                gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on Android.
+           linux*-android*)      gl_cv_func_snprintf_truncation_c99="guessing yes";;
                                  # Guess no on native Windows.
            mingw*)               gl_cv_func_snprintf_truncation_c99="guessing no";;
                                  # If we don't know, assume the worst.
@@ -1299,6 +1330,8 @@ changequote(,)dnl
            netbsd*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
                                  # Guess yes on BeOS.
            beos*)                gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on Android.
+           linux*-android*)      gl_cv_func_snprintf_retval_c99="guessing yes";;
 changequote([,])dnl
                                  # Guess yes on MSVC, no on mingw.
            mingw*)               AC_EGREP_CPP([Known], [
@@ -1391,6 +1424,8 @@ changequote(,)dnl
            netbsd*)              gl_cv_func_snprintf_directive_n="guessing yes";;
                                  # Guess yes on BeOS.
            beos*)                gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # Guess no on Android.
+           linux*-android*)      gl_cv_func_snprintf_directive_n="guessing no";;
                                  # Guess no on native Windows.
            mingw*)               gl_cv_func_snprintf_directive_n="guessing no";;
                                  # If we don't know, assume the worst.
@@ -1440,9 +1475,11 @@ int main()
         [gl_cv_func_snprintf_size1=yes],
         [gl_cv_func_snprintf_size1=no],
         [case "$host_os" in
-                   # Guess yes on native Windows.
-           mingw*) gl_cv_func_snprintf_size1="guessing yes" ;;
-           *)      gl_cv_func_snprintf_size1="guessing yes" ;;
+                            # Guess yes on Android.
+           linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;;
+                            # Guess yes on native Windows.
+           mingw*)          gl_cv_func_snprintf_size1="guessing yes" ;;
+           *)               gl_cv_func_snprintf_size1="guessing yes" ;;
          esac
         ])
     ])
@@ -1540,6 +1577,8 @@ changequote(,)dnl
            netbsd*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
                                  # Guess yes on BeOS.
            beos*)                gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on Android.
+           linux*-android*)      gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
                                  # Guess yes on native Windows.
            mingw* | pw*)         gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
                                  # If we don't know, assume the worst.
@@ -1626,6 +1665,7 @@ dnl   NetBSD 4.0                     .  ?  ?  ?  ?  ?  .  ?  .  ?  ?  ?  ?  ?  .
 dnl   NetBSD 3.0                     .  .  .  .  #  #  .  ?  #  #  ?  #  .  #  .  .  .  .  .  .
 dnl   Haiku                          .  .  .  #  #  #  .  #  .  .  .  .  .  ?  .  .  ?  .  .  .
 dnl   BeOS                           #  #  .  #  #  #  .  ?  #  .  ?  .  #  ?  .  .  ?  .  .  .
+dnl   Android 4.3                    .  .  #  #  #  #  #  #  .  #  .  #  .  #  .  .  .  #  .  .
 dnl   old mingw / msvcrt             #  #  #  #  #  #  .  .  #  #  .  #  #  ?  .  #  #  #  .  .
 dnl   MSVC 9                         #  #  #  #  #  #  #  .  #  #  .  #  #  ?  #  #  #  #  .  .
 dnl   mingw 2009-2011                .  #  .  #  .  .  .  .  #  #  .  .  .  ?  .  .  .  .  .  .
-- 
2.7.4


[-- Attachment #3: 0002-vasnprintf-Don-t-use-n-on-Android.patch --]
[-- Type: text/x-patch, Size: 2913 bytes --]

From 6c0f109fb98501fc8d65ea2c83501b45a80b00ab Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 23 Jan 2019 01:17:07 +0100
Subject: [PATCH 2/2] vasnprintf: Don't use %n on Android.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reported and fix suggested by Hugo Beauzée-Luyssen <hugo@beauzee.fr> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-12/msg00123.html>.

* lib/vasnprintf.c (VASNPRINTF): Don’t use %n on Android.
---
 ChangeLog        | 7 +++++++
 lib/vasnprintf.c | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index e3ec57b..f3972fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2019-01-22  Bruno Haible  <bruno@clisp.org>
 
+	vasnprintf: Don't use %n on Android.
+	Reported and fix suggested by Hugo Beauzée-Luyssen <hugo@beauzee.fr> in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2018-12/msg00123.html>.
+	* lib/vasnprintf.c (VASNPRINTF): Don’t use %n on Android.
+
+2019-01-22  Bruno Haible  <bruno@clisp.org>
+
 	*printf: Support cross-compilation to Android.
 	* m4/printf.m4: Add cross-compilation guesses for Android.
 
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 465ecc3..b14a959 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -4874,6 +4874,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 # if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))        \
          && !defined __UCLIBC__)                                            \
         || (defined __APPLE__ && defined __MACH__)                          \
+        || defined __ANDROID__                                              \
         || (defined _WIN32 && ! defined __CYGWIN__))
                 fbp[1] = '%';
                 fbp[2] = 'n';
@@ -4895,6 +4896,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                    On Mac OS X 10.13 or newer, the use of %n in format strings
                    in writable memory by default crashes the program, so we
                    should avoid it in this situation.  */
+                /* On Android, we know that snprintf's return value conforms to
+                   ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and
+                   gl_SNPRINTF_TRUNCATION_C99 pass.
+                   Therefore we can avoid using %n in this situation.
+                   Starting on 2018-03-07, the use of %n in format strings
+                   produces a fatal error (see
+                   <https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336>),
+                   so we should avoid it.  */
                 /* On native Windows systems (such as mingw), we can avoid using
                    %n because:
                      - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] vasnprintf: Don't use %n on android
  2019-01-23  0:25             ` Bruno Haible
@ 2019-01-23 18:38               ` Tim Rühsen
  0 siblings, 0 replies; 9+ messages in thread
From: Tim Rühsen @ 2019-01-23 18:38 UTC (permalink / raw)
  To: Bruno Haible, Hugo Beauzée-Luyssen; +Cc: bug-gnulib


[-- Attachment #1.1: Type: text/plain, Size: 3581 bytes --]

On 23.01.19 01:25, Bruno Haible wrote:
> Hi Tim and Hugo,
> 
>>> I also don't see much here (Debian unstable):
>>>
>>> $ grep -A1 -i 'checking.*printf' config.log
>>> configure:6305: checking for vasnprintf
>>> configure:6305: result: no
>>> configure:6305: checking for snprintf
>>> configure:6305: result: yes
>>> --
>>> configure:8450: checking whether snprintf returns a byte count as in C99
>>> configure:8548: result: yes
>>> configure:8559: checking for snprintf
>>> configure:8559: result: yes
>>> --
>>> configure:8568: checking whether _snprintf is declared
>>> configure:8568: result: no
>>>
>>> What does that grep look for you ?
>>
>> $ grep -A1 'checking .*printf' config.log
>> configure:6326: checking for vasnprintf
>> configure:6326: gcc -o conftest -g -O2   conftest.c  >&5
>> --
>> configure:6326: checking for snprintf
>> configure:6326: gcc -o conftest -g -O2   conftest.c  >&5
>> --
>> configure:8471: checking whether snprintf returns a byte count as in C99
>> configure:8558: gcc -o conftest -g -O2   conftest.c  >&5
>> --
>> configure:8580: checking for snprintf
>> configure:8580: result: yes
>> --
>> configure:8589: checking whether _snprintf is declared
>> configure:8589: gcc -c -g -O2  conftest.c >&5
> 
> I did these steps:
> 1) Create a testdir
>    ./gnulib-tool --create-testdir --dir=../testdir-printf-posix --single-configure \
>                  dprintf-posix fprintf-posix printf-posix snprintf-posix \
>                  sprintf-posix vasnprintf-posix vasprintf-posix vdprintf-posix \
>                  vfprintf-posix vprintf-posix vsnprintf-posix vsprintf-posix
> 2) Tarred the resulting directory
> 3) Transfered it to the device (Android 4.3 with 'Terminal IDE' app in my case),
> 4) Unpacked it there,
> 5) configured it,
> 6) Copy&pasted the configure output.
> 
> The configure output contains the lines
> 
> checking whether printf supports size specifiers as in C99... yes
> checking whether printf supports 'long double' arguments... yes
> checking whether printf supports infinite 'double' arguments... no
> checking whether printf supports infinite 'long double' arguments... no
> checking whether printf supports the 'a' and 'A' directives... no
> checking whether printf supports the 'F' directive... no
> checking whether printf supports the 'n' directive... no
> checking whether printf supports the 'ls' directive... no
> checking whether printf supports POSIX/XSI format strings with positions... yes
> checking whether printf supports the grouping flag... no
> checking whether printf supports the left-adjust flag correctly... yes
> checking whether printf supports the zero flag correctly... no
> checking whether printf supports large precisions... yes
> checking whether printf survives out-of-memory conditions... no
> checking for snprintf... yes
> checking whether snprintf truncates the result as in C99... yes
> checking whether snprintf returns a byte count as in C99... yes
> checking whether snprintf fully supports the 'n' directive... no
> checking whether snprintf respects a size of 1... yes
> checking whether vsnprintf respects a zero size as in C99... yes
> 
> With this, I am in the position to update the results in printf.m4, and
> even add cross-compilation guesses.
> 
> Since snprintf is behaving well enough, we can disable the use of %n,
> like you suggested.
> 
> Done through the attached patches.
> 
> Bruno

Thanks you, Bruno and Hugo.

Already committed it successfully into GnuTLS :-)

Regards, Tim


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-01-23 18:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-19  9:54 [PATCH] vasnprintf: Don't use %n on android Hugo Beauzée-Luyssen
2018-12-20  1:53 ` Bruno Haible
2019-01-08 13:22   ` Hugo Beauzée-Luyssen
2019-01-21 15:58     ` Tim Rühsen
2019-01-21 16:00       ` Hugo Beauzée-Luyssen
2019-01-21 16:11         ` Tim Rühsen
2019-01-21 16:51           ` Hugo Beauzée-Luyssen
2019-01-23  0:25             ` Bruno Haible
2019-01-23 18:38               ` Tim Rühsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).