Re: [PATCH] vasnprintf: Don't use %n on android

2019-01-23 Thread Tim Rühsen
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



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] vasnprintf: Don't use %n on android

2019-01-22 Thread Bruno Haible
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


>From 5447f440ef927283e63d5a1290dab292f7af1aea Mon Sep 17 00:00:00 2001
From: Bruno Haible 
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  
+
+	*printf: Support cross-compilation to Android.
+	* m4/printf.m4: Add cross-compilation guesses for Android.
+
 2019-01-21  Bruno Haible  
 
 	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

Re: [PATCH] vasnprintf: Don't use %n on android

2019-01-21 Thread Hugo Beauzée-Luyssen
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 

Re: [PATCH] vasnprintf: Don't use %n on android

2019-01-21 Thread Tim Rühsen
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



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] vasnprintf: Don't use %n on android

2019-01-21 Thread Hugo Beauzée-Luyssen
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
  h...@beauzee.fr



Re: [PATCH] vasnprintf: Don't use %n on android

2019-01-21 Thread Tim Rühsen
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



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] vasnprintf: Don't use %n on android

2019-01-08 Thread Hugo Beauzée-Luyssen
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
  h...@beauzee.fr



Re: [PATCH] vasnprintf: Don't use %n on android

2018-12-19 Thread Bruno Haible
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




[PATCH] vasnprintf: Don't use %n on android

2018-12-19 Thread Hugo Beauzée-Luyssen
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