]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
configure: check for the fseeko declaration too
authorDaniel Stenberg <daniel@haxx.se>
Thu, 19 Oct 2023 12:55:37 +0000 (14:55 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 22 Oct 2023 18:20:49 +0000 (20:20 +0200)
... and make the code require both symbol and declaration.

This is because for Android, the symbol is always present in the lib at
build-time even when not actually available in run-time.

Assisted-by: Viktor Szakats
Reported-by: 12932 on github
Fixes #12086
Closes #12158

CMakeLists.txt
configure.ac
lib/curl_config.h.cmake
lib/formdata.c

index 9267543a2429730a2504fc2ff749ff58a5421641..04cffd78f37ce470d0ac8df9dafa12d5d892dbf4 100644 (file)
@@ -1208,6 +1208,10 @@ check_symbol_exists(setlocale      "${CURL_INCLUDES}" HAVE_SETLOCALE)
 check_symbol_exists(setmode        "${CURL_INCLUDES}" HAVE_SETMODE)
 check_symbol_exists(setrlimit      "${CURL_INCLUDES}" HAVE_SETRLIMIT)
 
+if(HAVE_FSEEKO)
+  set(HAVE_DECL_FSEEKO 1)
+endif()
+
 if(NOT MSVC OR (MSVC_VERSION GREATER_EQUAL 1900))
   # earlier MSVC compilers had faulty snprintf implementations
   check_symbol_exists(snprintf       "stdio.h" HAVE_SNPRINTF)
index 1861e1e59fa0830c396d758bbd3b96db7bfbbeaf..97b4d3e01812b106bacfe6acd46fcf6c5b8abdfc 100644 (file)
@@ -3581,7 +3581,6 @@ AC_CHECK_DECLS([getpwuid_r], [], [AC_DEFINE(HAVE_DECL_GETPWUID_R_MISSING, 1, "Se
         [[#include <pwd.h>
           #include <sys/types.h>]])
 
-
 AC_CHECK_FUNCS([\
   _fseeki64 \
   arc4random \
@@ -3628,6 +3627,15 @@ AC_CHECK_FUNCS([\
   fi
 ])
 
+dnl On Android, the only way to know if fseeko can be used is to see if it is
+dnl declared or not (for this API level), as the symbol always exists in the
+dnl lib.
+AC_CHECK_DECL([fseeko],
+              [AC_DEFINE([HAVE_DECL_FSEEKO], [1],
+               [Define to 1 if you have the fseeko declaration])],
+              [],
+              [[#include <stdio.h>]])
+
 CURL_CHECK_NONBLOCKING_SOCKET
 
 dnl ************************************************************
index 6df67d081b901aecad26d3c677f09b557d041c71..e12e7a1242ceb2234f4ff047268600b6f11152cc 100644 (file)
 /* Define to 1 if you have the fseeko function. */
 #cmakedefine HAVE_FSEEKO 1
 
+/* Define to 1 if you have the fseeko declaration. */
+#cmakedefine HAVE_DECL_FSEEKO 1
+
 /* Define to 1 if you have the _fseeki64 function. */
 #cmakedefine HAVE__FSEEKI64 1
 
index e40c4bcb039bb98fdfd25aa45aee5412ce740c66..9781029555cfd81113485dabb5213593c5176a93 100644 (file)
@@ -792,7 +792,7 @@ static CURLcode setname(curl_mimepart *part, const char *name, size_t len)
 /* wrap call to fseeko so it matches the calling convention of callback */
 static int fseeko_wrapper(void *stream, curl_off_t offset, int whence)
 {
-#if defined(HAVE_FSEEKO)
+#if defined(HAVE_FSEEKO) && defined(HAVE_DECL_FSEEKO)
   return fseeko(stream, (off_t)offset, whence);
 #elif defined(HAVE__FSEEKI64)
   return _fseeki64(stream, (__int64)offset, whence);