GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: fix out-of-bounds write in mkdtemp for long prefixes · nodejs/node@992af05

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_file.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_file.cc‎

Copy file name to clipboardExpand all lines: src/node_file.cc
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,10 +3649,11 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
36493649
CHECK_GE(argc, 2);
36503650

36513651
BufferValue tmpl(isolate, args[0]);
3652-
static constexpr const char* const suffix = "XXXXXX";
3653-
const auto length = tmpl.length();
3654-
tmpl.AllocateSufficientStorage(length + strlen(suffix));
3655-
snprintf(tmpl.out() + length, tmpl.length(), "%s", suffix);
3652+
const auto prefix_length = tmpl.length();
3653+
static constexpr std::string_view suffix = "XXXXXX";
3654+
tmpl.AllocateSufficientStorage(prefix_length + suffix.size() + 1);
3655+
memcpy(tmpl.out() + prefix_length, suffix.data(), suffix.size());
3656+
tmpl.SetLengthAndZeroTerminate(prefix_length + suffix.size());
36563657

36573658
CHECK_NOT_NULL(*tmpl);
36583659

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.