]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.6'
authorStanislav Malyshev <stas@php.net>
Tue, 12 May 2015 21:31:52 +0000 (14:31 -0700)
committerStanislav Malyshev <stas@php.net>
Tue, 12 May 2015 22:00:24 +0000 (15:00 -0700)
* PHP-5.6:
  fix format
  update NEWS
  Add test for bug #69522
  Update tests
  Fix bug #69522 - do not allow int overflow
  Forgot test file
  Fix bug #69403 and other int overflows
  Fixed bug #69418 - more s->p fixes for filenames
  Fixed bug #69364 - use smart_str to assemble strings
  Fix bug #69453 - don't try to cut empty string
  Fix bug #69545 - avoid overflow when reading list

Conflicts:
Zend/zend_alloc.c
Zend/zend_operators.c
ext/ftp/ftp.c
ext/pcntl/pcntl.c
ext/standard/basic_functions.c
ext/standard/dir.c
ext/standard/file.c
ext/standard/pack.c
ext/standard/string.c
main/rfc1867.c

1  2 
Zend/zend_alloc.c
ext/ftp/ftp.c
ext/pcntl/pcntl.c
ext/phar/tar.c
ext/standard/basic_functions.c
ext/standard/dir.c
ext/standard/file.c
ext/standard/pack.c
main/rfc1867.c

Simple merge
diff --cc ext/ftp/ftp.c
Simple merge
index 4842e1af44edacd7df6e76a7a83505146d490c6a,975b7f8108950e383020dfa74c713222b715dcea..7e7513977139568928ce57926297d2cbf8e985ef
@@@ -778,12 -748,14 +778,12 @@@ PHP_FUNCTION(pcntl_exec
        char **argv = NULL, **envp = NULL;
        char **current_arg, **pair;
        int pair_length;
 -      char *key;
 -      uint key_length;
 +      zend_string *key;
        char *path;
 -      int path_len;
 -      ulong key_num;
 +      size_t path_len;
 +      zend_ulong key_num;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|aa", &path, &path_len, &args, &envs) == FAILURE) {
 -      if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|aa", &path, &path_len, &args, &envs) == FAILURE) {
++      if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|aa", &path, &path_len, &args, &envs) == FAILURE) {
                return;
        }
  
diff --cc ext/phar/tar.c
Simple merge
index 5e23fe2ea492b628b915494928cb773f1b263db9,9b13b3a27ffb5fe2100d602f1d19e29269254535..50dcab718a6cabd45c24f361a1436835a894ed3b
@@@ -5405,11 -5463,11 +5405,11 @@@ PHP_FUNCTION(ini_restore
     Sets the include_path configuration option */
  PHP_FUNCTION(set_include_path)
  {
 -      char *new_value;
 -      int new_value_len;
 +      zend_string *new_value;
        char *old_value;
 +      zend_string *key;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &new_value) == FAILURE) {
 -      if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &new_value, &new_value_len) == FAILURE) {
++      if (zend_parse_parameters(ZEND_NUM_ARGS(), "P", &new_value) == FAILURE) {
                return;
        }
  
index b1d211a9c8539489be27a24ed8233242e5b7aacb,dc3b4cad396984d84ba5cf631645b4a561065054..463cfa92236a07eecd742c4badd177d1d599f1eb
@@@ -224,7 -219,7 +224,7 @@@ static void _php_do_opendir(INTERNAL_FU
        php_stream_context *context = NULL;
        php_stream *dirp;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|r", &dirname, &dir_len, &zcontext) == FAILURE) {
 -      if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|r", &dirname, &dir_len, &zcontext) == FAILURE) {
++      if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|r", &dirname, &dir_len, &zcontext) == FAILURE) {
                RETURN_NULL();
        }
  
@@@ -297,10 -292,9 +297,10 @@@ PHP_FUNCTION(closedir
  PHP_FUNCTION(chroot)
  {
        char *str;
 -      int ret, str_len;
 +      int ret;
 +      size_t str_len;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &str_len) == FAILURE) {
 -      if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &str, &str_len) == FAILURE) {
++      if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &str, &str_len) == FAILURE) {
                RETURN_FALSE;
        }
  
index fa9e752dc62d04791eef57bf4f409b2ac1344a94,02ab4923f0bece10bc62285353b19293f1314858..7aa1ce7a853e85a65f4d120e07f389baa0c460ef
@@@ -801,12 -816,13 +801,12 @@@ parse_eol
  PHP_FUNCTION(tempnam)
  {
        char *dir, *prefix;
 -      int dir_len, prefix_len;
 -      size_t p_len;
 -      char *opened_path;
 -      char *p;
 +      size_t dir_len, prefix_len;
 +      zend_string *opened_path;
        int fd;
 +      zend_string *p;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
 -      if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
++      if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
                return;
        }
  
