php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47825 POST Data being ignored
Submitted: 2009-03-29 09:32 UTC Modified: 2009-03-31 09:31 UTC
From: tiposchi at tiscali dot it Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.2.9 OS: GNU/Linux
Private report: No CVE-ID: None
 [2009-03-29 09:32 UTC] tiposchi at tiscali dot it
Description:
------------
CGI protocol says that POST data must be passed to the script using
its standard input.

So what i have to do is something like (see the attached code).

Anyway, the php knows how long the input will be because it has an
environmental variable called content length that says it.

So php should wait to read the entire post data before going on.
Since i don't have any information about how the scheduler works, i
can't assure the father process to fill the pipe before the child is
scheduled.

But php ignores the data if the pipe isn't full already. So what i
did was filling the pipe BEFORE the fork, and doing this it works.
But there is another problem. With large POST data, the buffer is
filled and the OS puts my process on wait until the pipe is empty by
another process. But i didn't start the php yet because it wants all
the post data already present, so the webserver just hangs.

I think you should review the way php-cgi reads post data.

Thanks

Reproduce code:
---------------
p=pipe()

if (fork()==0) {
    close(STDIN)
    dup(p)
    exec ("php")
} else {
    write(p,str_post)
    wait()
}

I HAVE MADE THE CODE SIMPLE. I KNOW THIS CAN'T WORK.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-31 07:10 UTC] jani@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2009-03-31 09:31 UTC] tiposchi at tiscali dot it
The bug is about the incorrect handling of data from pipe. I guess you do a simple read, when you should do multiple reads until you've all the data the webserver says the client sent (using the envvar CONTENT_LENGTH) or until the read returns 0.

This is not a support request. The bug is about poor cgi implementation.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 16 18:01:34 2024 UTC