Merge pull request #5693 from lateralusX/lateralusX/disable-stack-overflow-win-x64
[mono.git] / support / pwd.c
index 4bb6ad6ca2b532e51f3e014cdcb6203b265ff339..0e73af22bf9dac7825528da3a77a4f7e34ae4746 100644 (file)
@@ -13,8 +13,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "mph.h" /* Don't remove or move after map.h! Works around issues with Android SDK unified headers */
 #include "map.h"
-#include "mph.h"
 
 G_BEGIN_DECLS
 
@@ -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);