diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-08-02 01:13:39 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-08-24 22:05:07 +0300 |
commit | 784c6d40f88c5a3b4270f2a6d4c7c120b4b12af6 (patch) | |
tree | cdf296c9ac7e655af395da2a44ddc8cc1228369d /src/node_os.cc | |
parent | 7e544240d34ca64d3817071ded3b705ba5f41cd0 (diff) |
src: use proper errors as coming from StringBytes
The previous errors were incorrect here, as the code
only failed in situations where strings exceeded size limits or
an OOM situation was encountered, not for invalid encodings
(which aren’t even detected explicitly).
Unfortunately, these situations are hard to test for.
PR-URL: https://github.com/nodejs/node/pull/14579
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/node_os.cc')
-rw-r--r-- | src/node_os.cc | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/node_os.cc b/src/node_os.cc index c1d1de971f4..c71ca401ed6 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -376,27 +376,11 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) { else shell = StringBytes::Encode(env->isolate(), pwd.shell, encoding, &error); - uv_os_free_passwd(&pwd); - - if (username.IsEmpty()) { - // TODO(addaleax): Use `error` itself here. - return env->ThrowUVException(UV_EINVAL, - "uv_os_get_passwd", - "Invalid character encoding for username"); - } - - if (homedir.IsEmpty()) { - // TODO(addaleax): Use `error` itself here. - return env->ThrowUVException(UV_EINVAL, - "uv_os_get_passwd", - "Invalid character encoding for homedir"); - } - - if (shell.IsEmpty()) { - // TODO(addaleax): Use `error` itself here. - return env->ThrowUVException(UV_EINVAL, - "uv_os_get_passwd", - "Invalid character encoding for shell"); + if (username.IsEmpty() || homedir.IsEmpty() || shell.IsEmpty()) { + CHECK(!error.IsEmpty()); + uv_os_free_passwd(&pwd); + env->isolate()->ThrowException(error); + return; } Local<Object> entry = Object::New(env->isolate()); |