Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions android/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
#
# It should also be fairly simple to extend this to cross-compile for any target

NDK := /opt/android-sdk-linux_x86/android-ndk-r16b
NDK := /opt/android-sdk-linux_x86/android-ndk-r21
ARCH := arm

EXTRA_CFLAGS :=

# You should be able to just 'make ARCH=x86' and it should DTRT.
ifeq ($(ARCH),arm)
TRIPLET := arm-linux-androideabi
API_LEVEL := 14
API_LEVEL := 16
EXTRA_CFLAGS := -march=armv7-a -mthumb
endif
ifeq ($(ARCH),arm64)
Expand All @@ -27,7 +27,7 @@ API_LEVEL := 26
endif
ifeq ($(ARCH),x86)
TRIPLET := i686-linux-android
API_LEVEL := 14
API_LEVEL := 16
endif
ifeq ($(ARCH),x86_64)
TRIPLET := x86_64-linux-android
Expand Down Expand Up @@ -78,10 +78,15 @@ all: openconnect run_pie
# (The fallback logic is because NDK versions <= r8e can fail after trying to
# use 32-bit binaries on a 64-bit NDK installation.)
#
#$(TOOLCHAIN_BUILT):
# $(NDK)/build/tools/make-standalone-toolchain.sh $(TOOLCHAIN_OPTS) || \
# $(NDK)/build/tools/make-standalone-toolchain.sh \
# $(TOOLCHAIN_OPTS) --system=linux-x86_64
# touch $@
$(TOOLCHAIN_BUILT):
$(NDK)/build/tools/make-standalone-toolchain.sh $(TOOLCHAIN_OPTS) || \
$(NDK)/build/tools/make-standalone-toolchain.sh \
$(TOOLCHAIN_OPTS) --system=linux-x86_64
$(TOOLCHAIN_OPTS)
touch $@

#####################################################################
Expand Down Expand Up @@ -170,9 +175,9 @@ gmp: $(GMP_DEPS)
#
# Build nettle
#
NETTLE_VER := 3.4
NETTLE_VER := 3.4.1
NETTLE_TAR := nettle-$(NETTLE_VER).tar.gz
NETTLE_SHA := ae7a42df026550b85daca8389b6a60ba6313b0567f374392e54918588a411e94
NETTLE_SHA := f941cf1535cd5d1819be5ccae5babef01f6db611f9b5a777bae9c7604b8a92ad
NETTLE_SRC := sources/nettle-$(NETTLE_VER)
NETTLE_BUILD := $(TRIPLET)/nettle

Expand Down Expand Up @@ -203,9 +208,9 @@ nettle: $(NETTLE_DEPS)
#
# Build GnuTLS
#
GNUTLS_VER := 3.5.17
GNUTLS_VER := 3.6.8
GNUTLS_TAR := gnutls-$(GNUTLS_VER).tar.xz
GNUTLS_SHA := 86b142afef587c118d63f72ccf307f3321dbc40357aae528202b65d913d20919
GNUTLS_SHA := aa81944e5635de981171772857e72be231a7e0f559ae0292d2737de475383e83
GNUTLS_SRC := sources/gnutls-$(GNUTLS_VER)
GNUTLS_BUILD := $(TRIPLET)/gnutls

Expand Down Expand Up @@ -300,6 +305,9 @@ $(OATH_SRC)/configure: $(OATH_TAR)
mkdir -p sources
tar xfz $< -C sources
> $(OATH_SRC)/liboath/gl/freading.c
patch $(OATH_SRC)/oathtool/gl/vasnprintf.c < $(TOPDIR)/oathtool.diff
patch $(OATH_SRC)/liboath/gl/vasnprintf.c < $(TOPDIR)/liboath.diff
patch $(OATH_SRC)/libpskc/gl/tests/vasnprintf.c < $(TOPDIR)/libpskc.diff
touch $@

$(OATH_BUILD)/Makefile: $(TOOLCHAIN_BUILT) $(OATH_SRC)/configure
Expand Down
6 changes: 3 additions & 3 deletions android/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ nettle_MIRROR_0=http://www.lysator.liu.se/~nisse/archive
nettle_MIRROR_1=http://ftp.gnu.org/gnu/nettle
nettle_MIRROR_2=http://gd.tuwien.ac.at/gnu/gnusrc/nettle

