summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/exec.c10
-rw-r--r--ext/standard/php_smart_str.h3
-rw-r--r--ext/standard/string.c6
3 files changed, 8 insertions, 11 deletions
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index e0ca9140f7..88a6b4ab79 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -133,7 +133,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
if (type != 3) {
b = buf;
-
+
while (php_stream_get_line(stream, b, EXEC_INPUT_BUF, &bufl)) {
/* no new line found, let's read some more */
if (b[bufl - 1] != '\n' && !php_stream_eof(stream)) {
@@ -330,7 +330,7 @@ PHPAPI char *php_escape_shell_cmd(char *str)
cmd[y++] = str[x];
break;
#else
- /* % is Windows specific for enviromental variables, ^%PATH% will
+ /* % is Windows specific for enviromental variables, ^%PATH% will
output PATH while ^%PATH^% will not. escapeshellcmd will escape all % and !.
*/
case '%':
@@ -492,7 +492,7 @@ PHP_FUNCTION(escapeshellcmd)
return;
}
cmd = php_escape_shell_cmd(command);
- RETVAL_STRING(cmd, 0);
+ RETVAL_STRINGL_CHECK(cmd, strlen(cmd), 0);
} else {
RETVAL_EMPTY_STRING();
}
@@ -517,7 +517,7 @@ PHP_FUNCTION(escapeshellarg)
return;
}
cmd = php_escape_shell_arg(argument);
- RETVAL_STRING(cmd, 0);
+ RETVAL_STRINGL_CHECK(cmd, strlen(cmd), 0);
}
}
/* }}} */
@@ -551,7 +551,7 @@ PHP_FUNCTION(shell_exec)
php_stream_close(stream);
if (total_readbytes > 0) {
- RETVAL_STRINGL(ret, total_readbytes, 0);
+ RETVAL_STRINGL_CHECK(ret, total_readbytes, 0);
}
}
/* }}} */
diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h
index edd9d3a89f..a336660987 100644
--- a/ext/standard/php_smart_str.h
+++ b/ext/standard/php_smart_str.h
@@ -57,7 +57,8 @@
newlen = (n); \
(d)->a = newlen < SMART_STR_START_SIZE \
? SMART_STR_START_SIZE \
- : newlen + SMART_STR_PREALLOC; \
+ : (newlen >= (INT_MAX - SMART_STR_PREALLOC)? newlen \
+ : (newlen + INT_MAX)); \
SMART_STR_DO_REALLOC(d, what); \
} else { \
newlen = (d)->len + (n); \
diff --git a/ext/standard/string.c b/ext/standard/string.c
index abe4eb1aba..cb6a8b4315 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -908,11 +908,7 @@ PHP_FUNCTION(wordwrap)
RETURN_FALSE;
}
- if (linelength < 0) {
- /* For BC */
- linelength = 0;
- }
- if (linelength > INT_MAX) {
+ if (linelength < 0 || linelength > INT_MAX) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length should be between 0 and %d", INT_MAX);
RETURN_FALSE;
}