# HG changeset patch # User Bruno Haible # Date 1548384849 -3600 # Node ID f03dfb30b48c5c644d28ae73449725e041564a26 # Parent cfcc57a4ed059d4c67da53b413269ce4d575e163 memchr: Work around bug on Android <= 5.0. * m4/memchr.m4 (gl_FUNC_MEMCHR): Add test against the Android bug. * doc/posix-functions/memchr.texi: Mention the Android bug. diff -r cfcc57a4ed05 -r f03dfb30b48c ChangeLog --- a/ChangeLog Fri Jan 25 01:36:26 2019 +0100 +++ b/ChangeLog Fri Jan 25 03:54:09 2019 +0100 @@ -1,3 +1,9 @@ +2019-01-24 Bruno Haible + + memchr: Work around bug on Android <= 5.0. + * m4/memchr.m4 (gl_FUNC_MEMCHR): Add test against the Android bug. + * doc/posix-functions/memchr.texi: Mention the Android bug. + 2019-01-24 Bruno Haible random: Fix compilation error on Android 4.3. diff -r cfcc57a4ed05 -r f03dfb30b48c doc/posix-functions/memchr.texi --- a/doc/posix-functions/memchr.texi Fri Jan 25 01:36:26 2019 +0100 +++ b/doc/posix-functions/memchr.texi Fri Jan 25 03:54:09 2019 +0100 @@ -11,6 +11,10 @@ @item This function dereferences too much memory on some platforms: glibc 2.10 on x86_64, IA-64; glibc 2.11 on Alpha. +@item +This function returns NULL if the character argument is not in the range +of an @code{unsigned char} on some platforms: +Android 5.0. @end itemize Portability problems fixed by Gnulib module @code{memchr-obsolete}: diff -r cfcc57a4ed05 -r f03dfb30b48c m4/memchr.m4 --- a/m4/memchr.m4 Fri Jan 25 01:36:26 2019 +0100 +++ b/m4/memchr.m4 Fri Jan 25 03:54:09 2019 +0100 @@ -1,4 +1,4 @@ -# memchr.m4 serial 13 +# memchr.m4 serial 14 dnl Copyright (C) 2002-2004, 2009-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, @@ -29,6 +29,8 @@ # memchr should not dereference overestimated length after a match # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 # https://sourceware.org/bugzilla/show_bug.cgi?id=10162 + # memchr should cast the second argument to 'unsigned char'. + # This bug exists in Android 4.3. # Assume that memchr works on platforms that lack mprotect. AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works], [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ @@ -74,15 +76,26 @@ if (memchr (fence - 1, 0, 3) != fence - 1) result |= 4; } + /* Test against bug on Android 4.3. */ + { + char input[3]; + input[0] = 'a'; + input[1] = 'b'; + input[2] = 'c'; + if (memchr (input, 0x789abc00 | 'b', 3) != input + 1) + result |= 8; + } return result; ]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], [case "$host_os" in - # Guess yes on native Windows. - mingw*) gl_cv_func_memchr_works="guessing yes" ;; - # Be pessimistic for now. - *) gl_cv_func_memchr_works="guessing no" ;; + # Guess no on Android. + linux*-android*) gl_cv_func_memchr_works="guessing no" ;; + # Guess yes on native Windows. + mingw*) gl_cv_func_memchr_works="guessing yes" ;; + # Be pessimistic for now. + *) gl_cv_func_memchr_works="guessing no" ;; esac ]) ])