Skip to content

Commit c984cce

Browse files
House-MenCopilot
andcommitted
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent ea24920 commit c984cce

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

base/hbase.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <mach-o/dyld.h> // for _NSGetExecutablePath
55
#endif
66

7+
#include <ctype.h> // for tolower
78
#include "hatomic.h"
89

910
#ifndef RAND_MAX
@@ -542,6 +543,7 @@ int hv_parse_url(hurl_t* stURL, const char* strURL) {
542543
}
543544

544545
int hv_normalize_path(char *path) {
546+
if (!path) return 0;
545547
if (*path != '/') return 0;
546548
int pos = 1;
547549
#ifdef OS_WIN
@@ -586,7 +588,7 @@ int hv_normalize_path(char *path) {
586588
default:
587589
#ifdef OS_WIN
588590
// windows is not case sensitive
589-
path[pos++] = (char)tolower(path[i]);
591+
path[pos++] = (char)tolower((unsigned char)path[i]);
590592
#else
591593
path[pos++] = path[i];
592594
#endif

http/server/HttpHandler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,9 @@ int HttpHandler::defaultRequestHandler() {
524524
int HttpHandler::defaultStaticHandler() {
525525
// file service
526526
std::string path = req->Path();
527-
path.resize(hv_normalize_path(const_cast<char*>(path.c_str())));
527+
if (!path.empty()) {
528+
path.resize(hv_normalize_path(&path[0]));
529+
}
528530
if (path.empty()) {
529531
hloge("[%s:%d] Illegal relative path: %s", ip, port, req->path.c_str());
530532
return HTTP_STATUS_BAD_REQUEST;

0 commit comments

Comments
 (0)