Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Unified Diff: runtime/bin/directory_macos.cc

Issue 12326007: dart:io Directory.list: Fix use of snprintf return value to work with both C99, Windows, and pre-C9… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/directory_linux.cc ('k') | runtime/bin/directory_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_macos.cc
diff --git a/runtime/bin/directory_macos.cc b/runtime/bin/directory_macos.cc
index ad05d1e952557f2632abc9d31e8173194d892a8d..c700f6c89802d192472feb591f3ce672de6cc193 100644
--- a/runtime/bin/directory_macos.cc
+++ b/runtime/bin/directory_macos.cc
@@ -28,12 +28,14 @@ class PathBuffer {
int length;
bool Add(const char* name) {
- size_t written = snprintf(data + length,
- PATH_MAX - length,
- "%s",
- name);
+ int written = snprintf(data + length,
+ PATH_MAX - length,
+ "%s",
+ name);
data[PATH_MAX] = '\0';
- if (written == strlen(name)) {
+ if (written <= PATH_MAX - length &&
+ written >= 0 &&
+ static_cast<size_t>(written) == strlen(name)) {
length += written;
return true;
} else {
« no previous file with comments | « runtime/bin/directory_linux.cc ('k') | runtime/bin/directory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698