curl / Mailing Lists / curl-library / Single Mail

curl-library

Minor bugs in curl-7.58.0, plus fixes/changes for Windows builds (fwd)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 22 Feb 2018 00:13:28 +0100 (CET)

Hey,

I fell over this email that I received from Stefan Kanthak a while ago but
forgot about. A list of flaws/fixes he suggests we do.

As I'm not a windows developer and my knowledge and experience about building
on windows is a bit lacking to say the least, I'm posting it here and hoping
for some help with dealing with these suggestions!

-- 
  / daniel.haxx.se
---------- Forwarded message ----------
Date: Wed, 24 Jan 2018 11:53:59
From: Stefan Kanthak
Subject: Minor bugs in curl-7.58.0, plus fixes/changes for Windows builds
Hi,
0. the file "curl-7.58.0/projects/README" references
|  Microsoft Internationalized Domain Name (IDN) Mitigation APIs:
|  <https://www.microsoft.com/en-us/download/details.aspx?id=734>
    This download is not available any more since quite some time
    (almost 2 years, IIRC).
For the Windows build, please incorporate the following changes:
1. download <https://curl.haxx.se/favicon.ico> and save it as
    "curl.ico" in the top level directory
2. add the file "lib/libcurl.manifest" to disable DLL hijacking
    per external manifest, and more
---
+++ curl-patch/lib/libcurl.manifest
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
+    <assemblyIdentity language="en-US" name="cURL" processorArchitecture="*" type="win32" version="7.58.0.0"/>
                                                                                                     ~~~~~~~~
+    <description>libcurl Shared Library</description>
+    <file name="advapi32.dll" loadFrom="%SystemRoot%\system32\advapi32.dll" />
+    <file name="crypt32.dll" loadFrom="%SystemRoot%\system32\crypt32.dll" />
+    <file name="kernel32.dll" loadFrom="%SystemRoot%\system32\kernel32.dll" />
+    <file name="wldap32.dll" loadFrom="%SystemRoot%\system32\wldap32.dll" />
+    <file name="ws2_32.dll" loadFrom="%SystemRoot%\system32\ws2_32.dll" />
+</assembly>
    NOTE: the underlined version string MUST reflect cURL's current version!
3. apply the following changes to file "lib\libcurl.rc" to include
    icon and manifest
--- curl-7.58.0/lib/libcurl.rc    2017-12-03 00:33
+++ curl-patch/lib/libcurl.rc
@@ -22,4 +22,9 @@
+#include <winuser.h>
  #include <winver.h>
  #include "tool_version.h"
-LANGUAGE  0x09,0x01
+LANGUAGE 0, 0
+
+1 ICON "../curl.ico"
+
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../lib/libcurl.manifest"
    NOTE: ALL resources used with cURL are language-independent!
4. add the file "src/curl.manifest" to disable DLL hijacking
    per external manifest, and more
---
+++ curl-patch/src/curl.manifest
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
+    <assemblyIdentity language="en-US" name="cURL" processorArchitecture="*" type="win32" version="7.58.0.0"/>
                                                                                                     ~~~~~~~~
+    <description>The cURL executable</description>
+    <file name="advapi32.dll" loadFrom="%SystemRoot%\system32\advapi32.dll" />
+    <file name="crypt32.dll" loadFrom="%SystemRoot%\system32\crypt32.dll" />
+    <file name="kernel32.dll" loadFrom="%SystemRoot%\system32\kernel32.dll" />
+    <file name="wldap32.dll" loadFrom="%SystemRoot%\system32\wldap32.dll" />
+    <file name="ws2_32.dll" loadFrom="%SystemRoot%\system32\ws2_32.dll" />
+</assembly>
    NOTE: the underlined version string MUST reflect cURL's current version!
5. apply the following changes to file "src\curl.rc" to include
    icon and manifest
--- curl-7.58.0/src/curl.rc    2017-12-03 00:33
+++ curl-patch/src/curl.rc
@@ -22,4 +22,9 @@
+#include <winuser.h>
  #include <winver.h>
  #include "tool_version.h"
-LANGUAGE  0x09,0x01
+LANGUAGE 0, 0
+
+1 ICON "../curl.ico"
+
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../src/curl.manifest"
    NOTE: ALL resources used with cURL are language-independent!
6. apply the following change to "lib/config-win32.h" to fix
    build errors
--- curl-7.58.0/lib/config-win32.h    2018-01-22 09:55
+++ curl-patch/lib/config-win32.h
@@ -719,1 +719,1 @@
-#elif defined(_M_X64) || defined(__x86_64__) /* x86_64 (MSVC >=2005 or gcc) */
+#elif defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) /* x86_64 (MSVC >=2005 or gcc) */
    According to "curl-7.58.0/projects/README" the platform SDK
    for Windows Server 2003 SP1 (which contains the VC7 and pre-VC8
    compiler and linker) can be used to build cURL.
    This but fails unless the existence of the macro _M_AMD64 is
    tested in "lib/config-win32.h"!
7. apply the following changes to "winbuild/MakefileBuild.vc" to
    fix build errors
