Bug 1314904 - uname() on success can return non-negative value (not just 0). r=bsmedberg
authorPetr Sumbera <petr.sumbera@oracle.com>
Thu, 03 Nov 2016 03:23:46 -0700
changeset 351975 9e60c1e0b3f1ada2e2d9bf80c3303d51eee2954c
parent 351974 5598e1579a1f7b5de8ca60f45b9f2cfd46c4c9e1
child 351976 058b48a72e502bc73e1a85d5a0f2a197ed6a5c61
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs1314904
milestone52.0a1
Bug 1314904 - uname() on success can return non-negative value (not just 0). r=bsmedberg
toolkit/components/startup/nsUserInfoUnix.cpp
widget/GfxInfoX11.cpp
--- a/toolkit/components/startup/nsUserInfoUnix.cpp
+++ b/toolkit/components/startup/nsUserInfoUnix.cpp
@@ -100,18 +100,17 @@ nsUserInfo::GetUsername(char * *aUsernam
 NS_IMETHODIMP 
 nsUserInfo::GetDomain(char * *aDomain)
 {
     nsresult rv = NS_ERROR_FAILURE;
 
     struct utsname buf;
     char *domainname = nullptr;
 
-    // is this portable?  that is a POSIX compliant call, but I need to check
-    if (uname(&buf)) { 
+    if (uname(&buf) < 0) { 
         return rv;
     }
 
 #if defined(__linux__)
     domainname = buf.domainname;
 #endif
 
     if (domainname && domainname[0]) {   
--- a/widget/GfxInfoX11.cpp
+++ b/widget/GfxInfoX11.cpp
@@ -130,17 +130,17 @@ GfxInfo::GetData()
     }
 
     if (!strcmp(textureFromPixmap.get(), "TRUE"))
         mHasTextureFromPixmap = true;
 
     // only useful for Linux kernel version check for FGLRX driver.
     // assumes X client == X server, which is sad.
     struct utsname unameobj;
-    if (!uname(&unameobj))
+    if (uname(&unameobj) >= 0)
     {
       mOS.Assign(unameobj.sysname);
       mOSRelease.Assign(unameobj.release);
     }
 
     const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR");
     if (spoofedVendor)
         mVendor.Assign(spoofedVendor);