Coverity fixes. 54/157954/1
authorINSUN PYO <insun.pyo@samsung.com>
Fri, 27 Oct 2017 04:06:19 +0000 (13:06 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Fri, 27 Oct 2017 04:07:01 +0000 (13:07 +0900)
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: I3a0e8c8edf5134810b482bfcaa77d298e80bd677

src/isadmin.c

index ebe98ad6dfa40fad6e3749df9d64422755627014..8d77f3f29dc18d1a264f6c6954bfbc60aabb7596 100644 (file)
@@ -73,7 +73,15 @@ int _has_system_group_static_(uid_t uid)
 
        /* Get all the gid of the given uid */
 
-       getpwuid_r(myuid, &pwd, buf, sizeof(buf), &userinfo);
+       if (getpwuid_r(myuid, &pwd, buf, sizeof(buf), &userinfo)) {
+               fprintf(stderr, "isadmin ERROR: cannot get password file entry\n");
+               return -1;
+       }
+
+       if (userinfo == NULL) {
+               fprintf(stderr, "isadmin ERROR: no matching password record\n");
+               return -1;
+       }
 
        /* Need to call this function now to get the number of group to make the
           malloc correctly sized */