@@@ -1353,7 -1347,7 +1353,7 @@@ PHP_FUNCTION(rmdir
        zval *zcontext = NULL;
        php_stream_context *context;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|r", &dir, &dir_len, &zcontext) == FAILURE) {
 -      if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|r", &dir, &dir_len, &zcontext) == FAILURE) {
++      if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|r", &dir, &dir_len, &zcontext) == FAILURE) {
                RETURN_FALSE;
        }
  
index 5fc13888f9dd5fbdb4e0049ea28d77379a78b39c,457392bd84550f71ce1c8ff6329523e16743896d..4327c7db104228fff722a06f1dff57e2b763d08f
@@@ -713,8 -736,9 +719,9 @@@ PHP_FUNCTION(unpack
                        }
  
                        if (size != 0 && size != -1 && INT_MAX - size + 1 < inputpos) {
 -                              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type %c: integer overflow", type);
 +                              php_error_docref(NULL, E_WARNING, "Type %c: integer overflow", type);
-                               inputpos = 0;
+                               zval_dtor(return_value);
+                               RETURN_FALSE;
                        }
  
                        if ((inputpos + size) <= inputlen) {
diff --cc main/rfc1867.c
index 8425ece7e0574f279dee67a23455285dd020969a,ca8f28b5534621f342d754dc17c4c169b78800a7..3c1bfa6b4f54b902b36794e07556cb74bac1876a
@@@ -33,6 -33,7 +33,7 @@@
  #include "php_variables.h"
  #include "rfc1867.h"
  #include "ext/standard/php_string.h"
 -#include "ext/standard/php_smart_str.h"
++#include "ext/standard/php_smart_string.h"
  
  #if defined(PHP_WIN32) && !defined(HAVE_ATOLL)
  # define atoll(s) _atoi64(s)
@@@ -405,27 -401,27 +406,27 @@@ static int find_boundary(multipart_buff
  }
  
  /* parse headers */
 -static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header TSRMLS_DC)
 +static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
  {
        char *line;
-       mime_header_entry prev_entry = {0}, entry;
-       int prev_len, cur_len;
+       mime_header_entry entry = {0};
 -      smart_str buf_value = {0};
++      smart_string buf_value = {0};
+       char *key = NULL;
  
        /* didn't find boundary, abort */
 -      if (!find_boundary(self, self->boundary TSRMLS_CC)) {
 +      if (!find_boundary(self, self->boundary)) {
                return 0;
        }
  
        /* get lines of text, or CRLF_CRLF */
  
 -      while( (line = get_line(self TSRMLS_CC)) && line[0] != '\0' )
 +      while( (line = get_line(self)) && line[0] != '\0' )
        {
                /* add header to table */
-               char *key = line;
                char *value = NULL;
  
 -              if (php_rfc1867_encoding_translation(TSRMLS_C)) {
 -                      self->input_encoding = zend_multibyte_encoding_detector((unsigned char *)line, strlen(line), self->detect_order, self->detect_order_size TSRMLS_CC);
 +              if (php_rfc1867_encoding_translation()) {
 +                      self->input_encoding = zend_multibyte_encoding_detector((const unsigned char *) line, strlen(line), self->detect_order, self->detect_order_size);
                }
  
                /* space in the beginning means same header */
                }
  
                if (value) {
-                       *value = 0;
+                       if(buf_value.c && key) {
+                               /* new entry, add the old one to the list */
 -                              smart_str_0(&buf_value);
++                              smart_string_0(&buf_value);
+                               entry.key = key;
+                               entry.value = buf_value.c;
+                               zend_llist_add_element(header, &entry);
+                               buf_value.c = NULL;
+                               key = NULL;
+                       }
+                       *value = '\0';
                        do { value++; } while(isspace(*value));
  
-                       entry.value = estrdup(value);
-                       entry.key = estrdup(key);
-               } else if (zend_llist_count(header)) { /* If no ':' on the line, add to previous line */
-                       prev_len = (int)strlen(prev_entry.value);
-                       cur_len = (int)strlen(line);
-                       entry.value = emalloc(prev_len + cur_len + 1);
-                       memcpy(entry.value, prev_entry.value, prev_len);
-                       memcpy(entry.value + prev_len, line, cur_len);
-                       entry.value[cur_len + prev_len] = '\0';
-                       entry.key = estrdup(prev_entry.key);
-                       zend_llist_remove_tail(header);
+                       key = estrdup(line);
 -                      smart_str_appends(&buf_value, value);
++                      smart_string_appends(&buf_value, value);
+               } else if (buf_value.c) { /* If no ':' on the line, add to previous line */
 -                      smart_str_appends(&buf_value, line);
++                      smart_string_appends(&buf_value, line);
                } else {
                        continue;
                }
 -              smart_str_0(&buf_value);
+       }
 +
+       if(buf_value.c && key) {
+               /* add the last one to the list */
++              smart_string_0(&buf_value);
+               entry.key = key;
+               entry.value = buf_value.c;
                zend_llist_add_element(header, &entry);
-               prev_entry = entry;
        }
  
        return 1;