diff --git a/src/node_os.cc b/src/node_os.cc index 7f392a58fd..663fa9c6bf 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -77,7 +77,7 @@ static Handle GetOSType(const Arguments& args) { #ifdef __POSIX__ struct utsname info; - if (uname(&info)) { + if (uname(&info) < 0) { return ThrowException(ErrnoException(errno, "uname")); } return scope.Close(String::New(info.sysname)); @@ -88,16 +88,15 @@ static Handle GetOSType(const Arguments& args) { static Handle GetOSRelease(const Arguments& args) { HandleScope scope; - char release[256]; #ifdef __POSIX__ struct utsname info; - - uname(&info); - strncpy(release, info.release, strlen(info.release)); - release[strlen(info.release)] = 0; - + if (uname(&info) < 0) { + return ThrowException(ErrnoException(errno, "uname")); + } + return scope.Close(String::New(info.release)); #else // __MINGW32__ + char release[256]; OSVERSIONINFO info; info.dwOSVersionInfoSize = sizeof(info); @@ -107,9 +106,9 @@ static Handle GetOSRelease(const Arguments& args) { sprintf(release, "%d.%d.%d", static_cast(info.dwMajorVersion), static_cast(info.dwMinorVersion), static_cast(info.dwBuildNumber)); + return scope.Close(String::New(release)); #endif - return scope.Close(String::New(release)); } static Handle GetCPUInfo(const Arguments& args) {