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

Unified Diff: runtime/bin/directory_linux.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_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_linux.cc
diff --git a/runtime/bin/directory_linux.cc b/runtime/bin/directory_linux.cc
index dcd123a090b290312e2a4794e226ac3593ae298d..3775ba1a06bfbd8b1bcea5c4709688eb576590e0 100644
--- a/runtime/bin/directory_linux.cc
+++ b/runtime/bin/directory_linux.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 == strnlen(name, PATH_MAX + 1)) {
+ if (written <= PATH_MAX - length &&
+ written >= 0 &&
+ static_cast<size_t>(written) == strnlen(name, PATH_MAX + 1)) {
length += written;
return true;
} else {
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698