]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
smb: do not redefine `getpid` on Windows
authorViktor Szakats <commit@vsz.me>
Fri, 11 Oct 2024 08:53:32 +0000 (10:53 +0200)
committerViktor Szakats <commit@vsz.me>
Sun, 13 Oct 2024 16:01:51 +0000 (18:01 +0200)
Replace with namespaced local macro `Curl_getpid()`.

Redefining symbols can backfire if that symbol is used in system
headers, especially with unity build. We haven't seen a fallout in CI
or supported envs, but do it anyway for good measure.

Bug report: https://datagirl.xyz/posts/wolfssl_curl_w2k.html
Closes #15263

lib/smb.c

index 948accda4dd79211273df09995bf5de1b8dd8a4d..2cd2deff64e116ae4f1a16458239886017367070 100644 (file)
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -28,7 +28,9 @@
 #if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE)
 
 #ifdef _WIN32
-#define getpid GetCurrentProcessId
+#define Curl_getpid() ((unsigned int)GetCurrentProcessId())
+#else
+#define Curl_getpid() ((unsigned int)getpid())
 #endif
 
 #include "smb.h"
@@ -546,7 +548,7 @@ static void smb_format_message(struct Curl_easy *data, struct smb_header *h,
   h->flags2 = smb_swap16(SMB_FLAGS2_IS_LONG_NAME | SMB_FLAGS2_KNOWS_LONG_NAME);
   h->uid = smb_swap16(smbc->uid);
   h->tid = smb_swap16(req->tid);
-  pid = (unsigned int)getpid();
+  pid = Curl_getpid();
   h->pid_high = smb_swap16((unsigned short)(pid >> 16));
   h->pid = smb_swap16((unsigned short) pid);
 }