[PHP-CVS] svn: /php/php-src/branches/PHP_5_2/main/ rfc1867.c

2009-12-29 Thread Jani Taskinen
jani Tue, 29 Dec 2009 18:54:08 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=292770

Log:
MFH: clean some dead code (with static analysis help) (Approved by Ilia)

Changed paths:
U   php/php-src/branches/PHP_5_2/main/rfc1867.c

Modified: php/php-src/branches/PHP_5_2/main/rfc1867.c
===
--- php/php-src/branches/PHP_5_2/main/rfc1867.c 2009-12-29 17:25:12 UTC (rev 
292769)
+++ php/php-src/branches/PHP_5_2/main/rfc1867.c 2009-12-29 18:54:08 UTC (rev 
292770)
@@ -32,7 +32,6 @@
 #include php_globals.h
 #include php_variables.h
 #include rfc1867.h
-#include php_ini.h
 #include ext/standard/php_string.h

 #define DEBUG_FILE_UPLOAD ZEND_DEBUG
@@ -205,7 +204,8 @@
index = NULL;
}
}
-   *s++='\0';
+
+   *s = '\0';
 }


@@ -612,7 +612,7 @@
}
}

-   *resp++ = '\0';
+   *resp = '\0';
return result;
 }


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/branches/PHP_5_2/main/ rfc1867.c

2009-12-29 Thread Jani Taskinen
jani Tue, 29 Dec 2009 19:01:03 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=292772

Log:
MF53: ws + cs + folding tags (99% sync :)

Changed paths:
U   php/php-src/branches/PHP_5_2/main/rfc1867.c

Modified: php/php-src/branches/PHP_5_2/main/rfc1867.c
===
--- php/php-src/branches/PHP_5_2/main/rfc1867.c	2009-12-29 18:59:58 UTC (rev 292771)
+++ php/php-src/branches/PHP_5_2/main/rfc1867.c	2009-12-29 19:01:03 UTC (rev 292772)
@@ -13,7 +13,7 @@
| lice...@php.net so we can mail you a copy immediately.   |
+--+
| Authors: Rasmus Lerdorf ras...@php.net |
-   |  Jani Taskinen sni...@php.net  |
+   |  Jani Taskinen j...@php.net|
+--+
  */

@@ -23,7 +23,7 @@
  *  This product includes software developed by the Apache Group
  *  for use in the Apache HTTP server project (http://www.apache.org/).
  *
- */
+ */

 #include stdio.h
 #include php.h
@@ -32,6 +32,7 @@
 #include php_globals.h
 #include php_variables.h
 #include rfc1867.h
+#include php_ini.h
 #include ext/standard/php_string.h

 #define DEBUG_FILE_UPLOAD ZEND_DEBUG
@@ -44,7 +45,7 @@
 static void safe_php_register_variable(char *var, char *strval, int val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC);

 #define SAFE_RETURN { \
-php_mb_flush_gpc_variables(num_vars, val_list, len_list, array_ptr TSRMLS_CC); \
+	php_mb_flush_gpc_variables(num_vars, val_list, len_list, array_ptr TSRMLS_CC); \
 	if (lbuf) efree(lbuf); \
 	if (abuf) efree(abuf); \
 	if (array_index) efree(array_index); \
@@ -56,7 +57,7 @@
 	if (mbuff) efree(mbuff); \
 	return; }

-void php_mb_flush_gpc_variables(int num_vars, char **val_list, int *len_list, zval *array_ptr  TSRMLS_DC)
+void php_mb_flush_gpc_variables(int num_vars, char **val_list, int *len_list, zval *array_ptr  TSRMLS_DC) /* {{{ */
 {
 	int i;
 	if (php_mb_encoding_translation(TSRMLS_C)) {
@@ -64,17 +65,18 @@
 			php_mb_gpc_encoding_detector(val_list, len_list, num_vars, NULL TSRMLS_CC) == SUCCESS) {
 			php_mb_gpc_encoding_converter(val_list, len_list, num_vars, NULL, NULL TSRMLS_CC);
 		}
-		for (i=0; inum_vars; i+=2){
+		for (i = 0; inum_vars; i += 2) {
 			safe_php_register_variable(val_list[i], val_list[i+1], len_list[i+1], array_ptr, 0 TSRMLS_CC);
 			efree(val_list[i]);
 			efree(val_list[i+1]);
-		}
+		}
 		efree(val_list);
 		efree(len_list);
 	}
 }
