Fix a crash in Mono.Posix.Syscall.getpwuid_r () on some systems when a uid is not...
authorSteffen Kieß <s-kiess@web.de>
Thu, 18 Apr 2013 18:34:15 +0000 (20:34 +0200)
committerZoltan Varga <vargaz@gmail.com>
Thu, 18 Apr 2013 18:35:30 +0000 (20:35 +0200)
support/pwd.c

index 4bb6ad6ca2b532e51f3e014cdcb6203b265ff339..6e3b68a208e9bc2340facb98262023033f9a2527 100644 (file)
@@ -183,6 +183,10 @@ Mono_Posix_Syscall_getpwuid_r (mph_uid_t uid,
        } while ((r = getpwuid_r (uid, &_pwbuf, buf, buflen, (struct passwd**) pwbufp)) && 
                        recheck_range (r));
 
+       if (r == 0 && !(*pwbufp))
+               /* On solaris, this function returns 0 even if the entry was not found */
+               r = errno = ENOENT;
+
        if (r == 0 && copy_passwd (pwbuf, &_pwbuf) == -1)
                r = errno = ENOMEM;
        free (buf);