diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-04-15 20:51:28 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-04-15 20:57:14 +0200 |
commit | 78c5de598bb6ebd68d8d93fabdcebdca1f024580 (patch) | |
tree | fed64ba85ea281af9ac38d3b2bc0937c6d9f5932 /src/node_os.cc | |
parent | 8ee43006b81b713db1a0ca190f5332edd45121c1 (diff) | |
download | node-new-78c5de598bb6ebd68d8d93fabdcebdca1f024580.tar.gz |
os: fix unlikely buffer overflow in os.type()
* Fix a buffer overflow that happens iff strlen(info.sysname) > 255.
* Check the return value of uname().
Diffstat (limited to 'src/node_os.cc')
-rw-r--r-- | src/node_os.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/node_os.cc b/src/node_os.cc index d9712b8bf4..3047d0744d 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -69,14 +69,11 @@ static Handle<Value> GetOSType(const Arguments& args) { HandleScope scope; #ifdef __POSIX__ - char type[256]; struct utsname info; - - uname(&info); - strncpy(type, info.sysname, strlen(info.sysname)); - type[strlen(info.sysname)] = 0; - - return scope.Close(String::New(type)); + if (uname(&info)) { + return ThrowException(ErrnoException(errno, "uname")); + } + return scope.Close(String::New(info.sysname)); #else // __MINGW32__ return scope.Close(String::New("Windows_NT")); #endif |