From adde656bb7a859fb4cc334cb89a00840a7023c2e Mon Sep 17 00:00:00 2001 From: kinichiro Date: Sun, 26 Dec 2021 15:42:47 +0900 Subject: Add strtonum to compat library and export it crypto library requires strtonum now, and add it to compat library. remove it from applications compat/ directories. --- apps/nc/CMakeLists.txt | 8 -------- apps/nc/Makefile.am | 4 ---- apps/ocspcheck/CMakeLists.txt | 8 -------- apps/ocspcheck/Makefile.am | 4 ---- apps/openssl/CMakeLists.txt | 8 -------- apps/openssl/Makefile.am | 4 ---- crypto/CMakeLists.txt | 5 +++++ crypto/Makefile.am | 7 +++++++ tests/optionstest.c | 1 - update.sh | 4 +--- 10 files changed, 13 insertions(+), 40 deletions(-) diff --git a/apps/nc/CMakeLists.txt b/apps/nc/CMakeLists.txt index e873de8..bd59211 100644 --- a/apps/nc/CMakeLists.txt +++ b/apps/nc/CMakeLists.txt @@ -29,14 +29,6 @@ else() set(NC_SRC ${NC_SRC} compat/readpassphrase.c) endif() -check_function_exists(strtonum HAVE_STRTONUM) -if(HAVE_STRTONUM AND CMAKE_SYSTEM_NAME MATCHES "Darwin" AND - CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 20) - add_definitions(-DHAVE_STRTONUM) -else() - set(NC_SRC ${NC_SRC} compat/strtonum.c) -endif() - if(NOT "${OPENSSLDIR}" STREQUAL "") add_definitions(-DDEFAULT_CA_FILE=\"${OPENSSLDIR}/cert.pem\") else() diff --git a/apps/nc/Makefile.am b/apps/nc/Makefile.am index 58b5c01..e9db6e5 100644 --- a/apps/nc/Makefile.am +++ b/apps/nc/Makefile.am @@ -43,8 +43,4 @@ if !HAVE_READPASSPHRASE nc_SOURCES += compat/readpassphrase.c endif -if !HAVE_STRTONUM -nc_SOURCES += compat/strtonum.c -endif - endif diff --git a/apps/ocspcheck/CMakeLists.txt b/apps/ocspcheck/CMakeLists.txt index 249f0f4..2dddb6e 100644 --- a/apps/ocspcheck/CMakeLists.txt +++ b/apps/ocspcheck/CMakeLists.txt @@ -13,14 +13,6 @@ else() set(OCSPCHECK_SRC ${OCSPCHECK_SRC} compat/memmem.c) endif() -check_function_exists(strtonum HAVE_STRTONUM) -if(HAVE_STRTONUM AND CMAKE_SYSTEM_NAME MATCHES "Darwin" AND - CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 20) - add_definitions(-DHAVE_STRTONUM) -else() - set(OCSPCHECK_SRC ${OCSPCHECK_SRC} compat/strtonum.c) -endif() - if(NOT "${OPENSSLDIR}" STREQUAL "") add_definitions(-DDEFAULT_CA_FILE=\"${OPENSSLDIR}/cert.pem\") else() diff --git a/apps/ocspcheck/Makefile.am b/apps/ocspcheck/Makefile.am index 71a73ea..7c7b454 100644 --- a/apps/ocspcheck/Makefile.am +++ b/apps/ocspcheck/Makefile.am @@ -22,7 +22,3 @@ noinst_HEADERS = http.h if !HAVE_MEMMEM ocspcheck_SOURCES += compat/memmem.c endif - -if !HAVE_STRTONUM -ocspcheck_SOURCES += compat/strtonum.c -endif diff --git a/apps/openssl/CMakeLists.txt b/apps/openssl/CMakeLists.txt index bb058e1..2a84178 100644 --- a/apps/openssl/CMakeLists.txt +++ b/apps/openssl/CMakeLists.txt @@ -61,14 +61,6 @@ if(WIN32) set(OPENSSL_SRC ${OPENSSL_SRC} compat/poll_win.c) endif() -check_function_exists(strtonum HAVE_STRTONUM) -if(HAVE_STRTONUM AND CMAKE_SYSTEM_NAME MATCHES "Darwin" AND - CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 20) - add_definitions(-DHAVE_STRTONUM) -else() - set(OPENSSL_SRC ${OPENSSL_SRC} compat/strtonum.c) -endif() - if(CMAKE_SYSTEM_NAME MATCHES "Darwin") check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) if(NOT HAVE_CLOCK_GETTIME) diff --git a/apps/openssl/Makefile.am b/apps/openssl/Makefile.am index b98e08d..7cbac48 100644 --- a/apps/openssl/Makefile.am +++ b/apps/openssl/Makefile.am @@ -84,10 +84,6 @@ openssl_SOURCES += compat/clock_gettime_osx.c endif endif -if !HAVE_STRTONUM -openssl_SOURCES += compat/strtonum.c -endif - noinst_HEADERS = apps.h noinst_HEADERS += progs.h noinst_HEADERS += s_apps.h diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 12bc8ae..196ae4a 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -888,6 +888,11 @@ if(NOT HAVE_STRSEP) set(EXTRA_EXPORT ${EXTRA_EXPORT} strsep) endif() +if(NOT HAVE_STRTONUM) + set(CRYPTO_SRC ${CRYPTO_SRC} compat/strtonum.c) + set(EXTRA_EXPORT ${EXTRA_EXPORT} strtonum) +endif() + if(NOT HAVE_SYSLOG_R) set(CRYPTO_SRC ${CRYPTO_SRC} compat/syslog_r.c) endif() diff --git a/crypto/Makefile.am b/crypto/Makefile.am index 155df59..42d0dd9 100644 --- a/crypto/Makefile.am +++ b/crypto/Makefile.am @@ -76,6 +76,9 @@ endif if !HAVE_STRSEP -echo strsep >> crypto_portable.sym endif +if !HAVE_STRTONUM + -echo strtonum >> crypto_portable.sym +endif if !HAVE_TIMEGM -echo timegm >> crypto_portable.sym endif @@ -175,6 +178,10 @@ if !HAVE_STRSEP libcompat_la_SOURCES += compat/strsep.c endif +if !HAVE_STRTONUM +libcompat_la_SOURCES += compat/strtonum.c +endif + if !HAVE_ASPRINTF libcompat_la_SOURCES += compat/bsd-asprintf.c endif diff --git a/tests/optionstest.c b/tests/optionstest.c index e860f0d..af9dc1e 100644 --- a/tests/optionstest.c +++ b/tests/optionstest.c @@ -24,7 +24,6 @@ #include #include -#include /* Needed to keep apps.c happy... */ BIO *bio_err; diff --git a/update.sh b/update.sh index 311ce4e..265afab 100755 --- a/update.sh +++ b/update.sh @@ -82,6 +82,7 @@ for i in crypto/compat; do $libc_src/crypt/chacha_private.h \ $libc_src/stdlib/reallocarray.c \ $libc_src/stdlib/recallocarray.c \ + $libc_src/stdlib/strtonum.c \ $libc_src/string/explicit_bzero.c \ $libc_src/string/strcasecmp.c \ $libc_src/string/strlcpy.c \ @@ -243,7 +244,6 @@ echo "copying nc(1) source" $CP $bin_src/nc/nc.1 apps/nc rm -f apps/nc/*.c apps/nc/*.h $CP_LIBC $libc_src/net/base64.c apps/nc/compat -$CP_LIBC $libc_src/stdlib/strtonum.c apps/nc/compat for i in `awk '/SOURCES|HEADERS|MANS/ { print $3 }' apps/nc/Makefile.am` ; do if [ -e $bin_src/nc/$i ]; then $CP $bin_src/nc/$i apps/nc @@ -255,7 +255,6 @@ echo "copying ocspcheck(1) source" $CP $sbin_src/ocspcheck/ocspcheck.8 apps/ocspcheck rm -f apps/ocspcheck/*.c apps/ocspcheck/*.h $CP_LIBC $libc_src/string/memmem.c apps/ocspcheck/compat -$CP_LIBC $libc_src/stdlib/strtonum.c apps/ocspcheck/compat for i in `awk '/SOURCES|HEADERS|MANS/ { print $3 }' apps/ocspcheck/Makefile.am` ; do if [ -e $sbin_src/ocspcheck/$i ]; then $CP $sbin_src/ocspcheck/$i apps/ocspcheck @@ -265,7 +264,6 @@ done # copy openssl(1) source echo "copying openssl(1) source" $CP $bin_src/openssl/openssl.1 apps/openssl -$CP_LIBC $libc_src/stdlib/strtonum.c apps/openssl/compat $CP $libcrypto_src/cert.pem . $CP $libcrypto_src/openssl.cnf . $CP $libcrypto_src/x509v3.cnf . -- cgit v1.2.3-55-g6feb