OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/kernel_proxy.h" | 5 #include "nacl_io/kernel_proxy.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 if (error) { | 263 if (error) { |
264 errno = error; | 264 errno = error; |
265 return -1; | 265 return -1; |
266 } | 266 } |
267 return 0; | 267 return 0; |
268 } | 268 } |
269 | 269 |
270 char* KernelProxy::getcwd(char* buf, size_t size) { | 270 char* KernelProxy::getcwd(char* buf, size_t size) { |
271 std::string cwd = GetCWD(); | 271 std::string cwd = GetCWD(); |
272 | 272 |
273 if (size <= 0) { | |
274 errno = EINVAL; | |
275 return NULL; | |
276 } | |
277 | |
278 // If size is 0, allocate as much as we need. | 273 // If size is 0, allocate as much as we need. |
279 if (size == 0) { | 274 if (size == 0) { |
280 size = cwd.size() + 1; | 275 size = cwd.size() + 1; |
281 } | 276 } |
282 | 277 |
283 // Verify the buffer is large enough | 278 // Verify the buffer is large enough |
284 if (size <= cwd.size()) { | 279 if (size <= cwd.size()) { |
285 errno = ERANGE; | 280 errno = ERANGE; |
286 return NULL; | 281 return NULL; |
287 } | 282 } |
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 errno = ENOTSOCK; | 1596 errno = ENOTSOCK; |
1602 return -1; | 1597 return -1; |
1603 } | 1598 } |
1604 | 1599 |
1605 return 0; | 1600 return 0; |
1606 } | 1601 } |
1607 | 1602 |
1608 #endif // PROVIDES_SOCKET_API | 1603 #endif // PROVIDES_SOCKET_API |
1609 | 1604 |
1610 } // namespace_nacl_io | 1605 } // namespace_nacl_io |
OLD | NEW |