Fixed bug #62881 (posix_getpwnam("") & posix_getgrnam("") didn't return ... #176

Closed
wants to merge 1 commit into
from

Projects

None yet

6 participants

@reeze
reeze commented Aug 21, 2012

Fixed bug #62881 (posix_getpwnam("") & posix_getgrnam("") didn't return false on Mac OSX 10.8)

more info about the bug could be found at: https://bugs.php.net/bug.php?id=62881

@travisbot

This pull request fails (merged 76c4a17 into 60ad16e).

@reeze
reeze commented Aug 22, 2012

Hi @smalyshev ,
You might want to take a look at this :)

Thanks

@laruence
Member
  1. we don't fix bug doesn't belong to php
  2. Linux man page of posix_getpwnam doesn't specific the situation about empty string
  3. Posix functions are buggy in mac os.
    so, won't fix for this, leave it to apple .

btw:

after a quick google, seems you have file a bug to apple, then file another bug to ruby..

and the ruby guy told you the same thing I told.

why you still think it should be fixed in php self?

@LawnGnome LawnGnome commented on the diff Aug 22, 2012
ext/posix/posix.c
@@ -1018,6 +1018,11 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */
RETURN_FALSE;
}
+ /* getgrnam/_r() is buggy on Mac OSX 10.8, do early check for invalid empty name */
+ if (name_len == 0) {
+ RETURN_FALSE;
+ }
+
@LawnGnome
LawnGnome Aug 22, 2012

I think this should be #ifdef'd for affected versions of OS X. Technically, it's possible to create users and groups with blank names (I've just done it on my Ubuntu workstation), and getpwnam("") and getgrnam("") do return valid records at that point.

@laruence
laruence Aug 22, 2012 php.net member

Apple should and will fix that. we don't need to

@LawnGnome LawnGnome commented on the diff Aug 22, 2012
ext/posix/posix.c
@@ -1137,6 +1142,11 @@ int php_posix_passwd_to_array(struct passwd *pw, zval *return_value) /* {{{ */
RETURN_FALSE;
}
+ /* getpwnam/_r() is buggy on Mac OSX 10.8, do early check for invalid empty name */
+ if (name_len == 0) {
+ RETURN_FALSE;
+ }
+
@LawnGnome
LawnGnome Aug 22, 2012

As above: this should be wrapped in an #if or #ifdef.

@php-pulls
Collaborator

Comment on behalf of laruence at php.net:

not a php issue

@php-pulls php-pulls closed this Aug 22, 2012
@reeze
reeze commented Aug 22, 2012

@laruence I'v mentioned that is a bug of OSX, I think it's a workround for that. PHP is a portable language,
it have to adapt it self to make itself consistent to developers.

etc: https://github.com/php/php-src/blob/master/main/rfc1867.c#L310 should be let it go?
and many #if are for the same reason

and I don't close it that quick

@laruence
Member

as I said:

"Linux man page of posix_getpwnam doesn't specific the situation about empty string"

that means, technically, it's possible to create users and groups with empty name. so what will happen if apply your fix?

we don't fix bugs doesn't belong to PHP. the situation you mentioned is totally different thing, it's the OS specific features.

for such a obvious reason, I close it.

@laruence
Member

and PS:

it's not just "technically",

LawnGnome 40 minutes ago
.... it's possible to create users and groups with blank names (I've just done it on my Ubuntu workstation), ....

so why do you think I should not close (quickly) a obvious wrong fix?

@smalyshev
Collaborator

Not a critical bug for 5.3. We may discuss adding a fix for 5.4/master, but I'm not feeling too comfortable fixing OS bugs - more we do that, more people expect it from us, and we end up with tons of special checks that don't belong in PHP but belong in OS code. I'd say if OS code returns that, pass it along. Maybe some OS allows empty usernames for some reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment