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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/fusefs/fuse_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: 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
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/fusefs/fuse_fs.h" 5 #include "nacl_io/fusefs/fuse_fs.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 *out_node = node; 136 *out_node = node;
137 return 0; 137 return 0;
138 } 138 }
139 139
140 Error FuseFs::Unlink(const Path& path) { 140 Error FuseFs::Unlink(const Path& path) {
141 if (!fuse_ops_->unlink) { 141 if (!fuse_ops_->unlink) {
142 LOG_TRACE("fuse_ops_->unlink is NULL."); 142 LOG_TRACE("fuse_ops_->unlink is NULL.");
143 return ENOSYS; 143 return ENOSYS;
144 } 144 }
145 145
146 int result = fuse_ops_->unlink(path.Join().c_str()); 146 std::string path_str = path.Join();
147 int result = fuse_ops_->unlink(path_str.c_str());
147 if (result < 0) 148 if (result < 0)
148 return -result; 149 return -result;
149 150
150 return 0; 151 return 0;
151 } 152 }
152 153
153 Error FuseFs::Mkdir(const Path& path, int perm) { 154 Error FuseFs::Mkdir(const Path& path, int perm) {
154 if (!fuse_ops_->mkdir) { 155 if (!fuse_ops_->mkdir) {
155 LOG_TRACE("fuse_ops_->mkdir is NULL."); 156 LOG_TRACE("fuse_ops_->mkdir is NULL.");
156 return ENOSYS; 157 return ENOSYS;
157 } 158 }
158 159
159 int result = fuse_ops_->mkdir(path.Join().c_str(), perm); 160 std::string path_str = path.Join();
161 int result = fuse_ops_->mkdir(path_str.c_str(), perm);
160 if (result < 0) 162 if (result < 0)
161 return -result; 163 return -result;
162 164
163 return 0; 165 return 0;
164 } 166 }
165 167
166 Error FuseFs::Rmdir(const Path& path) { 168 Error FuseFs::Rmdir(const Path& path) {
167 if (!fuse_ops_->rmdir) { 169 if (!fuse_ops_->rmdir) {
168 LOG_TRACE("fuse_ops_->rmdir is NULL."); 170 LOG_TRACE("fuse_ops_->rmdir is NULL.");
169 return ENOSYS; 171 return ENOSYS;
170 } 172 }
171 173
172 int result = fuse_ops_->rmdir(path.Join().c_str()); 174 std::string path_str = path.Join();
175 int result = fuse_ops_->rmdir(path_str.c_str());
173 if (result < 0) 176 if (result < 0)
174 return -result; 177 return -result;
175 178
176 return 0; 179 return 0;
177 } 180 }
178 181
179 Error FuseFs::Remove(const Path& path) { 182 Error FuseFs::Remove(const Path& path) {
180 ScopedNode node; 183 ScopedNode node;
181 Error error = Open(path, O_RDONLY, &node); 184 Error error = Open(path, O_RDONLY, &node);
182 if (error) 185 if (error)
(...skipping 12 matching lines...) Expand all
195 return Unlink(path); 198 return Unlink(path);
196 } 199 }
197 } 200 }
198 201
199 Error FuseFs::Rename(const Path& path, const Path& newpath) { 202 Error FuseFs::Rename(const Path& path, const Path& newpath) {
200 if (!fuse_ops_->rename) { 203 if (!fuse_ops_->rename) {
201 LOG_TRACE("fuse_ops_->rename is NULL."); 204 LOG_TRACE("fuse_ops_->rename is NULL.");
202 return ENOSYS; 205 return ENOSYS;
203 } 206 }
204 207
205 int result = fuse_ops_->rename(path.Join().c_str(), newpath.Join().c_str()); 208 std::string path_str = path.Join();
209 std::string newpath_str = newpath.Join();
210 int result = fuse_ops_->rename(path_str.c_str(), newpath_str.c_str());
206 if (result < 0) 211 if (result < 0)
207 return -result; 212 return -result;
208 213
209 return 0; 214 return 0;
210 } 215 }
211 216
212 FuseFsNode::FuseFsNode(Filesystem* filesystem, 217 FuseFsNode::FuseFsNode(Filesystem* filesystem,
213 struct fuse_operations* fuse_ops, 218 struct fuse_operations* fuse_ops,
214 struct fuse_file_info& info, 219 struct fuse_file_info& info,
215 const std::string& path) 220 const std::string& path)
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } else { 495 } else {
491 fill_info->getdents->AddDirent(ino, name, strlen(name)); 496 fill_info->getdents->AddDirent(ino, name, strlen(name));
492 fill_info->num_bytes -= sizeof(dirent); 497 fill_info->num_bytes -= sizeof(dirent);
493 // According to the docs, we can never return 1 (buffer full) when the 498 // According to the docs, we can never return 1 (buffer full) when the
494 // offset is zero (the user is probably ignoring the result anyway). 499 // offset is zero (the user is probably ignoring the result anyway).
495 return 0; 500 return 0;
496 } 501 }
497 } 502 }
498 503
499 } // namespace nacl_io 504 } // namespace nacl_io
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698