php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79570 ZTS build of PHP 7.3.17 doesn't handle ERANGE for posix_getgrgid and others
Submitted: 2020-05-06 06:53 UTC Modified: 2020-05-06 07:10 UTC
From: zboszor at pr dot hu Assigned:
Status: Closed Package: POSIX related
PHP Version: 7.3.17 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zboszor at pr dot hu
New email:
PHP Version: OS:

 

 [2020-05-06 06:53 UTC] zboszor at pr dot hu
Description:
------------
ZTS build of PHP uses getgrnam_r, getgrgid_r, getpwnam_r and getpwuid_r
behind their respective posix_* functions. These functions may return ERANGE
if the buffer supplied by the caller is too small.
sysconf() returns 1024 for _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX.
Only posix_getgrnam calling getgrnam_r handles ERANGE properly by
retrying with a larger buffer.
This was noticed on a system with a group containing many users, so
the respective line in /etc/group exceeded 2KB.

Test script:
---------------
<?php
  $i = 200; /* a GID that has a very long line in /etc/group */
  $data = posix_getgrgid($i);
  $error_num = posix_get_last_error();
  if ($error_num > 0) {
    echo "\nERROR NUM = $error_num\n";
    echo "ERROR MES = " . posix_strerror($error_num) . "\n\n";
  } else {
    printf("%s\n", $data["name"]);
  }
?>


Expected result:
----------------
The group name should be printed.

Actual result:
--------------
Error number 34 (ERANGE) is printed.

Patches

php-7.3-fix-posix-fns-with-zts.patch (last revision 2020-05-06 06:53 UTC by zboszor at pr dot hu)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-06 07:10 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2020-05-06 07:10 UTC] cmb@php.net
Thanks for reporting!  This has been missed when fixing bug
#75696.
 [2020-06-17 17:59 UTC] alexdowad@php.net
Can you submit the attached patch as a pull request to php-src in GitHub? Perhaps it may get more attention there. If you do not want to do this, I could also submit it on your behalf and credit you in the commit message.
 [2020-06-19 15:33 UTC] nikic@php.net
Automatic comment on behalf of zboszor@pr.hu
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6aff9a50cae40582d2571e7aa6f336d5c6a99547
Log: Fixed bug #79570
 [2020-06-19 15:33 UTC] nikic@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC