win64: build clean under MinGW-w64; drop a dead test assertion
The first MinGW pass at 1.0.0 failed to compile, so publish shipped 5 of 6 targets and the manifest said so honestly. Four separate Windows-port bugs, each invisible on POSIX: - _O_BINARY undeclared: MinGW spreads what one POSIX header covers across <io.h> (_setmode/_fileno), <fcntl.h> (the _O_* constants) and <direct.h> (_mkdir); windows.h pulls in none of them - InetPtonA and inet_ntop implicitly declared: MinGW defaults _WIN32_WINNT to 0x0502, which hides both behind a Vista gate - and the SSRF validator parses and prints addresses with exactly those two. _WIN32_WINNT 0x0601 now sits at the top of fetch_http.c, ahead of winsock2.h, the same rule plugin_fetch.c already carried - WINHTTP_REDIRECT_POLICY_NONE does not exist in MinGW's winhttp.h: that is the WinRT WINHTTP_REDIRECT_POLICY spelling. The Win32 option value for "do not follow redirects yourself, my loop owns every hop" is WINHTTP_OPTION_REDIRECT_POLICY_NEVER. The test that asserted the wrong spelling passed, which is what let it reach a shipped source tree - a2w() takes a narrow string (it converts with MultiByteToWideChar), and was handed L"Location" Also deletes a vestigial self-satisfying check ("string numbers are coerced") that asserted a literal against /dev/null; the real coercion assertion below it is kept and now carries the comment explaining what it proves. Version 1.0.1. Verified: x86_64-w64-mingw32-gcc -Wall -Wextra -static -> PE32+, zero errors; offline suite 265 pass / 0 fail including the audit gate.
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-14 01:05:05
Commit812406b4
Parents6e1866e0
Changed files
plugin.json+1−1■■
release-dist.sh+1−1■■
src/fetch_http.c+13−3■■■■■
src/plugin_fetch.c+6−1■■■■■
tests/run.sh+4−2■■■■■
5 files+25−8
Diff
plugin.json+1−1■■
index 6521c63..7bfb05b 100644
--- a/plugin.json
+++ b/plugin.json
@@ -11,7 +11,7 @@
1111 "menus": false,
1212 "verified": "live",
1313 "category": "network",
14- "version": "1.0.0",
14+ "version": "1.0.1",
1515 "license": "MIT",
1616 "capabilities": [
1717 "outbound_http_user_requested",
release-dist.sh+1−1■■
index f3f1cf0..7bf166f 100644
--- a/release-dist.sh
+++ b/release-dist.sh
@@ -18,7 +18,7 @@
1818 set -eu
1919
2020 SLUG=fetch
21-VERSION="${VERSION:-1.0.0}"
21+VERSION="${VERSION:-1.0.1}"
2222 PLUGINGIT_TOKEN_FILE="${PLUGINGIT_TOKEN_FILE:-/etc/scorpiox-plugingit.token}"
2323
2424 ROOT=$(cd "$(dirname "$0")" && pwd)
src/fetch_http.c+13−3■■■■■
index 8cf77bb..774aed6 100644
--- a/src/fetch_http.c
+++ b/src/fetch_http.c
@@ -14,7 +14,12 @@
1414 * FX_MAX_REDIRECTS. No TLS bypass exists.
1515 */
1616 /* The feature-test macros must precede every include (netdb/inet functions,
17- * POSIX sockets). */
17+ * POSIX sockets). _WIN32_WINNT likewise precedes winsock2.h: MinGW defaults
18+ * it to 0x0502, which hides InetPtonA and inet_ntop - both of which the SSRF
19+ * validator needs - behind a Windows Vista gate. */
20+#if defined(_WIN32) && !defined(_WIN32_WINNT)
21+# define _WIN32_WINNT 0x0601
22+#endif
1823 #if !defined(_WIN32) && !defined(_POSIX_C_SOURCE)
1924 # define _POSIX_C_SOURCE 200809L
2025 #endif
@@ -1087,7 +1092,12 @@ static int exchange_winhttp(const fx_url *u, const char *urltext, fx_response *r
10871092 WinHttpSetOption(req, WINHTTP_OPTION_SECURE_PROTOCOLS, &sec, sizeof sec);
10881093 }
10891094 {
1090- DWORD pol = WINHTTP_REDIRECT_POLICY_NONE;
1095+ /* Our own redirect loop owns every hop (each one re-resolved and
1096+ * re-validated), so WinHTTP must not follow any on its own.
1097+ * _NEVER is the documented spelling; _NONE is what the WinRT
1098+ * WINHTTP_REDIRECT_POLICY enum calls it and MinGW's winhttp.h does
1099+ * not define _NONE at all. */
1100+ DWORD pol = WINHTTP_OPTION_REDIRECT_POLICY_NEVER;
10911101 WinHttpSetOption(req, WINHTTP_OPTION_REDIRECT_POLICY, &pol, sizeof pol);
10921102 }
10931103 {
@@ -1143,7 +1153,7 @@ static int exchange_winhttp(const fx_url *u, const char *urltext, fx_response *r
11431153 wchar_t wloc[1024];
11441154 DWORD sz = sizeof wloc;
11451155 wloc[0] = L'\0';
1146- a2w(L"Location", whdr, 128);
1156+ a2w("Location", whdr, 128);
11471157 if (WinHttpQueryHeaders(req, WINHTTP_QUERY_CUSTOM, whdr, wloc, &sz,
11481158 WINHTTP_NO_HEADER_INDEX)) {
11491159 WideCharToMultiByte(CP_UTF8, 0, wloc, -1, r->url, sizeof r->url,
src/plugin_fetch.c+6−1■■■■■
index 561948d..3f23ce9 100644
--- a/src/plugin_fetch.c
+++ b/src/plugin_fetch.c
@@ -52,8 +52,13 @@
5252 #include <time.h>
5353
5454 #if defined(_WIN32)
55+ /* MinGW splits what one POSIX header covers into three: <io.h> declares
56+ * _setmode/_fileno, <fcntl.h> declares the _O_* constants _setmode takes,
57+ * <direct.h> declares _mkdir. windows.h pulls in none of them. */
5558 # include <windows.h>
5659 # include <io.h>
60+# include <fcntl.h>
61+# include <direct.h>
5762 #endif
5863 #include <sys/stat.h>
5964 #include <sys/types.h>
@@ -66,7 +71,7 @@
6671
6772 #define PLUGIN_SLUG "fetch"
6873 #define PLUGIN_ID "plugin_fetch"
69-#define PLUGIN_VER "1.0.0"
74+#define PLUGIN_VER "1.0.1"
7075
7176 #if defined(_WIN32)
7277 # define sx_mkdir(p) _mkdir(p)
tests/run.sh+4−2■■■■■
index 1ba6115..35555a9 100644
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -250,7 +250,9 @@ check "a missing url is an error" 'url is required' "$(fld nourl)"
250250 check "a schemeless url is refused" 'no scheme' "$(fld noscheme)"
251251 check "ftp is refused" "scheme 'ftp'" "$(fld badscheme)"
252252 check "an empty url is refused" 'url is required' "$(fld empty)"
253-check "string numbers are coerced" 'truncation footer proves max_length was applied' /dev/null >/dev/null
253+# the string-vs-int coercion path: max_length arrives as the string "40", so
254+# only the truncation footer naming start_index 40 proves it was read as a
255+# number rather than rejected or defaulted
254256 check "string numbers are coerced (max_length honoured as a string)" 'start_index of 40' "$(fld strnums)"
255257 check "the request sends our User-Agent" 'SCORPIOXBOT-fetch' "$(fld useragent)"
256258 check "the request asks for identity encoding" 'identity' "$(fld useragent)"
@@ -610,7 +612,7 @@ check "the socket connects to the validated address" 'connected to that exact va
610612 check "the connect is non-blocking so the deadline is real" 'O_NONBLOCK' "$(cat src/fetch_http.c)"
611613 check "the Windows leg sets hard timeouts too" 'WinHttpSetTimeouts' "$(cat src/fetch_http.c)"
612614 check "WinHTTP is pinned to TLS 1.2+" 'WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2' "$(cat src/fetch_http.c)"
613-check "WinHTTP does not follow redirects itself" 'WINHTTP_REDIRECT_POLICY_NONE' "$(cat src/fetch_http.c)"
615+check "WinHTTP does not follow redirects itself" 'WINHTTP_OPTION_REDIRECT_POLICY_NEVER' "$(cat src/fetch_http.c)"
614616 check "the body cap is 5 MB" 'define FX_MAX_BODY' "$(cat src/fetch_http.h)"
615617 check "the redirect cap is 5" 'define FX_MAX_REDIRECTS 5' "$(cat src/fetch_http.h)"
616618 check "the page is a generated header" '#include "ui_html.h"' "$(cat src/plugin_fetch.c)"
617619
plugin.json+1−1■■
index 6521c63..7bfb05b 100644index 6521c63..7bfb05b 100644
--- a/plugin.json--- a/plugin.json
+++ b/plugin.json+++ b/plugin.json
@@ -11,7 +11,7 @@@@ -11,7 +11,7 @@
11 "menus": false,11 "menus": false,
12 "verified": "live",12 "verified": "live",
13 "category": "network",13 "category": "network",
14- "version": "1.0.0",14+ "version": "1.0.1",
15 "license": "MIT",15 "license": "MIT",
16 "capabilities": [16 "capabilities": [
17 "outbound_http_user_requested",17 "outbound_http_user_requested",
release-dist.sh+1−1■■
index f3f1cf0..7bf166f 100644index f3f1cf0..7bf166f 100644
--- a/release-dist.sh--- a/release-dist.sh
+++ b/release-dist.sh+++ b/release-dist.sh
@@ -18,7 +18,7 @@@@ -18,7 +18,7 @@
18 set -eu18 set -eu
19 19
20 SLUG=fetch20 SLUG=fetch
21-VERSION="${VERSION:-1.0.0}"21+VERSION="${VERSION:-1.0.1}"
22 PLUGINGIT_TOKEN_FILE="${PLUGINGIT_TOKEN_FILE:-/etc/scorpiox-plugingit.token}"22 PLUGINGIT_TOKEN_FILE="${PLUGINGIT_TOKEN_FILE:-/etc/scorpiox-plugingit.token}"
23 23
24 ROOT=$(cd "$(dirname "$0")" && pwd)24 ROOT=$(cd "$(dirname "$0")" && pwd)
src/fetch_http.c+13−3■■■■■
index 8cf77bb..774aed6 100644index 8cf77bb..774aed6 100644
--- a/src/fetch_http.c--- a/src/fetch_http.c
+++ b/src/fetch_http.c+++ b/src/fetch_http.c
@@ -14,7 +14,12 @@@@ -14,7 +14,12 @@
14 * FX_MAX_REDIRECTS. No TLS bypass exists.14 * FX_MAX_REDIRECTS. No TLS bypass exists.
15 */15 */
16 /* The feature-test macros must precede every include (netdb/inet functions,16 /* The feature-test macros must precede every include (netdb/inet functions,
17- * POSIX sockets). */17+ * POSIX sockets). _WIN32_WINNT likewise precedes winsock2.h: MinGW defaults
18+ * it to 0x0502, which hides InetPtonA and inet_ntop - both of which the SSRF
19+ * validator needs - behind a Windows Vista gate. */
20+#if defined(_WIN32) && !defined(_WIN32_WINNT)
21+# define _WIN32_WINNT 0x0601
22+#endif
18 #if !defined(_WIN32) && !defined(_POSIX_C_SOURCE)23 #if !defined(_WIN32) && !defined(_POSIX_C_SOURCE)
19 # define _POSIX_C_SOURCE 200809L24 # define _POSIX_C_SOURCE 200809L
20 #endif25 #endif
@@ -1087,7 +1092,12 @@ static int exchange_winhttp(const fx_url *u, const char *urltext, fx_response *r@@ -1087,7 +1092,12 @@ static int exchange_winhttp(const fx_url *u, const char *urltext, fx_response *r
1087 WinHttpSetOption(req, WINHTTP_OPTION_SECURE_PROTOCOLS, &sec, sizeof sec);1092 WinHttpSetOption(req, WINHTTP_OPTION_SECURE_PROTOCOLS, &sec, sizeof sec);
1088 }1093 }
1089 {1094 {
1090- DWORD pol = WINHTTP_REDIRECT_POLICY_NONE;1095+ /* Our own redirect loop owns every hop (each one re-resolved and
1096+ * re-validated), so WinHTTP must not follow any on its own.
1097+ * _NEVER is the documented spelling; _NONE is what the WinRT
1098+ * WINHTTP_REDIRECT_POLICY enum calls it and MinGW's winhttp.h does
1099+ * not define _NONE at all. */
1100+ DWORD pol = WINHTTP_OPTION_REDIRECT_POLICY_NEVER;
1091 WinHttpSetOption(req, WINHTTP_OPTION_REDIRECT_POLICY, &pol, sizeof pol);1101 WinHttpSetOption(req, WINHTTP_OPTION_REDIRECT_POLICY, &pol, sizeof pol);
1092 }1102 }
1093 {1103 {
@@ -1143,7 +1153,7 @@ static int exchange_winhttp(const fx_url *u, const char *urltext, fx_response *r@@ -1143,7 +1153,7 @@ static int exchange_winhttp(const fx_url *u, const char *urltext, fx_response *r
1143 wchar_t wloc[1024];1153 wchar_t wloc[1024];
1144 DWORD sz = sizeof wloc;1154 DWORD sz = sizeof wloc;
1145 wloc[0] = L'\0';1155 wloc[0] = L'\0';
1146- a2w(L"Location", whdr, 128);1156+ a2w("Location", whdr, 128);
1147 if (WinHttpQueryHeaders(req, WINHTTP_QUERY_CUSTOM, whdr, wloc, &sz,1157 if (WinHttpQueryHeaders(req, WINHTTP_QUERY_CUSTOM, whdr, wloc, &sz,
1148 WINHTTP_NO_HEADER_INDEX)) {1158 WINHTTP_NO_HEADER_INDEX)) {
1149 WideCharToMultiByte(CP_UTF8, 0, wloc, -1, r->url, sizeof r->url,1159 WideCharToMultiByte(CP_UTF8, 0, wloc, -1, r->url, sizeof r->url,
src/plugin_fetch.c+6−1■■■■■
index 561948d..3f23ce9 100644index 561948d..3f23ce9 100644
--- a/src/plugin_fetch.c--- a/src/plugin_fetch.c
+++ b/src/plugin_fetch.c+++ b/src/plugin_fetch.c
@@ -52,8 +52,13 @@@@ -52,8 +52,13 @@
52 #include <time.h>52 #include <time.h>
53 53
54 #if defined(_WIN32)54 #if defined(_WIN32)
55+ /* MinGW splits what one POSIX header covers into three: <io.h> declares
56+ * _setmode/_fileno, <fcntl.h> declares the _O_* constants _setmode takes,
57+ * <direct.h> declares _mkdir. windows.h pulls in none of them. */
55 # include <windows.h>58 # include <windows.h>
56 # include <io.h>59 # include <io.h>
60+# include <fcntl.h>
61+# include <direct.h>
57 #endif62 #endif
58 #include <sys/stat.h>63 #include <sys/stat.h>
59 #include <sys/types.h>64 #include <sys/types.h>
@@ -66,7 +71,7 @@@@ -66,7 +71,7 @@
66 71
67 #define PLUGIN_SLUG "fetch"72 #define PLUGIN_SLUG "fetch"
68 #define PLUGIN_ID "plugin_fetch"73 #define PLUGIN_ID "plugin_fetch"
69-#define PLUGIN_VER "1.0.0"74+#define PLUGIN_VER "1.0.1"
70 75
71 #if defined(_WIN32)76 #if defined(_WIN32)
72 # define sx_mkdir(p) _mkdir(p)77 # define sx_mkdir(p) _mkdir(p)
tests/run.sh+4−2■■■■■
index 1ba6115..35555a9 100644index 1ba6115..35555a9 100644
--- a/tests/run.sh--- a/tests/run.sh
+++ b/tests/run.sh+++ b/tests/run.sh
@@ -250,7 +250,9 @@ check "a missing url is an error" 'url is required' "$(fld nourl)"@@ -250,7 +250,9 @@ check "a missing url is an error" 'url is required' "$(fld nourl)"
250 check "a schemeless url is refused" 'no scheme' "$(fld noscheme)"250 check "a schemeless url is refused" 'no scheme' "$(fld noscheme)"
251 check "ftp is refused" "scheme 'ftp'" "$(fld badscheme)"251 check "ftp is refused" "scheme 'ftp'" "$(fld badscheme)"
252 check "an empty url is refused" 'url is required' "$(fld empty)"252 check "an empty url is refused" 'url is required' "$(fld empty)"
253-check "string numbers are coerced" 'truncation footer proves max_length was applied' /dev/null >/dev/null253+# the string-vs-int coercion path: max_length arrives as the string "40", so
254+# only the truncation footer naming start_index 40 proves it was read as a
255+# number rather than rejected or defaulted
254 check "string numbers are coerced (max_length honoured as a string)" 'start_index of 40' "$(fld strnums)"256 check "string numbers are coerced (max_length honoured as a string)" 'start_index of 40' "$(fld strnums)"
255 check "the request sends our User-Agent" 'SCORPIOXBOT-fetch' "$(fld useragent)"257 check "the request sends our User-Agent" 'SCORPIOXBOT-fetch' "$(fld useragent)"
256 check "the request asks for identity encoding" 'identity' "$(fld useragent)"258 check "the request asks for identity encoding" 'identity' "$(fld useragent)"
@@ -610,7 +612,7 @@ check "the socket connects to the validated address" 'connected to that exact va@@ -610,7 +612,7 @@ check "the socket connects to the validated address" 'connected to that exact va
610 check "the connect is non-blocking so the deadline is real" 'O_NONBLOCK' "$(cat src/fetch_http.c)"612 check "the connect is non-blocking so the deadline is real" 'O_NONBLOCK' "$(cat src/fetch_http.c)"
611 check "the Windows leg sets hard timeouts too" 'WinHttpSetTimeouts' "$(cat src/fetch_http.c)"613 check "the Windows leg sets hard timeouts too" 'WinHttpSetTimeouts' "$(cat src/fetch_http.c)"
612 check "WinHTTP is pinned to TLS 1.2+" 'WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2' "$(cat src/fetch_http.c)"614 check "WinHTTP is pinned to TLS 1.2+" 'WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2' "$(cat src/fetch_http.c)"
613-check "WinHTTP does not follow redirects itself" 'WINHTTP_REDIRECT_POLICY_NONE' "$(cat src/fetch_http.c)"615+check "WinHTTP does not follow redirects itself" 'WINHTTP_OPTION_REDIRECT_POLICY_NEVER' "$(cat src/fetch_http.c)"
614 check "the body cap is 5 MB" 'define FX_MAX_BODY' "$(cat src/fetch_http.h)"616 check "the body cap is 5 MB" 'define FX_MAX_BODY' "$(cat src/fetch_http.h)"
615 check "the redirect cap is 5" 'define FX_MAX_REDIRECTS 5' "$(cat src/fetch_http.h)"617 check "the redirect cap is 5" 'define FX_MAX_REDIRECTS 5' "$(cat src/fetch_http.h)"
616 check "the page is a generated header" '#include "ui_html.h"' "$(cat src/plugin_fetch.c)"618 check "the page is a generated header" '#include "ui_html.h"' "$(cat src/plugin_fetch.c)"
617619