Last active
June 20, 2021 16:06
-
-
Save lordmulder/244a4ca15f0bd22cc50fe75817f3b71e to your computer and use it in GitHub Desktop.
Build cURL v7.77 for Windows XP or newer, Unicode, fully static, with OpenSSL zlib brotli zstd SSH2 HTTP/2 IPv6 IDN SASL NTLM HSTS RTMP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# _ _ ____ _ | |
# ___| | | | _ \| | | |
# / __| | | | |_) | | | |
# | (__| |_| | _ <| |___ | |
# \___|\___/|_| \_\_____| | |
set -e | |
trap 'read -p "Press any key..." x' EXIT | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Set up compiler | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
case "$(cc -dumpmachine)" in | |
i686-*) | |
readonly MY_CPU=x86 | |
readonly MY_MARCH=i486 | |
readonly MY_MTUNE=intel | |
;; | |
x86_64-*) | |
readonly MY_CPU=x64 | |
readonly MY_MARCH=x86-64 | |
readonly MY_MTUNE=corei7 | |
;; | |
*) | |
echo "Unknown compiler detected!"; | |
exit 1 | |
;; | |
esac | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Initialize paths | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
readonly BASE_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" | |
readonly LIBS_DIR="${BASE_DIR}/.local/${MY_CPU}" | |
find "${BASE_DIR}" -maxdepth 1 -type d -name "*-${MY_CPU}" -exec rm -rf "{}" \; | |
rm -rf "${LIBS_DIR}" && mkdir -p "${LIBS_DIR}/.pkg" "${LIBS_DIR}/bin" "${LIBS_DIR}/include" "${LIBS_DIR}/lib/pkgconfig" "${LIBS_DIR}/share" | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Download | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
wget -4 -O "${LIBS_DIR}/.pkg/zlib.tar.gz" https://zlib.net/zlib-1.2.11.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/zstd.tar.gz" https://github.com/facebook/zstd/releases/download/v1.5.0/zstd-1.5.0.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/brotli.tar.gz" https://github.com/google/brotli/archive/v1.0.9/brotli-1.0.9.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/openssl.tar.gz" https://www.openssl.org/source/openssl-1.1.1k.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/rtmpdump.tar.gz" http://git.ffmpeg.org/gitweb/rtmpdump.git/snapshot/f1b83c10d8beb43fcc70a6e88cf4325499f25857.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/libiconv.tar.gz" https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/gettext.tar.gz" https://ftp.gnu.org/pub/gnu/gettext/gettext-0.21.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/libssh2.tar.gz" https://www.libssh2.org/download/libssh2-1.9.0.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/nghttp2.tar.gz" https://github.com/nghttp2/nghttp2/releases/download/v1.43.0/nghttp2-1.43.0.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/libidn2.tar.gz" https://ftp.gnu.org/gnu/libidn/libidn2-2.3.1.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/libgsasl.tar.gz" https://ftp.gnu.org/gnu/gsasl/libgsasl-1.10.0.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/curl.tar.gz" https://curl.se/download/curl-7.77.0.tar.gz | |
wget -4 -O "${LIBS_DIR}/.pkg/cacert.pem" https://curl.se/ca/cacert.pem | |
wget -4 -O "${LIBS_DIR}/.pkg/manpage.html" https://curl.se/docs/manpage.html | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# zlib | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== zlib ====================\n\n" | |
readonly ZLIB_DIR="${BASE_DIR}/zlib-${MY_CPU}" | |
rm -rf "${ZLIB_DIR}" && mkdir "${ZLIB_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/zlib.tar.gz" --strip-components=1 -C "${ZLIB_DIR}" | |
pushd "${ZLIB_DIR}" | |
make -f win32/Makefile.gcc LOC="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501" | |
make -f win32/Makefile.gcc install BINARY_PATH="${LIBS_DIR}/include" INCLUDE_PATH="${LIBS_DIR}/include" LIBRARY_PATH="${LIBS_DIR}/lib" | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Zstandard | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== Zstandard ====================\n\n" | |
readonly ZSTD_DIR="${BASE_DIR}/zstd-${MY_CPU}" | |
rm -rf "${ZSTD_DIR}" && mkdir "${ZSTD_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/zstd.tar.gz" --strip-components=1 -C "${ZSTD_DIR}" | |
pushd "${ZSTD_DIR}" | |
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" LDFLAGS="-L${LIBS_DIR}/lib" make lib | |
cp -vf lib/libzstd.a "${LIBS_DIR}/lib" | |
cp -vf lib/zstd.h lib/zstd_errors.h lib/zdict.h "${LIBS_DIR}/include" | |
sed -e "s|@PREFIX@|${LIBS_DIR}|g" -e 's|@EXEC_PREFIX@|${prefix}|g' -e 's|@INCLUDEDIR@|${prefix}/include|g' -e 's|@LIBDIR@|${prefix}/lib|g' -e 's|@VERSION@|1.5.0|g' lib/libzstd.pc.in > "${LIBS_DIR}/lib/pkgconfig/libzstd.pc" | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Brotli | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== Brotli ====================\n\n" | |
readonly BROT_DIR="${BASE_DIR}/brotli-${MY_CPU}" | |
rm -rf "${BROT_DIR}" && mkdir "${BROT_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/brotli.tar.gz" --strip-components=1 -C "${BROT_DIR}" | |
pushd "${BROT_DIR}" | |
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" LDFLAGS="-L${LIBS_DIR}/lib" make lib | |
mkdir -p "${LIBS_DIR}/include/brotli" | |
cp -vf c/include/brotli/*.h "${LIBS_DIR}/include/brotli" | |
for fname in scripts/*.pc.in; do | |
cp -vf libbrotli.a "${LIBS_DIR}/lib/$(basename "${fname}" .pc.in).a" | |
sed -e "s|@prefix@|${LIBS_DIR}|g" -e 's|@exec_prefix@|${prefix}|g' -e 's|@includedir@|${prefix}/include|g' -e 's|@libdir@|${prefix}/lib|g' -e 's|@PACKAGE_VERSION@|1.0.9|g' ${fname} > "${LIBS_DIR}/lib/pkgconfig/$(basename "${fname}" .in)" | |
done | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# OpenSSL | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== OpenSSL ====================\n\n" | |
readonly OSSL_DIR="${BASE_DIR}/openssl-${MY_CPU}" | |
rm -rf "${OSSL_DIR}" && mkdir "${OSSL_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/openssl.tar.gz" --strip-components=1 -C "${OSSL_DIR}" | |
[[ "${MY_CPU}" == "x64" ]] && readonly ossl_flag="no-sse2" || readonly ossl_flag="386" | |
[[ "${MY_CPU}" == "x64" ]] && readonly ossl_mngw="mingw64" || readonly ossl_mngw="mingw" | |
pushd "${OSSL_DIR}" | |
./Configure no-hw no-shared no-engine no-capieng no-dso zlib ${ossl_flag} -static -march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I"${LIBS_DIR}/include" -L"${LIBS_DIR}/lib" --prefix="${LIBS_DIR}" ${ossl_mngw} | |
make build_libs && make install_dev | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# librtmp | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== librtmp ====================\n\n" | |
readonly RTMP_DIR="${BASE_DIR}/librtmp-${MY_CPU}" | |
rm -rf "${RTMP_DIR}" && mkdir "${RTMP_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/rtmpdump.tar.gz" --strip-components=1 -C "${RTMP_DIR}" | |
pushd "${RTMP_DIR}" | |
patch -p1 -b < "${BASE_DIR}/patch/librtmp_openssl.diff" | |
make SYS=mingw SHARED= prefix="${LIBS_DIR}" XCFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" XLDFLAGS="-L${LIBS_DIR}/lib" XLIBS="-lws2_32" | |
make SYS=mingw SHARED= prefix="${LIBS_DIR}" install | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# libiconv | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== libiconv ====================\n\n" | |
readonly ICNV_DIR="${BASE_DIR}/libiconv-${MY_CPU}" | |
rm -rf "${ICNV_DIR}" && mkdir "${ICNV_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/libiconv.tar.gz" --strip-components=1 -C "${ICNV_DIR}" | |
pushd "${ICNV_DIR}" | |
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" LDFLAGS="-L${LIBS_DIR}/lib" ./configure --prefix="${LIBS_DIR}" --disable-rpath --disable-shared | |
make && make install | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# gettext | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== gettext ====================\n\n" | |
readonly GTXT_DIR="${BASE_DIR}/gettext-${MY_CPU}" | |
rm -rf "${GTXT_DIR}" && mkdir "${GTXT_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/gettext.tar.gz" --strip-components=1 -C "${GTXT_DIR}" | |
pushd "${GTXT_DIR}/gettext-runtime" | |
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" LDFLAGS="-L${LIBS_DIR}/lib" ./configure --prefix="${LIBS_DIR}" --disable-shared --disable-libasprintf --without-emacs --disable-java --disable-native-java --disable-csharp --disable-openmp | |
make && make install | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# libssh2 | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== libssh2 ====================\n\n" | |
readonly SSH2_DIR="${BASE_DIR}/libssh2-${MY_CPU}" | |
rm -rf "${SSH2_DIR}" && mkdir "${SSH2_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/libssh2.tar.gz" --strip-components=1 -C "${SSH2_DIR}" | |
pushd "${SSH2_DIR}" | |
patch -p1 -b < "${BASE_DIR}/patch/ssh2_session.diff" | |
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" LDFLAGS="-L${LIBS_DIR}/lib" ./configure --prefix="${LIBS_DIR}" --disable-examples-build --disable-shared --with-libz | |
make && make install | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# nghttp2 | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== nghttp2 ====================\n\n" | |
readonly NGH2_DIR="${BASE_DIR}/nghttp2-${MY_CPU}" | |
rm -rf "${NGH2_DIR}" && mkdir "${NGH2_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/nghttp2.tar.gz" --strip-components=1 -C "${NGH2_DIR}" | |
pushd "${NGH2_DIR}" | |
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" LDFLAGS="-L${LIBS_DIR}/lib" OPENSSL_CFLAGS="-I${LIBS_DIR}/include" OPENSSL_LIBS="-L${LIBS_DIR}/lib -lssl -lcrypto" ZLIB_CFLAGS="-I${LIBS_DIR}/include" ZLIB_LIBS="-L${LIBS_DIR}/lib -lz" ./configure --prefix="${LIBS_DIR}" --enable-lib-only --disable-threads --disable-shared | |
make && make install | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# libidn2 | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== libidn2 ====================\n\n" | |
readonly IDN2_DIR="${BASE_DIR}/libidn2-${MY_CPU}" | |
rm -rf "${IDN2_DIR}" && mkdir "${IDN2_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/libidn2.tar.gz" --strip-components=1 -C "${IDN2_DIR}" | |
pushd "${IDN2_DIR}" | |
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" LDFLAGS="-L${LIBS_DIR}/lib" ./configure --prefix="${LIBS_DIR}" --disable-shared --disable-doc --without-libiconv-prefix --without-libunistring-prefix --disable-valgrind-tests | |
make && make install | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# libgsasl | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== libgsasl ====================\n\n" | |
readonly SASL_DIR="${BASE_DIR}/libgsasl-${MY_CPU}" | |
rm -rf "${SASL_DIR}" && mkdir "${SASL_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/libgsasl.tar.gz" --strip-components=1 -C "${SASL_DIR}" | |
pushd "${SASL_DIR}" | |
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" LDFLAGS="-L${LIBS_DIR}/lib" ./configure --prefix="${LIBS_DIR}" --disable-shared --disable-valgrind-tests --disable-obsolete -without-libintl-prefix | |
make && make install | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# cURL | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== cURL ====================\n\n" | |
readonly CURL_DIR="${BASE_DIR}/curl-${MY_CPU}" | |
rm -rf "${CURL_DIR}" && mkdir "${CURL_DIR}" | |
tar -xvf "${LIBS_DIR}/.pkg/curl.tar.gz" --strip-components=1 -C "${CURL_DIR}" | |
pushd "${CURL_DIR}" | |
patch -p1 -b < "${BASE_DIR}/patch/curl_getenv.diff" | |
patch -p1 -b < "${BASE_DIR}/patch/curl_threads.diff" | |
patch -p1 -b < "${BASE_DIR}/patch/curl_tool_doswin.diff" | |
patch -p1 -b < "${BASE_DIR}/patch/curl_tool_parsecfg.diff" | |
patch -p1 -b < "${BASE_DIR}/patch/curl_url.diff" | |
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -I${LIBS_DIR}/include" CPPFLAGS="-D_WIN32_WINNT=0x0501 -DNGHTTP2_STATICLIB -DUNICODE -D_UNICODE" LDFLAGS="-static -no-pthread -L${LIBS_DIR}/lib" LIBS="-liconv -lcrypt32 -lwinmm" PKG_CONFIG_PATH="${LIBS_DIR}/lib/pkgconfig" ./configure --enable-static --disable-shared --disable-pthreads --disable-libcurl-option --disable-openssl-auto-load-config --with-zlib --with-zstd --with-brotli --with-openssl --with-librtmp --with-libssh2 --with-nghttp2="${LIBS_DIR}" --with-libidn2 --with-gsasl --without-ca-bundle | |
make curl_LDFLAGS="-all-static -municode -mconsole -Wl,--trace" | |
strip -s src/curl.exe | |
popd | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Output | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
printf "\n==================== Output ====================\n\n" | |
readonly OUT_DIR="${BASE_DIR}/.bin/${MY_CPU}" | |
rm -rf "${OUT_DIR}" && mkdir -p "${OUT_DIR}" | |
pushd "${OUT_DIR}" | |
cp -vf "${CURL_DIR}/src/curl.exe" curl.exe | |
cp -vf "${LIBS_DIR}/.pkg/cacert.pem" curl-ca-bundle.crt | |
cp -vf "${LIBS_DIR}/.pkg/manpage.html" manpage.html | |
sed -n "/Configured to build curl\/libcurl:$/,/^[[:space:]]*Features:/p" "${CURL_DIR}/config.log" | sed -r "s/configure:[[:digit:]]+://" | sed -r "s/^[[:blank:]]*//" | unix2dos > config.log | |
mkdir -p "${OUT_DIR}/legal" | |
unix2dos -n "${BROT_DIR}/LICENSE" legal/brotli.LICENSE.txt | |
unix2dos -n "${BROT_DIR}/README.md" legal/brotli.README.md | |
unix2dos -n "${CURL_DIR}/CHANGES" legal/curl.CHANGES.txt | |
unix2dos -n "${CURL_DIR}/COPYING" legal/curl.COPYING.txt | |
unix2dos -n "${CURL_DIR}/README" legal/curl.README.txt | |
unix2dos -n "${GTXT_DIR}/AUTHORS" legal/gettext.AUTHORS.txt | |
unix2dos -n "${GTXT_DIR}/COPYING" legal/gettext.COPYING.txt | |
unix2dos -n "${GTXT_DIR}/README" legal/gettext.README.txt | |
unix2dos -n "${ICNV_DIR}/AUTHORS" legal/libiconv.AUTHORS.txt | |
unix2dos -n "${ICNV_DIR}/COPYING" legal/libiconv.COPYING.txt | |
unix2dos -n "${ICNV_DIR}/README" legal/libiconv.README | |
unix2dos -n "${IDN2_DIR}/AUTHORS" legal/libidn2.AUTHORS.txt | |
unix2dos -n "${IDN2_DIR}/COPYING" legal/libidn2.COPYING.txt | |
unix2dos -n "${IDN2_DIR}/README.md" legal/libidn2.README.md | |
unix2dos -n "${NGH2_DIR}/AUTHORS" legal/nghttp2.AUTHORS.txt | |
unix2dos -n "${NGH2_DIR}/COPYING" legal/nghttp2.COPYING.txt | |
unix2dos -n "${NGH2_DIR}/README.rst" legal/nghttp2.README.rst | |
unix2dos -n "${OSSL_DIR}/AUTHORS" legal/openssl.AUTHORS.txt | |
unix2dos -n "${OSSL_DIR}/LICENSE" legal/openssl.LICENSE.txt | |
unix2dos -n "${OSSL_DIR}/README" legal/openssl.README.txt | |
unix2dos -n "${RTMP_DIR}/COPYING" legal/librtmp.COPYING.txt | |
unix2dos -n "${RTMP_DIR}/README" legal/librtmp.README.txt | |
unix2dos -n "${SASL_DIR}/AUTHORS" legal/libgsasl.AUTHORS.txt | |
unix2dos -n "${SASL_DIR}/COPYING" legal/libgsasl.COPYING.txt | |
unix2dos -n "${SASL_DIR}/README" legal/libgsasl.README.txt | |
unix2dos -n "${SSH2_DIR}/COPYING" legal/libssh2.COPYING.txt | |
unix2dos -n "${SSH2_DIR}/README" legal/libssh2.README.txt | |
unix2dos -n "${ZLIB_DIR}/README" legal/zlib.README.txt | |
unix2dos -n "${ZSTD_DIR}/LICENSE" legal/zstandard.LICENSE.txt | |
unix2dos -n "${ZSTD_DIR}/README.md" legal/zstandard.README.md | |
mkdir -p "${OUT_DIR}/patch" | |
cp -vf "${BASE_DIR}/patch/"*.diff "${OUT_DIR}/patch" | |
find "${OUT_DIR}" -type f -exec chmod 444 "{}" \; | |
readonly zfile="${BASE_DIR}/curl-windows-${MY_CPU}.$(date +"%Y-%m-%d").zip" | |
rm -rf "${zfile}" && zip -v -r -9 "${zfile}" "." | |
chmod 444 "${zfile}" | |
popd | |
printf "\nCompleted.\n\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git "a/D:\\_Sandbox\\curl\\curl-x86\\lib\\getenv.c.orig" "b/D:\\_Sandbox\\curl\\curl-x86\\lib\\getenv.c" | |
index 92c5350..1d3b0cb 100644 | |
--- "a/lib/getenv.c" | |
+++ "b/lib/getenv.c" | |
@@ -24,25 +24,23 @@ | |
#include <curl/curl.h> | |
#include "curl_memory.h" | |
+#include "curlx.h" | |
#include "memdebug.h" | |
-static char *GetEnv(const char *variable) | |
+#ifdef WIN32 | |
+static TCHAR *GetEnv(const TCHAR *variable) | |
{ | |
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_APP) | |
- (void)variable; | |
- return NULL; | |
-#elif defined(WIN32) | |
/* This uses Windows API instead of C runtime getenv() to get the environment | |
variable since some changes aren't always visible to the latter. #4774 */ | |
- char *buf = NULL; | |
- char *tmp; | |
+ TCHAR *buf = NULL; | |
+ TCHAR *tmp; | |
DWORD bufsize; | |
DWORD rc = 1; | |
const DWORD max = 32768; /* max env var size from MSCRT source */ | |
for(;;) { | |
- tmp = realloc(buf, rc); | |
+ tmp = (TCHAR*)realloc(buf, rc * sizeof(TCHAR)); | |
if(!tmp) { | |
free(buf); | |
return NULL; | |
@@ -53,25 +51,44 @@ static char *GetEnv(const char *variable) | |
/* It's possible for rc to be 0 if the variable was found but empty. | |
Since getenv doesn't make that distinction we ignore it as well. */ | |
- rc = GetEnvironmentVariableA(variable, buf, bufsize); | |
+ rc = GetEnvironmentVariable(variable, buf, bufsize); | |
if(!rc || rc == bufsize || rc > max) { | |
free(buf); | |
return NULL; | |
} | |
/* if rc < bufsize then rc is bytes written not including null */ | |
- if(rc < bufsize) | |
+ if(rc < bufsize) { | |
return buf; | |
- | |
+ } | |
/* else rc is bytes needed, try again */ | |
} | |
+} | |
+#endif | |
+ | |
+char *curl_getenv(const char *variable) | |
+{ | |
+#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_APP) | |
+ (void)variable; | |
+ return NULL; | |
+#elif defined(WIN32) | |
+#ifdef UNICODE | |
+ char *value = NULL; | |
+ wchar_t *variable_w = curlx_convert_UTF8_to_wchar(variable); | |
+ if(variable_w) { | |
+ wchar_t *value_w = GetEnv(variable_w); | |
+ if(value_w) { | |
+ value = curlx_convert_wchar_to_UTF8(value_w); | |
+ free(value_w); | |
+ } | |
+ free(variable_w); | |
+ } | |
+ return value; | |
+#else | |
+ return GetEnv(variable); | |
+#endif | |
#else | |
char *env = getenv(variable); | |
return (env && env[0])?strdup(env):NULL; | |
#endif | |
} | |
- | |
-char *curl_getenv(const char *v) | |
-{ | |
- return GetEnv(v); | |
-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git "a/D:\\_Sandbox\\curl\\curl-src\\lib\\curl_threads.h.orig" "b/D:\\_Sandbox\\curl\\curl-src\\lib\\curl_threads.h" | |
index e10b7a1..22fdb49 100644 | |
--- "a/lib/curl_threads.h" | |
+++ "b/lib/curl_threads.h" | |
@@ -37,13 +37,7 @@ | |
# define curl_mutex_t CRITICAL_SECTION | |
# define curl_thread_t HANDLE | |
# define curl_thread_t_null (HANDLE)0 | |
-# if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \ | |
- (_WIN32_WINNT < _WIN32_WINNT_VISTA) || \ | |
- (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)) | |
-# define Curl_mutex_init(m) InitializeCriticalSection(m) | |
-# else | |
-# define Curl_mutex_init(m) InitializeCriticalSectionEx(m, 0, 1) | |
-# endif | |
+# define Curl_mutex_init(m) InitializeCriticalSection(m) | |
# define Curl_mutex_acquire(m) EnterCriticalSection(m) | |
# define Curl_mutex_release(m) LeaveCriticalSection(m) | |
# define Curl_mutex_destroy(m) DeleteCriticalSection(m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git "a/D:\\_Sandbox\\curl\\curl-src\\src\\tool_doswin.c.orig" "b/D:\\_Sandbox\\curl\\curl-src\\src\\tool_doswin.c" | |
index 98e13bc..9f83c16 100644 | |
--- "a/src/tool_doswin.c" | |
+++ "b/src/tool_doswin.c" | |
@@ -612,6 +612,37 @@ char **__crt0_glob_function(char *arg) | |
* HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SafeProcessSearchMode | |
*/ | |
+static BOOL check_file_exists(const TCHAR *filename) | |
+{ | |
+ const DWORD attr = GetFileAttributes(filename); | |
+ return (attr != INVALID_FILE_ATTRIBUTES) && (!(attr & FILE_ATTRIBUTE_DIRECTORY)); | |
+} | |
+ | |
+static char *execpath(const TCHAR *filename) | |
+{ | |
+ static const size_t BUFFSIZE = 512; | |
+ TCHAR filebuffer[BUFFSIZE]; | |
+ unsigned long len = GetModuleFileName(0, filebuffer, BUFFSIZE); | |
+ if((len > 0) && (len < BUFFSIZE)) { | |
+ TCHAR *lastdirchar = _tcsrchr(filebuffer, TEXT('\\')); | |
+ if(lastdirchar) { | |
+ *lastdirchar = TEXT('\0'); | |
+ } | |
+ if (_tcslen(filebuffer) + _tcslen(filename) + 2U < BUFFSIZE) { | |
+ _tcscat(filebuffer, TEXT("\\")); | |
+ _tcscat(filebuffer, filename); | |
+ if (check_file_exists(filebuffer)) { | |
+#ifdef UNICODE | |
+ return curlx_convert_wchar_to_UTF8(filebuffer); | |
+#else | |
+ return strdup(filebuffer); | |
+#endif | |
+ } | |
+ } | |
+ } | |
+ return NULL; | |
+} | |
+ | |
CURLcode FindWin32CACert(struct OperationConfig *config, | |
curl_sslbackend backend, | |
const TCHAR *bundle_file) | |
@@ -627,22 +658,10 @@ CURLcode FindWin32CACert(struct OperationConfig *config, | |
if((curlinfo->features & CURL_VERSION_SSL) && | |
backend != CURLSSLBACKEND_SCHANNEL) { | |
- DWORD res_len; | |
- TCHAR buf[PATH_MAX]; | |
- TCHAR *ptr = NULL; | |
- | |
- buf[0] = TEXT('\0'); | |
- | |
- res_len = SearchPath(NULL, bundle_file, NULL, PATH_MAX, buf, &ptr); | |
- if(res_len > 0) { | |
+ char *cacert = execpath(bundle_file); | |
+ if (cacert) { | |
Curl_safefree(config->cacert); | |
-#ifdef UNICODE | |
- config->cacert = curlx_convert_wchar_to_UTF8(buf); | |
-#else | |
- config->cacert = strdup(buf); | |
-#endif | |
- if(!config->cacert) | |
- result = CURLE_OUT_OF_MEMORY; | |
+ config->cacert = cacert; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git "a/D:\\_Sandbox\\curl\\curl-src\\src\\tool_parsecfg.c.orig" "b/D:\\_Sandbox\\curl\\curl-src\\src\\tool_parsecfg.c" | |
index d26774f..6b26101 100644 | |
--- "a/src/tool_parsecfg.c" | |
+++ "b/src/tool_parsecfg.c" | |
@@ -45,29 +45,22 @@ static const char *unslashquote(const char *line, char *param); | |
static bool my_get_line(FILE *fp, struct curlx_dynbuf *, bool *error); | |
#ifdef WIN32 | |
-static FILE *execpath(const char *filename) | |
+static FILE *execpath(const TCHAR *filename) | |
{ | |
- char filebuffer[512]; | |
- /* Get the filename of our executable. GetModuleFileName is already declared | |
- * via inclusions done in setup header file. We assume that we are using | |
- * the ASCII version here. | |
- */ | |
- unsigned long len = GetModuleFileNameA(0, filebuffer, sizeof(filebuffer)); | |
- if(len > 0 && len < sizeof(filebuffer)) { | |
- /* We got a valid filename - get the directory part */ | |
- char *lastdirchar = strrchr(filebuffer, '\\'); | |
+ static const size_t BUFFSIZE = 512; | |
+ TCHAR filebuffer[BUFFSIZE]; | |
+ unsigned long len = GetModuleFileName(0, filebuffer, BUFFSIZE); | |
+ if((len > 0) && (len < BUFFSIZE)) { | |
+ TCHAR *lastdirchar = _tcsrchr(filebuffer, TEXT('\\')); | |
if(lastdirchar) { | |
- size_t remaining; | |
- *lastdirchar = 0; | |
- /* If we have enough space, build the RC filename */ | |
- remaining = sizeof(filebuffer) - strlen(filebuffer); | |
- if(strlen(filename) < remaining - 1) { | |
- msnprintf(lastdirchar, remaining, "%s%s", DIR_CHAR, filename); | |
- return fopen(filebuffer, FOPEN_READTEXT); | |
- } | |
+ *lastdirchar = TEXT('\0'); | |
+ } | |
+ if (_tcslen(filebuffer) + _tcslen(filename) + 2U < BUFFSIZE) { | |
+ _tcscat(filebuffer, TEXT("\\")); | |
+ _tcscat(filebuffer, filename); | |
+ return _tfopen(filebuffer, TEXT(FOPEN_READTEXT)); | |
} | |
} | |
- | |
return NULL; | |
} | |
#endif | |
@@ -85,7 +78,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global) | |
if(!filename || !*filename) { | |
/* NULL or no file name attempts to load .curlrc from the homedir! */ | |
- char *home = homedir(".curlrc"); | |
+ char *home = NULL; /* homedir(".curlrc"); */ | |
#ifndef WIN32 | |
if(home) { | |
pathalloc = curl_maprintf("%s%s.curlrc", home, DIR_CHAR); | |
@@ -120,9 +113,9 @@ int parseconfig(const char *filename, struct GlobalConfig *global) | |
} | |
if(!filename) { | |
/* check for .curlrc then _curlrc in the dir of the executable */ | |
- file = execpath(".curlrc"); | |
+ file = execpath(TEXT(".curlrc")); | |
if(!file) | |
- file = execpath("_curlrc"); | |
+ file = execpath(TEXT("_curlrc")); | |
} | |
#endif | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git "a/D:\\_Sandbox\\curl\\curl-x86\\lib\\url.c.orig" "b/D:\\_Sandbox\\curl\\curl-x86\\lib\\url.c" | |
index 1ee38af..99c7740 100644 | |
--- "a/lib/url.c" | |
+++ "b/lib/url.c" | |
@@ -62,6 +62,14 @@ | |
#ifdef USE_LIBIDN2 | |
#include <idn2.h> | |
+#if defined(WIN32) && defined(UNICODE) | |
+#define IDN2_LOOKUP(name, host, flags) \ | |
+ idn2_lookup_u8((const uint8_t *)name, (uint8_t **)host, flags) | |
+#else | |
+#define IDN2_LOOKUP(name, host, flags) \ | |
+ idn2_lookup_ul((const char *)name, (char **)host, flags) | |
+#endif | |
+ | |
#elif defined(USE_WIN32_IDN) | |
/* prototype for curl_win32_idn_to_ascii() */ | |
bool curl_win32_idn_to_ascii(const char *in, char **out); | |
@@ -1577,12 +1585,12 @@ CURLcode Curl_idnconvert_hostname(struct Curl_easy *data, | |
#else | |
int flags = IDN2_NFC_INPUT; | |
#endif | |
- int rc = idn2_lookup_ul((const char *)host->name, &ace_hostname, flags); | |
+ int rc = IDN2_LOOKUP(host->name, &ace_hostname, flags); | |
if(rc != IDN2_OK) | |
/* fallback to TR46 Transitional mode for better IDNA2003 | |
compatibility */ | |
- rc = idn2_lookup_ul((const char *)host->name, &ace_hostname, | |
- IDN2_TRANSITIONAL); | |
+ rc = IDN2_LOOKUP(host->name, &ace_hostname, | |
+ IDN2_TRANSITIONAL); | |
if(rc == IDN2_OK) { | |
host->encalloc = (char *)ace_hostname; | |
/* change the name pointer to point to the encoded hostname */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
librtmp/dh.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
librtmp/handshake.h | 31 +++++++++++++++++++----------- | |
librtmp/hashswf.c | 30 ++++++++++++++++++----------- | |
librtmp/rtmp.c | 5 ----- | |
librtmp/rtmp_sys.h | 1 - | |
rtmpsrv.c | 3 --- | |
rtmpsuck.c | 8 -------- | |
thread.c | 6 +++--- | |
8 files changed, 96 insertions(+), 42 deletions(-) | |
diff --git a/librtmp/dh.h b/librtmp/dh.h | |
index 5fc3f32..da8259e 100644 | |
--- a/librtmp/dh.h | |
+++ b/librtmp/dh.h | |
@@ -253,20 +253,42 @@ DHInit(int nKeyBits) | |
if (!dh) | |
goto failed; | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
MP_new(dh->g); | |
if (!dh->g) | |
goto failed; | |
+#else | |
+ BIGNUM *g = NULL; | |
+ MP_new(g); | |
+ if (!g) | |
+ goto failed; | |
+#endif | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
MP_gethex(dh->p, P1024, res); /* prime P1024, see dhgroups.h */ | |
+#else | |
+ BIGNUM* p = NULL; | |
+ DH_get0_pqg(dh, (BIGNUM const**)&p, NULL, NULL); | |
+ MP_gethex(p, P1024, res); /* prime P1024, see dhgroups.h */ | |
+#endif | |
if (!res) | |
{ | |
goto failed; | |
} | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
MP_set_w(dh->g, 2); /* base 2 */ | |
+#else | |
+ MP_set_w(g, 2); /* base 2 */ | |
+ DH_set0_pqg(dh, p, NULL, g); | |
+#endif | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
dh->length = nKeyBits; | |
+#else | |
+ DH_set_length(dh, nKeyBits); | |
+#endif | |
return dh; | |
failed: | |
@@ -293,12 +315,24 @@ DHGenerateKey(MDH *dh) | |
MP_gethex(q1, Q1024, res); | |
assert(res); | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
res = isValidPublicKey(dh->pub_key, dh->p, q1); | |
+#else | |
+ BIGNUM const* pub_key = NULL; | |
+ BIGNUM const* p = NULL; | |
+ DH_get0_key(dh, &pub_key, NULL); | |
+ DH_get0_pqg(dh, &p, NULL, NULL); | |
+ res = isValidPublicKey((BIGNUM*)pub_key, (BIGNUM*)p, q1); | |
+#endif | |
if (!res) | |
{ | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
MP_free(dh->pub_key); | |
MP_free(dh->priv_key); | |
dh->pub_key = dh->priv_key = 0; | |
+#else | |
+ DH_free(dh); | |
+#endif | |
} | |
MP_free(q1); | |
@@ -314,15 +348,29 @@ static int | |
DHGetPublicKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen) | |
{ | |
int len; | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
if (!dh || !dh->pub_key) | |
+#else | |
+ BIGNUM const* pub_key = NULL; | |
+ DH_get0_key(dh, &pub_key, NULL); | |
+ if (!dh || !pub_key) | |
+#endif | |
return 0; | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
len = MP_bytes(dh->pub_key); | |
+#else | |
+ len = MP_bytes(pub_key); | |
+#endif | |
if (len <= 0 || len > (int) nPubkeyLen) | |
return 0; | |
memset(pubkey, 0, nPubkeyLen); | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
MP_setbin(dh->pub_key, pubkey + (nPubkeyLen - len), len); | |
+#else | |
+ MP_setbin(pub_key, pubkey + (nPubkeyLen - len), len); | |
+#endif | |
return 1; | |
} | |
@@ -364,7 +412,13 @@ DHComputeSharedSecretKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen, | |
MP_gethex(q1, Q1024, len); | |
assert(len); | |
+#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | |
if (isValidPublicKey(pubkeyBn, dh->p, q1)) | |
+#else | |
+ BIGNUM const* p = NULL; | |
+ DH_get0_pqg(dh, &p, NULL, NULL); | |
+ if (isValidPublicKey(pubkeyBn, (BIGNUM*)p, q1)) | |
+#endif | |
res = MDH_compute_key(secret, nPubkeyLen, pubkeyBn, dh); | |
else | |
res = -1; | |
diff --git a/librtmp/handshake.h b/librtmp/handshake.h | |
index 0438486..3522e0f 100644 | |
--- a/librtmp/handshake.h | |
+++ b/librtmp/handshake.h | |
@@ -31,9 +31,9 @@ | |
#define SHA256_DIGEST_LENGTH 32 | |
#endif | |
#define HMAC_CTX sha2_context | |
-#define HMAC_setup(ctx, key, len) sha2_hmac_starts(&ctx, (unsigned char *)key, len, 0) | |
-#define HMAC_crunch(ctx, buf, len) sha2_hmac_update(&ctx, buf, len) | |
-#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig) | |
+#define HMAC_setup(ctx, key, len) sha2_hmac_starts(ctx, (unsigned char *)key, len, 0) | |
+#define HMAC_crunch(ctx, buf, len) sha2_hmac_update(ctx, buf, len) | |
+#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(ctx, dig) | |
typedef arc4_context * RC4_handle; | |
#define RC4_alloc(h) *h = malloc(sizeof(arc4_context)) | |
@@ -50,9 +50,9 @@ typedef arc4_context * RC4_handle; | |
#endif | |
#undef HMAC_CTX | |
#define HMAC_CTX struct hmac_sha256_ctx | |
-#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(&ctx, len, key) | |
-#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(&ctx, len, buf) | |
-#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig) | |
+#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(ctx, len, key) | |
+#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(ctx, len, buf) | |
+#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(ctx, SHA256_DIGEST_LENGTH, dig) | |
#define HMAC_close(ctx) | |
typedef struct arcfour_ctx* RC4_handle; | |
@@ -64,14 +64,23 @@ typedef struct arcfour_ctx* RC4_handle; | |
#else /* USE_OPENSSL */ | |
#include <openssl/sha.h> | |
+#include <openssl/ossl_typ.h> | |
#include <openssl/hmac.h> | |
#include <openssl/rc4.h> | |
#if OPENSSL_VERSION_NUMBER < 0x0090800 || !defined(SHA256_DIGEST_LENGTH) | |
#error Your OpenSSL is too old, need 0.9.8 or newer with SHA256 | |
#endif | |
-#define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, EVP_sha256(), 0) | |
-#define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, buf, len) | |
-#define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, dig, &dlen); HMAC_CTX_cleanup(&ctx) | |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L | |
+#define HMAC_setup(ctx, key, len) HMAC_CTX_init(ctx); HMAC_Init_ex(ctx, key, len, EVP_sha256(), 0) | |
+#else | |
+#define HMAC_setup(ctx, key, len) ctx = HMAC_CTX_new(); HMAC_CTX_reset(ctx); HMAC_Init_ex(ctx, key, len, EVP_sha256(), 0) | |
+#endif | |
+#define HMAC_crunch(ctx, buf, len) HMAC_Update(ctx, buf, len) | |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L | |
+#define HMAC_finish(ctx, dig, dlen) HMAC_Final(ctx, dig, &dlen); HMAC_CTX_cleanup(ctx) | |
+#else | |
+#define HMAC_finish(ctx, dig, dlen) HMAC_Final(ctx, dig, &dlen); HMAC_CTX_free(ctx) | |
+#endif | |
typedef RC4_KEY * RC4_handle; | |
#define RC4_alloc(h) *h = malloc(sizeof(RC4_KEY)) | |
@@ -117,7 +126,7 @@ static void InitRC4Encryption | |
{ | |
uint8_t digest[SHA256_DIGEST_LENGTH]; | |
unsigned int digestLen = 0; | |
- HMAC_CTX ctx; | |
+ HMAC_CTX* ctx = NULL; | |
RC4_alloc(rc4keyIn); | |
RC4_alloc(rc4keyOut); | |
@@ -266,7 +275,7 @@ HMACsha256(const uint8_t *message, size_t messageLen, const uint8_t *key, | |
size_t keylen, uint8_t *digest) | |
{ | |
unsigned int digestLen; | |
- HMAC_CTX ctx; | |
+ HMAC_CTX* ctx = NULL; | |
HMAC_setup(ctx, key, keylen); | |
HMAC_crunch(ctx, message, messageLen); | |
diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c | |
index 32b2eed..9a5fda3 100644 | |
--- a/librtmp/hashswf.c | |
+++ b/librtmp/hashswf.c | |
@@ -37,9 +37,9 @@ | |
#define SHA256_DIGEST_LENGTH 32 | |
#endif | |
#define HMAC_CTX sha2_context | |
-#define HMAC_setup(ctx, key, len) sha2_hmac_starts(&ctx, (unsigned char *)key, len, 0) | |
-#define HMAC_crunch(ctx, buf, len) sha2_hmac_update(&ctx, buf, len) | |
-#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig) | |
+#define HMAC_setup(ctx, key, len) sha2_hmac_starts(ctx, (unsigned char *)key, len, 0) | |
+#define HMAC_crunch(ctx, buf, len) sha2_hmac_update(ctx, buf, len) | |
+#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(ctx, dig) | |
#define HMAC_close(ctx) | |
#elif defined(USE_GNUTLS) | |
#include <nettle/hmac.h> | |
@@ -48,19 +48,27 @@ | |
#endif | |
#undef HMAC_CTX | |
#define HMAC_CTX struct hmac_sha256_ctx | |
-#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(&ctx, len, key) | |
-#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(&ctx, len, buf) | |
-#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig) | |
+#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(ctx, len, key) | |
+#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(ctx, len, buf) | |
+#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(ctx, SHA256_DIGEST_LENGTH, dig) | |
#define HMAC_close(ctx) | |
#else /* USE_OPENSSL */ | |
#include <openssl/ssl.h> | |
#include <openssl/sha.h> | |
#include <openssl/hmac.h> | |
#include <openssl/rc4.h> | |
-#define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, (unsigned char *)key, len, EVP_sha256(), 0) | |
-#define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, (unsigned char *)buf, len) | |
-#define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, (unsigned char *)dig, &dlen); | |
-#define HMAC_close(ctx) HMAC_CTX_cleanup(&ctx) | |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L | |
+#define HMAC_setup(ctx, key, len) HMAC_CTX_init(ctx); HMAC_Init_ex(ctx, (unsigned char *)key, len, EVP_sha256(), 0) | |
+#else | |
+#define HMAC_setup(ctx, key, len) ctx = HMAC_CTX_new(); HMAC_CTX_reset(ctx); HMAC_Init_ex(ctx, key, len, EVP_sha256(), 0) | |
+#endif | |
+#define HMAC_crunch(ctx, buf, len) HMAC_Update(ctx, (unsigned char *)buf, len) | |
+#define HMAC_finish(ctx, dig, dlen) HMAC_Final(ctx, (unsigned char *)dig, &dlen); | |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L | |
+#define HMAC_close(ctx) HMAC_CTX_cleanup(ctx) | |
+#else | |
+#define HMAC_close(ctx) HMAC_CTX_reset(ctx); HMAC_CTX_free(ctx) | |
+#endif | |
#endif | |
extern void RTMP_TLS_Init(); | |
@@ -298,7 +306,7 @@ leave: | |
struct info | |
{ | |
z_stream *zs; | |
- HMAC_CTX ctx; | |
+ HMAC_CTX *ctx; | |
int first; | |
int zlib; | |
int size; | |
diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c | |
index 0865689..24f61ba 100644 | |
--- a/librtmp/rtmp.c | |
+++ b/librtmp/rtmp.c | |
@@ -1902,7 +1902,6 @@ SendFCUnpublish(RTMP *r) | |
SAVC(publish); | |
SAVC(live); | |
-SAVC(record); | |
static int | |
SendPublish(RTMP *r) | |
@@ -2904,8 +2903,6 @@ AVC("NetStream.Play.PublishNotify"); | |
static const AVal av_NetStream_Play_UnpublishNotify = | |
AVC("NetStream.Play.UnpublishNotify"); | |
static const AVal av_NetStream_Publish_Start = AVC("NetStream.Publish.Start"); | |
-static const AVal av_NetConnection_Connect_Rejected = | |
-AVC("NetConnection.Connect.Rejected"); | |
/* Returns 0 for OK/Failed/error, 1 for 'Stop or Complete' */ | |
static int | |
@@ -3552,7 +3549,6 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet) | |
uint8_t hbuf[RTMP_MAX_HEADER_SIZE] = { 0 }; | |
char *header = (char *)hbuf; | |
int nSize, hSize, nToRead, nChunk; | |
- int didAlloc = FALSE; | |
int extendedTimestamp; | |
RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d", __FUNCTION__, r->m_sb.sb_socket); | |
@@ -3679,7 +3675,6 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet) | |
RTMP_Log(RTMP_LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__); | |
return FALSE; | |
} | |
- didAlloc = TRUE; | |
packet->m_headerType = (hbuf[0] & 0xc0) >> 6; | |
} | |
diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h | |
index 85d7e53..32c2bde 100644 | |
--- a/librtmp/rtmp_sys.h | |
+++ b/librtmp/rtmp_sys.h | |
@@ -37,7 +37,6 @@ | |
#define GetSockError() WSAGetLastError() | |
#define SetSockError(e) WSASetLastError(e) | |
#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e) | |
-#define EWOULDBLOCK WSAETIMEDOUT /* we don't use nonblocking, but we do use timeouts */ | |
#define sleep(n) Sleep(n*1000) | |
#define msleep(n) Sleep(n) | |
#define SET_RCVTIMEO(tv,s) int tv = s*1000 | |
diff --git a/rtmpsrv.c b/rtmpsrv.c | |
index 5df4d3a..17ffd9e 100644 | |
--- a/rtmpsrv.c | |
+++ b/rtmpsrv.c | |
@@ -152,11 +152,9 @@ SAVC(flashVer); | |
SAVC(swfUrl); | |
SAVC(pageUrl); | |
SAVC(tcUrl); | |
-SAVC(fpad); | |
SAVC(capabilities); | |
SAVC(audioCodecs); | |
SAVC(videoCodecs); | |
-SAVC(videoFunction); | |
SAVC(objectEncoding); | |
SAVC(_result); | |
SAVC(createStream); | |
@@ -167,7 +165,6 @@ SAVC(mode); | |
SAVC(level); | |
SAVC(code); | |
SAVC(description); | |
-SAVC(secureToken); | |
static int | |
SendConnectResult(RTMP *r, double txn) | |
diff --git a/rtmpsuck.c b/rtmpsuck.c | |
index e886179..c2b869c 100644 | |
--- a/rtmpsuck.c | |
+++ b/rtmpsuck.c | |
@@ -124,21 +124,13 @@ SAVC(flashVer); | |
SAVC(swfUrl); | |
SAVC(pageUrl); | |
SAVC(tcUrl); | |
-SAVC(fpad); | |
-SAVC(capabilities); | |
SAVC(audioCodecs); | |
SAVC(videoCodecs); | |
-SAVC(videoFunction); | |
SAVC(objectEncoding); | |
-SAVC(_result); | |
-SAVC(createStream); | |
SAVC(play); | |
SAVC(closeStream); | |
-SAVC(fmsVer); | |
-SAVC(mode); | |
SAVC(level); | |
SAVC(code); | |
-SAVC(secureToken); | |
SAVC(onStatus); | |
SAVC(close); | |
static const AVal av_NetStream_Failed = AVC("NetStream.Failed"); | |
diff --git a/thread.c b/thread.c | |
index 0913c98..9de42ea 100644 | |
--- a/thread.c | |
+++ b/thread.c | |
@@ -29,13 +29,13 @@ | |
HANDLE | |
ThreadCreate(thrfunc *routine, void *args) | |
{ | |
- HANDLE thd; | |
+ uintptr_t thd; | |
- thd = (HANDLE) _beginthread(routine, 0, args); | |
+ thd = _beginthread(routine, 0, args); | |
if (thd == -1L) | |
RTMP_LogPrintf("%s, _beginthread failed with %d\n", __FUNCTION__, errno); | |
- return thd; | |
+ return (HANDLE) thd; | |
} | |
#else | |
pthread_t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git "a/D:\\_Sandbox\\curl\\libssh2-x64\\src\\session.c.orig" "b/D:\\_Sandbox\\curl\\libssh2-x64\\src\\session.c" | |
index e439acd..476a497 100644 | |
--- "a/src/session.c" | |
+++ "b/src/session.c" | |
@@ -58,6 +58,8 @@ | |
#include "mac.h" | |
#include "misc.h" | |
+#define DIFFTIME(_b,_a) ((double)((_b) - (_a))) | |
+ | |
/* libssh2_default_alloc | |
*/ | |
static | |
@@ -610,7 +612,7 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session, time_t start_time) | |
(seconds_to_next == 0 || | |
ms_to_next > session->api_timeout)) { | |
time_t now = time(NULL); | |
- elapsed_ms = (long)(1000*difftime(now, start_time)); | |
+ elapsed_ms = (long)(1000*DIFFTIME(now, start_time)); | |
if(elapsed_ms > session->api_timeout) { | |
return _libssh2_error(session, LIBSSH2_ERROR_TIMEOUT, | |
"API timeout expired"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl-windows-x86.2021-06-20.zip
curl-windows-x64.2021-06-20.zip