Skip to content

Commit d6decb8

Browse files
committed
Explicit cast to unsigned char when calling tolower to avoid undefined behavior for c<0
1 parent cf31acb commit d6decb8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/HTTPConnection.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,12 @@ void HTTPConnection::loop() {
437437
std::string connectionHeaderValue = "";
438438
if (connectionHeader != NULL) {
439439
connectionHeaderValue += connectionHeader->_value;
440-
std::transform(connectionHeaderValue.begin(), connectionHeaderValue.end(), connectionHeaderValue.begin(), ::tolower);
440+
std::transform(
441+
connectionHeaderValue.begin(),
442+
connectionHeaderValue.end(),
443+
connectionHeaderValue.begin(),
444+
[](unsigned char c){ return ::tolower(c); }
445+
);
441446
}
442447
if (std::string("keep-alive").compare(connectionHeaderValue)==0) {
443448
HTTPS_DLOGHEX("[ ] Keep-Alive activated. fid=", _socket);

0 commit comments

Comments
 (0)