You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Jens-G (via GitHub)" <gi...@apache.org> on 2026/03/24 21:07:22 UTC
Re: [PR] THRIFT-5930: c_glib: reject oversized Unix socket paths in thrift_server_socket_listen() [thrift]
Jens-G commented on code in PR #3354:
URL: https://github.com/apache/thrift/pull/3354#discussion_r2984265514
##########
compiler/cpp/src/thrift/main.cc:
##########
@@ -164,17 +165,25 @@ bool g_generator_failure = false;
* Win32 doesn't have realpath, so use fallback implementation in that case,
* otherwise this just calls through to realpath
*/
-char* saferealpath(const char* path, char* resolved_path) {
+char* saferealpath(const char* path, char* resolved_path, size_t resolved_path_size) {
#ifdef _WIN32
char buf[MAX_PATH];
char* basename;
+ const char* source;
+ size_t source_len;
DWORD len = GetFullPathNameA(path, MAX_PATH, buf, &basename);
if (len == 0 || len > MAX_PATH - 1) {
- strcpy(resolved_path, path);
+ source = path;
} else {
- strcpy(resolved_path, buf);
+ source = buf;
}
+ source_len = strlen(source);
+ if (source_len >= resolved_path_size) {
+ return nullptr;
+ }
+ strcpy(resolved_path, source);
+
Review Comment:
strncpy()?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org