--- curl-7.58.0/winbuild/MakefileBuild.vc    2018-01-22 09:55
+++ curl-patch/winbuild/MakefileBuild.vc
@@ -75,1 +75,7 @@
-WIN_LIBS    = ws2_32.lib wldap32.lib advapi32.lib
+!IF "$(VC)"=="7"
+WIN_LIBS    = ws2_32.lib wldap32.lib bufferoverflowu.lib advapi32.lib
+!ELSEIF "$(VC)"=="8"
+WIN_LIBS    = ws2_32.lib wldap32.lib bufferoverflowu.lib advapi32.lib
+!ELSE
+WIN_LIBS    = ws2_32.lib wldap32.lib advapi32.lib
+!ENDIF
    According to "curl-7.58.0/projects/README" the platform SDK
    for Windows Server 2003 SP1 (which contains the VC7 and pre-VC8
    compiler and linker) can be used to build cURL.
    This but fails unless bufferoverflowu.lib is added to WIN_LIBS
--- curl-7.58.0/winbuild/MakefileBuild.vc    2018-01-22 09:55
+++ curl-patch/winbuild/MakefileBuild.vc
@@ -112,2 +112,2 @@
-CFLAGS         = $(CFLAGS) /I"$(DEVEL_INCLUDE)"
-LFLAGS         = $(LFLAGS) "/LIBPATH:$(DEVEL_LIB)"
+CFLAGS         = $(CFLAGS) /I"$(DEVEL_INCLUDE)" /GA /GF /Gy
+LFLAGS         = $(LFLAGS) /LIBPATH:"$(DEVEL_LIB)" /DYNAMICBASE /FIXED:NO /NXCOMPAT /RELEASE
    Explicitly enable string pooling, COMDATs, ASLR and DEP
    alias "no execute"!
--- curl-7.58.0/winbuild/MakefileBuild.vc    2018-01-22 09:55
+++ curl-patch/winbuild/MakefileBuild.vc
@@ -270,1 +270,1 @@
-MANIFESTTOOL = mt -manifest $(DIRDIST)\bin\$(PROGRAM_NAME).manifest -outputresource:$(DIRDIST)\bin\$(PROGRAM_NAME);1
+MANIFESTTOOL = mt.exe -manifest $(DIRDIST)\bin\$(PROGRAM_NAME).manifest -outputresource:$(DIRDIST)\bin\$(PROGRAM_NAME);1
    Always use .exe file extension!
--- curl-7.58.0/winbuild/MakefileBuild.vc    2018-01-22 09:55
+++ curl-patch/winbuild/MakefileBuild.vc
@@ -498,2 +498,2 @@
-$(LIB_DIROBJ)\libcurl.res: $(LIBCURL_SRC_DIR)\libcurl.rc
-rc $(RC_FLAGS)
+$(LIB_DIROBJ)\libcurl.res: $(LIBCURL_SRC_DIR)\libcurl.rc $(LIBCURL_SRC_DIR)\libcurl.manifest ..\curl.ico
+rc.exe $(RC_FLAGS)
    Add dependency for manifest and icon,
    and always use .exe file extension!
--- curl-7.58.0/winbuild/MakefileBuild.vc    2018-01-22 09:55
+++ curl-patch/winbuild/MakefileBuild.vc
@@ -534,8 +534,8 @@
-$(CURL_DIROBJ)\nonblock.obj: ../lib/nonblock.c
-$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/nonblock.c
-$(CURL_DIROBJ)\strtoofft.obj: ../lib/strtoofft.c
-$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/strtoofft.c
-$(CURL_DIROBJ)\warnless.obj: ../lib/warnless.c
-$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/warnless.c
-$(CURL_DIROBJ)\curl.res: $(CURL_SRC_DIR)\curl.rc
-rc $(CURL_RC_FLAGS)
+$(CURL_DIROBJ)\nonblock.obj: $(LIBCURL_SRC_DIR)\nonblock.c
+$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" $(LIBCURL_SRC_DIR)\nonblock.c
+$(CURL_DIROBJ)\strtoofft.obj: $(LIBCURL_SRC_DIR)\strtoofft.c
+$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" $(LIBCURL_SRC_DIR)\strtoofft.c
+$(CURL_DIROBJ)\warnless.obj: $(LIBCURL_SRC_DIR)\warnless.c
+$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" $(LIBCURL_SRC_DIR)\warnless.c
+$(CURL_DIROBJ)\curl.res: $(CURL_SRC_DIR)\curl.rc $(CURL_SRC_DIR)\curl.manifest ..\curl.ico
+rc.exe $(CURL_RC_FLAGS)
    Use macro LIBCURL_SRC_DIR instead of ../lib/,
    and always use .exe file extension!
8. apply the following changes to "winbuild/Makefile.vc" to fix
    build errors when AppLocker or SAFER alias Software Restriction
    Policies are in effect
--- curl-7.58.0/winbuild/Makefile.vc    2018-01-22 09:55
+++ curl-patch/winbuild/Makefile.vc
@@ -251,1 +251,1 @@
-    @gen_resp_file.bat $(LIBCURL_OBJS)
+    @CALL gen_resp_file.bat $(LIBCURL_OBJS)
--- curl-7.58.0/winbuild/Makefile.vc    2018-01-22 09:55
+++ curl-patch/winbuild/Makefile.vc
@@ -256,1 +256,1 @@
-    @gen_resp_file.bat $(CURL_OBJS)
+    @CALL gen_resp_file.bat $(CURL_OBJS)
    Always use CALL to run batch scripts!
regards
Stefan Kanthak
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2018-02-22