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

Unified Diff: runtime/bin/directory_win.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_macos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_win.cc
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index d648f95a2281ca901bf54dd21e392c3643505a29..f1b4bae3a361f62fecbe5263299656184a6a64ee 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -23,12 +23,14 @@ class PathBuffer {
int length;
bool Add(const wchar_t* name) {
- size_t written = _snwprintf(data + length,
- MAX_PATH - length,
- L"%s",
- name);
+ int written = _snwprintf(data + length,
+ MAX_PATH - length,
+ L"%s",
+ name);
data[MAX_PATH] = L'\0';
- if (written == wcsnlen(name, MAX_PATH + 1)) {
+ if (written <= MAX_PATH - length &&
+ written >= 0 &&
+ static_cast<size_t>(written) == wcsnlen(name, MAX_PATH + 1)) {
length += written;
return true;
} else {
« no previous file with comments | « runtime/bin/directory_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698