summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/rfc1867.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 0c66baf0b9..3bb046fba0 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -13,10 +13,12 @@
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Rasmus Lerdorf <rasmus@php.net> |
+ | Jani Taskinen <sniper@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
+
#include <stdio.h>
#include "php.h"
#include "php_open_temporary_file.h"
@@ -109,8 +111,8 @@ void destroy_uploaded_files_hash(TSRMLS_D)
}
-/*
- * Following code is borrowed from Apache
+/*
+ * Following code is based on apache_multipart_buffer.c from libapreq-0.33 package.
*
*/
@@ -172,6 +174,7 @@ static int fill_buffer(multipart_buffer *self TSRMLS_DC)
return actual_read;
}
+
/* eof if we are out of bytes, or if we hit the final boundary */
static int multipart_buffer_eof(multipart_buffer *self TSRMLS_DC)
{
@@ -182,6 +185,7 @@ static int multipart_buffer_eof(multipart_buffer *self TSRMLS_DC)
}
}
+
/* create new multipart_buffer structure */
static multipart_buffer *multipart_buffer_new(char *boundary, int boundary_len)
{
@@ -206,6 +210,7 @@ static multipart_buffer *multipart_buffer_new(char *boundary, int boundary_len)
return self;
}
+
/*
gets the next CRLF terminated line from the input buffer.
if it doesn't find a CRLF, and the buffer isn't completely full, returns
@@ -251,6 +256,7 @@ static char *next_line(multipart_buffer *self)
return line;
}
+
/* returns the next CRLF terminated line from the client */
static char *get_line(multipart_buffer *self TSRMLS_DC)
{
@@ -264,6 +270,7 @@ static char *get_line(multipart_buffer *self TSRMLS_DC)
return ptr;
}
+
/* Free header entry */
static void php_free_hdr_entry(mime_header_entry *h)
{
@@ -271,6 +278,7 @@ static void php_free_hdr_entry(mime_header_entry *h)
if(h->value) efree(h->value);
}
+
/* finds a boundary */
static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC)
{
@@ -289,6 +297,7 @@ static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC)
return 0;
}
+
/* parse headers */
static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header TSRMLS_DC)
{
@@ -378,6 +387,7 @@ static char *php_ap_getword(char **line, char stop)
return res;
}
+
static char *substring_conf(char *start, int len, char quote)
{
char *result = emalloc(len + 2);
@@ -396,6 +406,7 @@ static char *substring_conf(char *start, int len, char quote)
return result;
}
+
static char *php_ap_getword_conf(char **line)
{
char *str = *line, *strend, *res, quote;
@@ -441,6 +452,7 @@ static char *php_ap_getword_conf(char **line)
return res;
}
+
/*
search for a string in a fixed-length byte string.
if partial is true, partial matches are allowed at the end of the buffer.
@@ -469,6 +481,7 @@ static void *php_ap_memstr(char *haystack, int haystacklen, char *needle, int ne
return ptr;
}
+
/* read until a boundary condition */
static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes TSRMLS_DC)
{
@@ -509,6 +522,7 @@ static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes TS
return len;
}
+
/*
XXX: this is horrible memory-usage-wise, but we only expect
to do this on small pieces of form data.