bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Bruno Haible
Subject: Re: [PATCH] vasnprintf: Don't use %n on android
Date: Thu, 20 Dec 2018 02:53:13 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-139-generic; KDE/5.18.0; x86_64; ; )

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]