+/* }}} */

-void php_mb_gpc_realloc_buffer(char ***pval_list, int **plen_list, int *num_vars_max, int inc  TSRMLS_DC)
+void php_mb_gpc_realloc_buffer(char ***pval_list, int **plen_list, int *num_vars_max, int inc  TSRMLS_DC) /* {{{ */
 {
 	/* allow only even increments */
 	if (inc  1) {
@@ -84,15 +86,15 @@
 	*pval_list = (char **)erealloc(*pval_list, (*num_vars_max+2)*sizeof(char *));
 	*plen_list = (int *)erealloc(*plen_list, (*num_vars_max+2)*sizeof(int));
 }
+/* }}} */

-void php_mb_gpc_stack_variable(char *param, char *value, char ***pval_list, int **plen_list, int *num_vars, int *num_vars_max TSRMLS_DC)
+void php_mb_gpc_stack_variable(char *param, char *value, char ***pval_list, int **plen_list, int *num_vars, int *num_vars_max TSRMLS_DC) /* {{{ */
 {
-	char **val_list=*pval_list;
-	int *len_list=*plen_list;
+	char **val_list = *pval_list;
+	int *len_list = *plen_list;

-	if (*num_vars=*num_vars_max){
-		php_mb_gpc_realloc_buffer(pval_list, plen_list, num_vars_max,
-  16 TSRMLS_CC);
+	if (*num_vars = *num_vars_max) {
+		php_mb_gpc_realloc_buffer(pval_list, plen_list, num_vars_max, 16 TSRMLS_CC);
 		/* in case realloc relocated the buffer */
 		val_list = *pval_list;
 		len_list = *plen_list;
@@ -105,6 +107,7 @@
 	len_list[*num_vars] = strlen(value);
 	(*num_vars)++;
 }
+/* }}} */

 #else

@@ -137,7 +140,7 @@
 #define UPLOAD_ERROR_F7  /* Failed to write file to disk */
 #define UPLOAD_ERROR_X8  /* File upload stopped by extension */

-void php_rfc1867_register_constants(TSRMLS_D)
+void php_rfc1867_register_constants(TSRMLS_D) /* {{{ */
 {
 	REGISTER_MAIN_LONG_CONSTANT(UPLOAD_ERR_OK, UPLOAD_ERROR_OK, CONST_CS | CONST_PERSISTENT);
 	REGISTER_MAIN_LONG_CONSTANT(UPLOAD_ERR_INI_SIZE,   UPLOAD_ERROR_A,  CONST_CS | CONST_PERSISTENT);
@@ -148,26 +151,27 @@
 	REGISTER_MAIN_LONG_CONSTANT(UPLOAD_ERR_CANT_WRITE, UPLOAD_ERROR_F,  CONST_CS | CONST_PERSISTENT);
 	REGISTER_MAIN_LONG_CONSTANT(UPLOAD_ERR_EXTENSION,  UPLOAD_ERROR_X,  CONST_CS | CONST_PERSISTENT);
 }
+/* }}} */

-static void normalize_protected_variable(char *varname TSRMLS_DC)
+static void normalize_protected_variable(char *varname TSRMLS_DC) /* {{{ */
 {
-	char *s=varname, *index=NULL, *indexend=NULL, *p;
-
+	char *s = varname, *index = NULL, *indexend = NULL, *p;
+
 	/* overjump leading 

[PHP-CVS] svn: /php/php-src/branches/ PHP_5_2/main/rfc1867.c PHP_5_3/main/rfc1867.c

2009-12-29 Thread Jani Taskinen
jani Tue, 29 Dec 2009 19:25:09 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=292777

Log:
- Sync with HEAD

Changed paths:
U   php/php-src/branches/PHP_5_2/main/rfc1867.c
U   php/php-src/branches/PHP_5_3/main/rfc1867.c

Modified: php/php-src/branches/PHP_5_2/main/rfc1867.c
===
--- php/php-src/branches/PHP_5_2/main/rfc1867.c 2009-12-29 19:23:41 UTC (rev 
292776)
+++ php/php-src/branches/PHP_5_2/main/rfc1867.c 2009-12-29 19:25:09 UTC (rev 
292777)
@@ -263,7 +263,7 @@
 }
 /* }}} */

-static int unlink_filename(char **filename TSRMLS_DC) /* {{{ */
+static int unlink_filename(char **filename TSRMLS_DC) /* {{{ */
 {
VCWD_UNLINK(*filename);
return 0;
@@ -304,7 +304,7 @@

 /*
  * Fill up the buffer with client data.
- * returns number of bytes added to buffer.
+ * Returns number of bytes added to buffer.
  */
 static int fill_buffer(multipart_buffer *self TSRMLS_DC)
 {
@@ -417,7 +417,7 @@
return line;
 }

-/* returns the next CRLF terminated line from the client */
+/* Returns the next CRLF terminated line from the client */
 static char *get_line(multipart_buffer *self TSRMLS_DC)
 {
char* ptr = next_line(self);
@@ -665,7 +665,7 @@
  * Search for a string in a fixed-length byte string.
  * If partial is true, partial matches are allowed at the end of the buffer.
  * Returns NULL if not found, or a pointer to the start of the first match.
-*/
+ */
 static void *php_ap_memstr(char *haystack, int haystacklen, char *needle, int 
needlen, int partial)
 {
int len = haystacklen;
@@ -747,12 +747,14 @@
total_bytes += read_bytes;
}

-   if (out) out[total_bytes] = '\0';
+   if (out) {
+   out[total_bytes] = '\0';
+   }
*len = total_bytes;

return out;
 }
-/* }}} */
+/* }}} */

 /*
  * The combined READER/HANDLER
@@ -773,7 +775,7 @@
 #endif
multipart_buffer *mbuff;
zval *array_ptr = (zval *) arg;
-   int fd=-1;
+   int fd = -1;
zend_llist header;
void *event_extra_data = NULL;
int llen = 0;
@@ -860,7 +862,7 @@
while (!multipart_buffer_eof(mbuff TSRMLS_CC))
{
char buff[FILLUNIT];
-   char *cd = NULL,*param = NULL, *filename = NULL, *tmp = NULL;
+   char *cd = NULL, *param = NULL, *filename = NULL, *tmp = NULL;
size_t blen = 0, wlen = 0;
off_t offset;

@@ -1084,7 +1086,6 @@
 #endif
cancel_upload = UPLOAD_ERROR_B;
} else if (blen  0) {
-
wlen = write(fd, buff, blen);

if (wlen == -1) {
@@ -1119,7 +1120,6 @@
cancel_upload = 5;
}
 #endif
-
if (php_rfc1867_callback != NULL) {
multipart_event_file_end event_file_end;

@@ -1153,7 +1153,7 @@
if (array_index) {
efree(array_index);
}
-   array_index = estrndup(start_arr+1, 
array_len-2);
+   array_index = estrndup(start_arr + 1, array_len 
- 2);
}

/* Add $foo_name */
@@ -1339,6 +1339,7 @@
efree(param);
}
}
+
 fileupload_done:
if (php_rfc1867_callback != NULL) {
multipart_event_end event_end;
@@ -1349,6 +1350,7 @@

SAFE_RETURN;
 }
+/* }}} */

 /*
  * Local variables:

Modified: php/php-src/branches/PHP_5_3/main/rfc1867.c
===
--- php/php-src/branches/PHP_5_3/main/rfc1867.c 2009-12-29 19:23:41 UTC (rev 
292776)
+++ php/php-src/branches/PHP_5_3/main/rfc1867.c 2009-12-29 19:25:09 UTC (rev 
292777)
@@ -262,7 +262,7 @@
 }
 /* }}} */

-static int unlink_filename(char **filename TSRMLS_DC) /* {{{ */
+static int unlink_filename(char **filename TSRMLS_DC) /* {{{ */
 {
VCWD_UNLINK(*filename);
return 0;
@@ -303,7 +303,7 @@

 /*
  * Fill up the buffer with client data.
- * returns number of bytes added to buffer.
+ * Returns number of bytes added to buffer.
  */
 static int fill_buffer(multipart_buffer *self TSRMLS_DC)
 {
@@ -416,7 +416,7 @@
return line;
 }

-/* returns the next CRLF terminated line from the client */
+/* Returns the next CRLF terminated line from the client */
 static char *get_line(multipart_buffer *self TSRMLS_DC)
 {
char* ptr = next_line(self);
@@ -664,7 +664,7 @@
  * Search for a string in a fixed-length byte string.
  * If partial is true, partial matches are allowed at the end of the buffer.
  * Returns NULL if not found, or a pointer to the start of the first match.
-*/
+ */
 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_2/main/rfc1867.c branches/PHP_5_3/main/rfc1867.c trunk/main/rfc1867.c

2009-11-17 Thread Rasmus Lerdorf
rasmus   Tue, 17 Nov 2009 20:33:51 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=290885

Log:
Make it possible to disable post_max_size

Changed paths:
U   php/php-src/branches/PHP_5_2/main/rfc1867.c
U   php/php-src/branches/PHP_5_3/main/rfc1867.c
U   php/php-src/trunk/main/rfc1867.c

Modified: php/php-src/branches/PHP_5_2/main/rfc1867.c
===
--- php/php-src/branches/PHP_5_2/main/rfc1867.c 2009-11-17 20:11:54 UTC (rev 
290884)
+++ php/php-src/branches/PHP_5_2/main/rfc1867.c 2009-11-17 20:33:51 UTC (rev 
290885)
@@ -797,7 +797,7 @@
int llen = 0;
int upload_cnt = INI_INT(max_file_uploads);

-   if (SG(request_info).content_length  SG(post_max_size)) {
+   if (SG(post_max_size)  0  SG(request_info).content_length  
SG(post_max_size)) {
sapi_module.sapi_error(E_WARNING, POST Content-Length of %ld 
bytes exceeds the limit of %ld bytes, SG(request_info).content_length, 
SG(post_max_size));
return;
}

Modified: php/php-src/branches/PHP_5_3/main/rfc1867.c
===
--- php/php-src/branches/PHP_5_3/main/rfc1867.c 2009-11-17 20:11:54 UTC (rev 
290884)
+++ php/php-src/branches/PHP_5_3/main/rfc1867.c 2009-11-17 20:33:51 UTC (rev 
290885)
@@ -797,7 +797,7 @@
int llen = 0;
int upload_cnt = INI_INT(max_file_uploads);

-   if (SG(request_info).content_length  SG(post_max_size)) {
+   if (SG(post_max_size)  0  SG(request_info).content_length  
SG(post_max_size)) {
sapi_module.sapi_error(E_WARNING, POST Content-Length of %ld 
bytes exceeds the limit of %ld bytes, SG(request_info).content_length, 
SG(post_max_size));
return;
}

Modified: php/php-src/trunk/main/rfc1867.c
===
--- php/php-src/trunk/main/rfc1867.c2009-11-17 20:11:54 UTC (rev 290884)
+++ php/php-src/trunk/main/rfc1867.c2009-11-17 20:33:51 UTC (rev 290885)
@@ -596,7 +596,7 @@
int llen = 0;
int upload_cnt = INI_INT(max_file_uploads);

-   if (SG(request_info).content_length  SG(post_max_size)) {
+   if (SG(post_max_size)  0  SG(request_info).content_length  
SG(post_max_size)) {
sapi_module.sapi_error(E_WARNING, POST Content-Length of %ld 
bytes exceeds the limit of %ld bytes, SG(request_info).content_length, 
SG(post_max_size));
return;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_2/main/rfc1867.c branches/PHP_5_3/main/rfc1867.c trunk/main/rfc1867.c

2009-11-16 Thread Ilia Alshanetsky
iliaaMon, 16 Nov 2009 13:34:57 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=290820

Log:
Simpify the max_file_uploads handling code

Changed paths:
U   php/php-src/branches/PHP_5_2/main/rfc1867.c
U   php/php-src/branches/PHP_5_3/main/rfc1867.c
U   php/php-src/trunk/main/rfc1867.c

Modified: php/php-src/branches/PHP_5_2/main/rfc1867.c
===
--- php/php-src/branches/PHP_5_2/main/rfc1867.c 2009-11-16 13:34:48 UTC (rev 
290819)
+++ php/php-src/branches/PHP_5_2/main/rfc1867.c 2009-11-16 13:34:57 UTC (rev 
290820)
@@ -795,13 +795,8 @@
zend_llist header;
void *event_extra_data = NULL;
int llen = 0;
-   char *max_uploads = INI_STR(max_file_uploads);
-   int upload_cnt = 0;
+   int upload_cnt = INI_INT(max_file_uploads);

-   if (max_uploads  *max_uploads) {
-   upload_cnt = atoi(max_uploads);
-   }
-
if (SG(request_info).content_length  SG(post_max_size)) {
sapi_module.sapi_error(E_WARNING, POST Content-Length of %ld 
bytes exceeds the limit of %ld bytes, SG(request_info).content_length, 
SG(post_max_size));
return;

Modified: php/php-src/branches/PHP_5_3/main/rfc1867.c
===
--- php/php-src/branches/PHP_5_3/main/rfc1867.c 2009-11-16 13:34:48 UTC (rev 
290819)
+++ php/php-src/branches/PHP_5_3/main/rfc1867.c 2009-11-16 13:34:57 UTC (rev 
290820)
@@ -795,13 +795,8 @@
zend_llist header;
void *event_extra_data = NULL;
int llen = 0;
-   char *max_uploads = INI_STR(max_file_uploads);
-   int upload_cnt = 0;
+   int upload_cnt = INI_INT(max_file_uploads);

-   if (max_uploads  *max_uploads) {
-   upload_cnt = atoi(max_uploads);
-   }
-
if (SG(request_info).content_length  SG(post_max_size)) {
sapi_module.sapi_error(E_WARNING, POST Content-Length of %ld 
bytes exceeds the limit of %ld bytes, SG(request_info).content_length, 
SG(post_max_size));
return;

Modified: php/php-src/trunk/main/rfc1867.c
===
--- php/php-src/trunk/main/rfc1867.c2009-11-16 13:34:48 UTC (rev 290819)
+++ php/php-src/trunk/main/rfc1867.c2009-11-16 13:34:57 UTC (rev 290820)
@@ -594,13 +594,8 @@
zend_llist header;
void *event_extra_data = NULL;
int llen = 0;
-   char *max_uploads = INI_STR(max_file_uploads);
-   int upload_cnt = 0;
+   int upload_cnt = INI_INT(max_file_uploads);

-   if (max_uploads  *max_uploads) {
-   upload_cnt = atoi(max_uploads);
-   }
-
if (SG(request_info).content_length  SG(post_max_size)) {
sapi_module.sapi_error(E_WARNING, POST Content-Length of %ld 
bytes exceeds the limit of %ld bytes, SG(request_info).content_length, 
SG(post_max_size));
return;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php