import sys
import subprocess
-HTTPLIB_VERSION = "refs/tags/v0.43.3"
+HTTPLIB_VERSION = "refs/tags/v0.43.4"
vendor = {
"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "vendor/nlohmann/json.hpp",
stream_line_reader lr(strm, line_buf, sizeof(line_buf));
if (!lr.getline()) { return -1; }
- char *endptr = nullptr;
- unsigned long chunk_len = std::strtoul(lr.ptr(), &endptr, 16);
- if (endptr == lr.ptr()) { return -1; }
- if (chunk_len == ULONG_MAX) { return -1; }
+ // RFC 9112 ยง7.1: chunk-size = 1*HEXDIG
+ const char *p = lr.ptr();
+ int v = 0;
+ if (!is_hex(*p, v)) { return -1; }
+
+ size_t chunk_len = 0;
+ constexpr size_t chunk_len_max = (std::numeric_limits<size_t>::max)();
+ for (; is_hex(*p, v); ++p) {
+ if (chunk_len > (chunk_len_max >> 4)) { return -1; }
+ chunk_len = (chunk_len << 4) | static_cast<size_t>(v);
+ }
+
+ while (is_space_or_tab(*p)) {
+ ++p;
+ }
+ if (*p != '\0' && *p != ';' && *p != '\r' && *p != '\n') { return -1; }
if (chunk_len == 0) {
chunk_remaining = 0;
return 0;
}
- chunk_remaining = static_cast<size_t>(chunk_len);
+ chunk_remaining = chunk_len;
last_chunk_total = chunk_remaining;
last_chunk_offset = 0;
}
#ifndef CPPHTTPLIB_HTTPLIB_H
#define CPPHTTPLIB_HTTPLIB_H
-#define CPPHTTPLIB_VERSION "0.43.3"
-#define CPPHTTPLIB_VERSION_NUM "0x002b03"
+#define CPPHTTPLIB_VERSION "0.43.4"
+#define CPPHTTPLIB_VERSION_NUM "0x002b04"
#ifdef _WIN32
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00