Skip to content

Commit c546b77

Browse files
committed
Fix Codacy CWE-126: replace strlen with std::char_traits::length
Replace strlen(s) with std::char_traits<char>::length(s) in unescaper_func to silence Codacy static analysis warning about potential over-read on non-null-terminated strings. The MHD API guarantees s is null-terminated, but using the C++ equivalent avoids false positives from C-focused analyzers.
1 parent 9ec8c40 commit c546b77

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/webserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ size_t unescaper_func(void * cls, struct MHD_Connection *c, char *s) {
815815
// STRING CONTAINING '\0' AFTER AN UNESCAPING, IS UNABLE TO PARSE
816816
// ARGS WITH get_connection_values FUNC OR lookup FUNC.
817817
if (s == nullptr) return 0;
818-
return strlen(s);
818+
return std::char_traits<char>::length(s);
819819
}
820820

821821
MHD_Result webserver::post_iterator(void *cls, enum MHD_ValueKind kind,

0 commit comments

Comments
 (0)