gnutls_MIRROR_0=https://www.gnupg.org/ftp/gcrypt/gnutls/v3.5
gnutls_MIRROR_1=http://ftp.heanet.ie/mirrors/ftp.gnupg.org/gcrypt/gnutls/v3.5
gnutls_MIRROR_2=http://gd.tuwien.ac.at/pub/gnupg/gnutls/v3.5
gnutls_MIRROR_0=https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6
gnutls_MIRROR_1=http://ftp.heanet.ie/mirrors/ftp.gnupg.org/gcrypt/gnutls/v3.6
gnutls_MIRROR_2=http://gd.tuwien.ac.at/pub/gnupg/gnutls/v3.6

stoken_MIRROR_0=http://sourceforge.net/projects/stoken/files
stoken_SUFFIX_0=/download
Expand Down
73 changes: 73 additions & 0 deletions android/liboath.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
--- ./sources/oath-toolkit-2.6.2/liboath/gl/vasnprintf.c 2016-08-27 14:15:06.000000000 +0300
+++ ./sources/oath-toolkit-2.6.2/liboath/gl/vasnprintf.c.new 2019-10-09 11:34:36.000000000 +0300
@@ -2,16 +2,16 @@
Copyright (C) 1999, 2002-2016 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1, or (at your option)
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
+ GNU General Public License for more details.

- You should have received a copy of the GNU Lesser General Public License along
+ You should have received a copy of the GNU General Public License along
with this program; if not, see <http://www.gnu.org/licenses/>. */

/* This file can be parametrized with the following macros:
@@ -4858,7 +4858,11 @@
#endif
*fbp = dp->conversion;
#if USE_SNPRINTF
-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# 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';
fbp[3] = '\0';
@@ -4872,9 +4876,23 @@
in format strings in writable memory may crash the program
(if compiled with _FORTIFY_SOURCE=2), so we should avoid it
in this situation. */
+ /* On Mac OS X 10.3 or newer, 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.
+ 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,
+/USE_SNPRINTF
snprintf does not write more than the specified number
of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
'4', '5', '6' into buf, not '4', '5', '\0'.)
@@ -4884,8 +4902,8 @@
On native Windows systems (such as mingw) where the OS is
Windows Vista, the use of %n in format strings by default
crashes the program. See
- <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
- <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx>
+ <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
+ <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-printf-count-output>
So we should avoid %n in this situation. */
fbp[1] = '\0';
# endif
52 changes: 52 additions & 0 deletions android/libpskc.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--- ./sources/oath-toolkit-2.6.2/libpskc/gl/tests/vasnprintf.c 2016-08-27 14:15:06.000000000 +0300
+++ ./sources/oath-toolkit-2.6.2/libpskc/gl/tests/vasnprintf.c.new 2019-10-09 11:34:36.000000000 +0300
@@ -4858,7 +4858,11 @@
#endif
*fbp = dp->conversion;
#if USE_SNPRINTF
-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# 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';
fbp[3] = '\0';
@@ -4872,9 +4876,23 @@
in format strings in writable memory may crash the program
(if compiled with _FORTIFY_SOURCE=2), so we should avoid it
in this situation. */
+ /* On Mac OS X 10.3 or newer, 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.
+ 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,
+/USE_SNPRINTF
snprintf does not write more than the specified number
of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
'4', '5', '6' into buf, not '4', '5', '\0'.)
@@ -4884,8 +4902,8 @@
On native Windows systems (such as mingw) where the OS is
Windows Vista, the use of %n in format strings by default
crashes the program. See
- <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
- <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx>
+ <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
+ <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-printf-count-output>
So we should avoid %n in this situation. */
fbp[1] = '\0';
# endif
52 changes: 52 additions & 0 deletions android/oathtool.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--- ./sources/oath-toolkit-2.6.2/oathtool/gl/vasnprintf.c 2016-08-27 14:15:06.000000000 +0300
+++ ./sources/oath-toolkit-2.6.2/oathtool/gl/vasnprintf.c.new 2019-10-09 11:34:36.000000000 +0300
@@ -4858,7 +4858,11 @@
#endif
*fbp = dp->conversion;
#if USE_SNPRINTF
-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# 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';
fbp[3] = '\0';
@@ -4872,9 +4876,23 @@
in format strings in writable memory may crash the program
(if compiled with _FORTIFY_SOURCE=2), so we should avoid it
in this situation. */
+ /* On Mac OS X 10.3 or newer, 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.
+ 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,
+/USE_SNPRINTF
snprintf does not write more than the specified number
of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
'4', '5', '6' into buf, not '4', '5', '\0'.)
@@ -4884,8 +4902,8 @@
On native Windows systems (such as mingw) where the OS is
Windows Vista, the use of %n in format strings by default
crashes the program. See
- <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
- <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx>
+ <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
+ <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-printf-count-output>
So we should avoid %n in this situation. */
fbp[1] = '\0';
# endif