diff options
author | Saúl Ibarra Corretgé <saghul@gmail.com> | 2015-01-14 20:26:02 +0100 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2015-01-14 23:52:14 +0100 |
commit | 07bd05ba332e078c1ba76635921f5448a3e884cf (patch) | |
tree | 1c4cf7ac62c5fc430c052eb8fe8c235612a56c52 /deps/uv/src/unix/freebsd.c | |
parent | e177377a4bc0cdbaecb8b17a58e57c73b4ca0090 (diff) | |
download | android-node-v8-07bd05ba332e078c1ba76635921f5448a3e884cf.tar.gz android-node-v8-07bd05ba332e078c1ba76635921f5448a3e884cf.tar.bz2 android-node-v8-07bd05ba332e078c1ba76635921f5448a3e884cf.zip |
deps: update libuv to 1.2.1
PR: https://github.com/iojs/io.js/pull/423
Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-by: Bert Belder <bertbelder@gmail.com>
Diffstat (limited to 'deps/uv/src/unix/freebsd.c')
-rw-r--r-- | deps/uv/src/unix/freebsd.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/deps/uv/src/unix/freebsd.c b/deps/uv/src/unix/freebsd.c index 55492adc48..d87b74b9bc 100644 --- a/deps/uv/src/unix/freebsd.c +++ b/deps/uv/src/unix/freebsd.c @@ -75,8 +75,9 @@ uint64_t uv__hrtime(uv_clocktype_t type) { int uv_exepath(char* buffer, size_t* size) { + char abspath[PATH_MAX * 2 + 1]; int mib[4]; - size_t cb; + size_t abspath_size; if (buffer == NULL || size == NULL || *size == 0) return -EINVAL; @@ -93,10 +94,19 @@ int uv_exepath(char* buffer, size_t* size) { mib[3] = -1; #endif - cb = *size; - if (sysctl(mib, 4, buffer, &cb, NULL, 0)) + abspath_size = sizeof abspath;; + if (sysctl(mib, 4, abspath, &abspath_size, NULL, 0)) return -errno; - *size = strlen(buffer); + + assert(abspath_size > 0); + abspath_size -= 1; + *size -= 1; + + if (*size > abspath_size) + *size = abspath_size; + + memcpy(buffer, abspath, *size); + buffer[*size] = '\0'; return 0; } |