php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11516 multipart/form-data doesn't accept a NULL character
Submitted: 2001-06-16 19:37 UTC Modified: 2001-07-22 13:18 UTC
From: jeroen at smartnet dot dhs dot org Assigned:
Status: Closed Package: Variables related
PHP Version: 4.0.5 OS: winnt4.0
Private report: No CVE-ID: None
 [2001-06-16 19:37 UTC] jeroen at smartnet dot dhs dot org
Hi,


first of all, I'm not 100% sure this is a bug, but I think it is. anyway, here goes:

I manually connect to a php script, by simulating a browser's call. I want to sent some data by simulating a multipart/form-data POST. The data I sent is binary, but since I want to put this data directly into a database, I don't want to use the Content-Disposition: form-data; name="whatever"; filename="C:\whatever.exe" header.

This header would cause php to create a file in the tmp dir, and I don't want this. I simply want the binary data I send in a variable.

What I did was to set the following header: Content-Disposition: form-data; name="whatever"
(without the filename="C:\whatever.exe" part). After that I sent the binary data.

This should create a variable $whatever on the server. 
Everything works just fine until my binary data contains a NULL [chr(0)]. What happens is that php creates the variable $whatever, but truncates everything after the NULL character (including the NULL character itself).

Of course you wouldn't be able to send a NULL from a normal multipart form input box or textarea on the web, but I think php should be able to create a variable which contains my NULL character and everything that follows when I manually connect. It correctly creates a file (including the NULL) when I sent the 'filename="whatever"' header.

By the way, if my form contains more parts after the binary part with the NULL character, php creates those variables correctly... but it just truncates everything after a NULL when I don't send something like filename="c:\whatever.exe".

here is a copy of the headers I manually sent:
****START****
POST /script.php HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------7d12b732260086
Host: www.myserver.com
Content-Length: [The correct length]

-----------------------------7d12b732260086
Content-Disposition: form-data; name="whatever"

123[NULL]456
-----------------------------7d12b732260086
Content-Disposition: form-data; name="foo"

normal text, not binary
-----------------------------7d12b732260086--
****END****

my script on the server now has 2 variables; $whatever and $foo.
print $foo; #this prints "normal text, not binary"
print $whatever; #this prints "123". it should have printed "123 456" (the space here simulating the unprintable NULL character)


I hope this all makes sense (I'm not sure it does :) ). But please email me if this message is not completely clear.

I hope you get back to me.


thanks in advance
Jeroen

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-17 13:53 UTC] sniper@php.net
This works for me just fine. Could you please try
the latest snapshot from http://www.zend.com/snapshots/

 [2001-07-22 13:18 UTC] andy@php.net
no feedback after 30+ days.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 02:01:29 2024 UTC