Skip to content

Commit

Permalink
Merge pull request #18 from rryan/2.1.x-windows-libshout-patch
Browse files Browse the repository at this point in the history
Add a patch to fix libshout ticket #2244 / LP Bug #1544739.
  • Loading branch information
rryan authored Jan 24, 2017
2 parents 1823aec + 493185a commit ce9b43e
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 20 deletions.
113 changes: 113 additions & 0 deletions build/libshout-2.4.1/fix_libshout_ticket2244.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
diff -b -u -r libshout-2.4.1-a/src/shout.c libshout-2.4.1-b/src/shout.c
--- libshout-2.4.1-a/src/shout.c 2015-11-09 06:54:12.000000000 -0500
+++ libshout-2.4.1-b/src/shout.c 2016-11-25 23:08:02.000000000 -0500
@@ -130,6 +130,7 @@
return NULL;
}
self->tls_mode = SHOUT_TLS_AUTO;
+ self->tls_mode_used = SHOUTERR_NOTLS;
#endif

self->port = LIBSHOUT_DEFAULT_PORT;
@@ -378,7 +379,7 @@
return SHOUTERR_NOCONNECT;

#ifdef HAVE_OPENSSL
- switch (self->tls_mode) {
+ switch (self->tls_mode_used) {
case SHOUT_TLS_DISABLED:
/* nothing to do */
break;
@@ -1157,22 +1158,45 @@

case SHOUT_STATE_TLS_PENDING:
#ifdef HAVE_OPENSSL
- if (self->tls_mode == SHOUT_TLS_DISABLED) {
- /* nothing to be done */
- } else if (self->tls_mode == SHOUT_TLS_AUTO || self->tls_mode == SHOUT_TLS_AUTO_NO_PLAIN) {
+ if (self->tls_mode_used < 0) {
+ switch (self->tls_mode) {
+ case SHOUT_TLS_DISABLED:
+ case SHOUT_TLS_RFC2818:
+ case SHOUT_TLS_RFC2817:
+ self->tls_mode_used = self->tls_mode;
+ break;
+ case SHOUT_TLS_AUTO:
+ case SHOUT_TLS_AUTO_NO_PLAIN:
if (self->server_caps & LIBSHOUT_CAP_GOTCAPS) {
- /* We had a probe allready, otherwise just do nothing to poke the server. */
+ /* We had a probe allready, otherwise just poke the server. */
if (self->server_caps & LIBSHOUT_CAP_UPGRADETLS) {
- self->tls_mode = SHOUT_TLS_RFC2817;
+ self->tls_mode_used = SHOUT_TLS_RFC2817;
} else {
- if (self->tls_mode == SHOUT_TLS_AUTO_NO_PLAIN)
+ if (self->tls_mode == SHOUT_TLS_AUTO_NO_PLAIN) {
+ self->tls_mode_used = SHOUTERR_NOTLS;
return SHOUTERR_NOTLS;
- self->tls_mode = SHOUT_TLS_DISABLED;
+ }
+ self->tls_mode_used = SHOUT_TLS_DISABLED;
}
self->state = SHOUT_STATE_TLS_PENDING;
goto retry;
+ } else {
+ /* TODO: do something. */
+ if (self->tls_mode == SHOUT_TLS_AUTO_NO_PLAIN) {
+ self->tls_mode_used = SHOUTERR_NOTLS;
+ return SHOUTERR_NOTLS;
+ }
+ self->tls_mode_used = SHOUT_TLS_DISABLED;
}
- } else if (self->tls_mode == SHOUT_TLS_RFC2818 || self->upgrade_to_tls) {
+ break;
+ default:
+ rc = SHOUTERR_INSANE;
+ goto failure;
+ break;
+
+ }
+ }
+ if (self->tls_mode_used == SHOUT_TLS_RFC2818 || self->upgrade_to_tls) {
if (!self->tls) {
self->tls = shout_tls_new(self, self->socket);
if (!self->tls) /* just guessing that it's a malloc error */
@@ -1183,7 +1207,7 @@
return SHOUTERR_BUSY;
goto failure;
}
- } else if (self->tls_mode == SHOUT_TLS_RFC2817) {
+ } else if (self->tls_mode_used == SHOUT_TLS_RFC2817) {
if ((rc = shout_create_http_request_upgrade(self, "TLS/1.0")) != SHOUTERR_SUCCESS) {
if (rc == SHOUTERR_BUSY)
return SHOUTERR_BUSY;
@@ -1191,9 +1215,6 @@
}
self->state = SHOUT_STATE_REQ_PENDING;
goto retry;
- } else {
- rc = SHOUTERR_INSANE;
- goto failure;
}
#endif
self->state = SHOUT_STATE_REQ_CREATION;
@@ -1233,7 +1254,7 @@
} else if (rc == SHOUTERR_SOCKET && !(self->server_caps & LIBSHOUT_CAP_GOTCAPS) &&
(self->tls_mode == SHOUT_TLS_AUTO || self->tls_mode == SHOUT_TLS_AUTO_NO_PLAIN)) {
self->state = SHOUT_STATE_RECONNECT;
- self->tls_mode = SHOUT_TLS_RFC2818;
+ self->tls_mode_used = SHOUT_TLS_RFC2818;
goto retry;
#endif
}
diff -b -u -r libshout-2.4.1-a/src/shout_private.h libshout-2.4.1-b/src/shout_private.h
--- libshout-2.4.1-a/src/shout_private.h 2015-11-09 06:54:12.000000000 -0500
+++ libshout-2.4.1-b/src/shout_private.h 2016-11-25 23:08:09.000000000 -0500
@@ -130,6 +130,7 @@
#ifdef HAVE_OPENSSL
int upgrade_to_tls;
int tls_mode;
+ int tls_mode_used;
char *ca_directory;
char *ca_file;
char *allowed_ciphers;
55 changes: 37 additions & 18 deletions build_environment.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,54 @@ SET "PROGRAMFILES_PATH=%ProgramFiles(x86)%"

rem ====== Edit to suit your environment =========
SET VCVERSION=140
SET "MSVC_PATH=%PROGRAMFILES_PATH%\Microsoft Visual Studio 14.0\VC"
SET "BUILDTOOLS_PATH=%PROGRAMFILES_PATH%\Microsoft Visual C++ Build Tools"

REM Allow overriding MSSDKS_PATH from outside this script.
IF "%MSSDKS_PATH%" == "" (
set "MSSDKS_PATH=%PROGRAMFILES_PATH%\Microsoft SDKs"
)

REM Allow overriding MSVC_PATH from outside this script.
IF "%MSVC_PATH%" == "" (
SET "MSVC_PATH=%PROGRAMFILES_PATH%\Microsoft Visual Studio 14.0"
)

REM Allow overriding BUILDTOOLS_PATH from outside this script.
if "%BUILDTOOLS_PATH%" == "" (
SET "BUILDTOOLS_PATH=%PROGRAMFILES_PATH%\Microsoft Visual C++ Build Tools"
)

REM Allow overriding CMAKEDIR from outside this script.
if "%CMAKEDIR%" == "" (
SET "CMAKEDIR=%PROGRAMFILES_PATH%\CMake\bin"
)

REM with two slashes at the end
SET "PLAT_TARGETS_PATH=%PROGRAMFILES_PATH%\MSBuild\Microsoft.Cpp\v4.0\V140\\"
SET "CMAKEDIR=%PROGRAMFILES_PATH%\CMake\bin"
SET "NASMPATH=%CD%\bin"

REM Verify paths.
IF EXIST "%MSVC_PATH%" (
SET "BUILDTOOLS_PATH=%MSVC_PATH%"
SET "BUILDTOOLS_PATH=%MSVC_PATH%\VC"
SET BUILDTOOLS_SCRIPT=vcvarsall.bat
SET MSBUILD=msbuild /nologo /m /p:PlatformToolset=v%VCVERSION%_xp /p:RuntimeLibrary=%RUNTIMELIB%

REM Check whether we have a 64-bit compiler available.
IF EXIST "%MSVC_PATH%\VC\bin\amd64\cl.exe" (
SET COMPILER_X86=amd64_x86
SET COMPILER_X64=amd64
) ELSE (
REM NOTE(rryan): Temporarily disabled because the build doesn't work with a 64-bit compiler.
rem IF EXIST "%MSVC_PATH%\VC\bin\amd64\cl.exe" (
rem SET COMPILER_X86=amd64_x86
rem SET COMPILER_X64=amd64
rem ) ELSE (
SET COMPILER_X86=x86
SET COMPILER_X64=x86_amd64
)
rem )

) ELSE (
IF EXIST "%BUILDTOOLS_PATH%" (
SET BUILDTOOLS_SCRIPT=vcbuildtools.bat
SET MSBUILD=msbuild /m /p:PlatformToolset=v140_xp /p:VCTargetsPath="%PLAT_TARGETS_PATH%"
rem If building for XP and using the C++ Build Tools package (not full VS,)
rem install the Windows 7.1 SDK and adjust the following if needed
SET "WindowsSdkDir_71A=%PROGRAMFILES_PATH%\Microsoft SDKs\Windows\v7.1A\"
SET "WindowsSdkDir_71A=%MSSDKS_PATH%\Windows\v7.1A\"

SET COMPILER_X86=amd64_x86
SET COMPILER_X64=amd64
Expand All @@ -62,8 +81,8 @@ REM END EXIST BUILDTOOLS
REM END EXIST VISUALSTUDIO

if NOT EXIST "%CMAKEDIR%" (
set "CMAKEDIROLD=%CMAKEDIR%"
set "CMAKEDIR=%ProgramFiles%\CMake\bin"
set "CMAKEDIROLD=%CMAKEDIR%"
set "CMAKEDIR=%ProgramFiles%\CMake\bin"
)
if NOT EXIST "%CMAKEDIR%" (
echo.
Expand Down Expand Up @@ -209,7 +228,7 @@ set _LINK_=/DEBUG
if %CONFIG_RELEASE% (
if %CONFIG_FASTBUILD% (
REM In fastbuild mode, disable /GL (whole program optimization) and /LTCG (link-time code generation).
set _CL_=%_CL_% /GL-
set _CL_=%_CL_% /GL-
REM /DEBUG defaults /OPT:REF and /OPT:ICF to off, so enable them explicitly.
set _LINK_=%_LINK_% /LTCG:OFF /OPT:REF /OPT:ICF
) else (
Expand All @@ -234,9 +253,9 @@ SET BUILD_DIR=%CD%\build\

REM Everyting prepared. Setup the compiler.
if %MACHINE_X86% (
call "%BUILDTOOLS_PATH%\%BUILDTOOLS_SCRIPT%" %COMPILER_X86%
call "%BUILDTOOLS_PATH%\%BUILDTOOLS_SCRIPT%" %COMPILER_X86%
) else (
call "%BUILDTOOLS_PATH%\%BUILDTOOLS_SCRIPT%" %COMPILER_X64%
call "%BUILDTOOLS_PATH%\%BUILDTOOLS_SCRIPT%" %COMPILER_X64%
)

REM The Visual C++ compiler (cl.exe) recognizes certain environment variables, specifically LIB, LIBPATH, PATH, and INCLUDE
Expand Down Expand Up @@ -344,9 +363,9 @@ ENDLOCAL

REM Copy debug runtime DLLs for debug builds.
if not %CONFIG_RELEASE% (
%XCOPY% "%MSVC_PATH%\redist\Debug_NonRedist\%MACHINE_X%\Microsoft.VC%VCVERSION%.DebugCRT\*.dll" %LIB_DIR%
%XCOPY% "%MSVC_PATH%\redist\Debug_NonRedist\%MACHINE_X%\Microsoft.VC%VCVERSION%.DebugCXXAMP\*.dll" %LIB_DIR%
%XCOPY% "%MSVC_PATH%\redist\Debug_NonRedist\%MACHINE_X%\Microsoft.VC%VCVERSION%.DebugOpenMP\*.dll" %LIB_DIR%
%XCOPY% "%MSVC_PATH%\VC\redist\Debug_NonRedist\%MACHINE_X%\Microsoft.VC%VCVERSION%.DebugCRT\*.dll" %LIB_DIR%
%XCOPY% "%MSVC_PATH%\VC\redist\Debug_NonRedist\%MACHINE_X%\Microsoft.VC%VCVERSION%.DebugCXXAMP\*.dll" %LIB_DIR%
%XCOPY% "%MSVC_PATH%\VC\redist\Debug_NonRedist\%MACHINE_X%\Microsoft.VC%VCVERSION%.DebugOpenMP\*.dll" %LIB_DIR%
)
echo.
echo.
Expand Down
11 changes: 9 additions & 2 deletions build_libshout.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ if %MACHINE_X86% (
set OUTPUT_PATH=%PLATFORM%\%CONFIG%
)

cd build\%SHOUT_PATH%\win32
cd build\%SHOUT_PATH%

REM Apply patch fixing:
REM https://trac.xiph.org/ticket/2244
REM https://bugs.launchpad.net/mixxx/+bug/1544739
%BIN_DIR%\patch.exe -N -p1 --verbose < fix_libshout_ticket2244.patch

cd win32
%MSBUILD% libshout.sln /p:Configuration=%CONFIG% /p:Platform=%PLATFORM% /t:libshout:Clean;libshout:Rebuild
IF ERRORLEVEL 1 (
SET VALRETURN=1
Expand All @@ -41,4 +48,4 @@ cd %ROOT_DIR%
REM the GOTO command resets the errorlevel and the endlocal resets the local environment,
REM so I have to use this workaround
ENDLOCAL & SET VALRETURN=%VALRETURN%
exit /b %VALRETURN%
exit /b %VALRETURN%

0 comments on commit ce9b43e

Please sign in to comment.