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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc

Issue 1062463004: [NaCl SDK] nacl_io: Fix use-after-free bug in html5fs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use const std::string& Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « native_client_sdk/src/examples/demo/nacl_io_demo/example.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "nacl_io/html5fs/html5_fs.h" 5 #include "nacl_io/html5fs/html5_fs.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 return hash; 39 return hash;
40 } 40 }
41 41
42 ino_t Html5Fs::HashPath(const Path& path) { 42 ino_t Html5Fs::HashPath(const Path& path) {
43 // Prime the DJB2a hash 43 // Prime the DJB2a hash
44 ino_t hash = 5381; 44 ino_t hash = 5381;
45 45
46 // Apply a running DJB2a to each part of the path 46 // Apply a running DJB2a to each part of the path
47 for (size_t segment = 0; segment < path.Size(); segment++) { 47 for (size_t segment = 0; segment < path.Size(); segment++) {
48 const char *ptr = path.Part(segment).c_str(); 48 const std::string& part = path.Part(segment);
49 size_t len = path.Part(segment).length(); 49 hash = HashPathSegment(hash, part.c_str(), part.length());
50 hash = HashPathSegment(hash, ptr, len);
51 } 50 }
52 return hash; 51 return hash;
53 } 52 }
54 53
55 54
56 // For HTML5, the INO should be the one used by the system, however PPAPI 55 // For HTML5, the INO should be the one used by the system, however PPAPI
57 // does not provide access to the real INO. Instead, since HTML5 does not 56 // does not provide access to the real INO. Instead, since HTML5 does not
58 // suport links, we assume that files are unique based on path to the base 57 // suport links, we assume that files are unique based on path to the base
59 // of the mount. 58 // of the mount.
60 void Html5Fs::OnNodeCreated(Node* node) { 59 void Html5Fs::OnNodeCreated(Node* node) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 338 }
340 339
341 void Html5Fs::FilesystemOpenCallback(int32_t result) { 340 void Html5Fs::FilesystemOpenCallback(int32_t result) {
342 AUTO_LOCK(filesysem_open_lock_); 341 AUTO_LOCK(filesysem_open_lock_);
343 filesystem_open_has_result_ = true; 342 filesystem_open_has_result_ = true;
344 filesystem_open_error_ = PPErrorToErrno(result); 343 filesystem_open_error_ = PPErrorToErrno(result);
345 pthread_cond_signal(&filesystem_open_cond_); 344 pthread_cond_signal(&filesystem_open_cond_);
346 } 345 }
347 346
348 } // namespace nacl_io 347 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/examples/demo/nacl_io_demo/example.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698