neosys007 commented on code in PR #3354:
URL: https://github.com/apache/thrift/pull/3354#discussion_r2985166864
##########
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:
You are right to call this out, but this file should not be part of
THRIFT-5930 in the first place. This PR branch accidentally pulled in the
separate saferealpath change from THRIFT-5932. I will clean up #3354 so it only
contains the c_glib server-socket changes.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]