php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67546 Environment variables passed via php-fpm are hardlimited to 1024 chars
Submitted: 2014-06-30 11:42 UTC Modified: 2017-01-15 06:53 UTC
From: m at ttias dot be Assigned: krakjoe (profile)
Status: Closed Package: FPM related
PHP Version: 5.4.30 OS: n/a
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: m at ttias dot be
New email:
PHP Version: OS:

 

 [2014-06-30 11:42 UTC] m at ttias dot be
Description:
------------
The current php-fpm implementation limits the size of environment variables, passed via the FPM pool configurations, to 1024 chars. This limit is defined in $src/sapi/fpm/fpm/fpm_conf.c around line 1467, where fpm_conf_load_ini_file() is called.

If larger environment variables are passed through the FPM config to PHP, it will silently truncate them and more than likely cause a configuration error because a trailing quote, to limit strings, will be missing.

The resulting error, when trying to start the PHP-FPM service, looks like this.

Stopping php-fpm2:                            [FAILED]
Starting php-fpm: PHP:  syntax error, unexpected $end in Unknown on line 1
[30-Jun-2014 13:24:36] ERROR: failed to load configuration file '/etc/php-fpm.d/pool-site.conf'
[30-Jun-2014 13:24:36] ERROR: FPM initialization failed

Test script:
---------------
The "bug" is simple to reproduce, by defining an environment variable in the pool configuration that exceeds 1024 chars. A pool configuration with the following details causes this.

[global]
...

[site]
listen = /var/run/php-fpm/site.socket

listen.backlog = 128

listen.allowed_clients = 127.0.0.1
env[TEST_VAR] = '{"variable":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}}'

Expected result:
----------------
One of two things should happen:
- either throw a clear warning that more than 1024 characters were found, but they have been silently removed (not optimal)
- throw a warning but allow the maximum PHP environment variables to be configured through a PHP.INI setting

Actual result:
--------------
The pool fails to start, trigger the error:


Stopping php-fpm:                            [FAILED]
Starting php-fpm: PHP:  syntax error, unexpected $end in Unknown on line 1
[30-Jun-2014 13:40:01] ERROR: failed to load configuration file '/etc/php-fpm.d/pool-site.conf'
[30-Jun-2014 13:40:01] ERROR: FPM initialization failed                                                       [FAILED]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-15 06:53 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2017-01-15 06:53 UTC] krakjoe@php.net
This has been fixed and someone forgot to update the bug. 

Version 7 of PHP should not be exhibit this behaviour.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 23:01:26 2024 UTC