Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e09f7f0

Browse filesBrowse files
addaleaxdanielleadams
authored andcommitted
src: limit GetProcessTitle() result to 1MB
`GetProcessTitle()` otherwise runs an infinite loop when `uv_setup_argv()` has not been called (yet). This is a problem e.g. in assertions from static constructors, which run before `main()` and thus before `argc` and `argv` become available. To solve that, do not allocate more than 1MB of storage for the title and bail out if we reach that point. PR-URL: #35492 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 5790c40 commit e09f7f0
Copy full SHA for e09f7f0

File tree

Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Open diff view settings
Collapse file

‎src/util.cc‎

Copy file name to clipboardExpand all lines: src/util.cc
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ std::string GetProcessTitle(const char* default_title) {
144144
if (rc == 0)
145145
break;
146146

147-
if (rc != UV_ENOBUFS)
147+
// If uv_setup_args() was not called, `uv_get_process_title()` will always
148+
// return `UV_ENOBUFS`, no matter the input size. Guard against a possible
149+
// infinite loop by limiting the buffer size.
150+
if (rc != UV_ENOBUFS || buf.size() >= 1024 * 1024)
148151
return default_title;
149152

150153
buf.resize(2 * buf.size());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.