Skip to content

Commit 13aa892

Browse files
cabelomeh
authored andcommitted
vendor : update cpp-httplib to 0.43.4 (ggml-org#22888)
1 parent 54d48af commit 13aa892

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

scripts/sync_vendor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66
import subprocess
77

8-
HTTPLIB_VERSION = "refs/tags/v0.43.3"
8+
HTTPLIB_VERSION = "refs/tags/v0.43.4"
99

1010
vendor = {
1111
"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "vendor/nlohmann/json.hpp",

vendor/cpp-httplib/httplib.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8980,10 +8980,22 @@ ssize_t ChunkedDecoder::read_payload(char *buf, size_t len,
89808980
stream_line_reader lr(strm, line_buf, sizeof(line_buf));
89818981
if (!lr.getline()) { return -1; }
89828982

8983-
char *endptr = nullptr;
8984-
unsigned long chunk_len = std::strtoul(lr.ptr(), &endptr, 16);
8985-
if (endptr == lr.ptr()) { return -1; }
8986-
if (chunk_len == ULONG_MAX) { return -1; }
8983+
// RFC 9112 §7.1: chunk-size = 1*HEXDIG
8984+
const char *p = lr.ptr();
8985+
int v = 0;
8986+
if (!is_hex(*p, v)) { return -1; }
8987+
8988+
size_t chunk_len = 0;
8989+
constexpr size_t chunk_len_max = (std::numeric_limits<size_t>::max)();
8990+
for (; is_hex(*p, v); ++p) {
8991+
if (chunk_len > (chunk_len_max >> 4)) { return -1; }
8992+
chunk_len = (chunk_len << 4) | static_cast<size_t>(v);
8993+
}
8994+
8995+
while (is_space_or_tab(*p)) {
8996+
++p;
8997+
}
8998+
if (*p != '\0' && *p != ';' && *p != '\r' && *p != '\n') { return -1; }
89878999

89889000
if (chunk_len == 0) {
89899001
chunk_remaining = 0;
@@ -8993,7 +9005,7 @@ ssize_t ChunkedDecoder::read_payload(char *buf, size_t len,
89939005
return 0;
89949006
}
89959007

8996-
chunk_remaining = static_cast<size_t>(chunk_len);
9008+
chunk_remaining = chunk_len;
89979009
last_chunk_total = chunk_remaining;
89989010
last_chunk_offset = 0;
89999011
}

vendor/cpp-httplib/httplib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#ifndef CPPHTTPLIB_HTTPLIB_H
99
#define CPPHTTPLIB_HTTPLIB_H
1010

11-
#define CPPHTTPLIB_VERSION "0.43.3"
12-
#define CPPHTTPLIB_VERSION_NUM "0x002b03"
11+
#define CPPHTTPLIB_VERSION "0.43.4"
12+
#define CPPHTTPLIB_VERSION_NUM "0x002b04"
1313

1414
#ifdef _WIN32
1515
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00

0 commit comments

Comments
 (0)