summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/dns.c2
-rw-r--r--ext/standard/head.c6
-rw-r--r--ext/standard/image.c2
-rw-r--r--ext/standard/pack.c4
-rw-r--r--ext/standard/proc_open.c3
-rw-r--r--ext/standard/scanf.c2
-rw-r--r--ext/standard/string.c4
-rw-r--r--ext/standard/type.c3
8 files changed, 11 insertions, 15 deletions
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index eca8eeb641..fd40806167 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -422,7 +422,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
switch (type) {
case DNS_T_A:
add_assoc_string(*subarray, "type", "A", 1);
- sprintf(name, "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]);
+ snprintf(name, sizeof(name), "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]);
add_assoc_string(*subarray, "ip", name, 1);
cp += dlen;
break;
diff --git a/ext/standard/head.c b/ext/standard/head.c
index af945ff8e0..7240d777d3 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -94,8 +94,6 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
if (domain) {
len += domain_len;
}
- cookie = emalloc(len + 100);
-
if (value && value_len == 0) {
/*
* MSIE doesn't delete a cookie when you set it to a null value
@@ -104,10 +102,10 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
*/
time_t t = time(NULL) - 31536001;
dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, t, 0 TSRMLS_CC);
- sprintf(cookie, "Set-Cookie: %s=deleted; expires=%s", name, dt);
+ spprintf(&cookie, 0, "Set-Cookie: %s=deleted; expires=%s", name, dt);
efree(dt);
} else {
- sprintf(cookie, "Set-Cookie: %s=%s", name, value ? encoded_value : "");
+ spprintf(&cookie, 0, "Set-Cookie: %s=%s", name, value ? encoded_value : "");
if (expires > 0) {
strlcat(cookie, "; expires=", len + 100);
dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, expires, 0 TSRMLS_CC);
diff --git a/ext/standard/image.c b/ext/standard/image.c
index 5e7d5e7c75..804f185cdf 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -454,7 +454,7 @@ static int php_read_APP(php_stream * stream, unsigned int marker, zval *info TSR
return 0;
}
- sprintf(markername, "APP%d", marker - M_APP0);
+ snprintf(markername, sizeof(markername), "APP%d", marker - M_APP0);
if (zend_hash_find(Z_ARRVAL_P(info), markername, strlen(markername)+1, (void **) &tmp) == FAILURE) {
/* XXX we onyl catch the 1st tag of it's kind! */
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index 9946469473..569266ea1a 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -644,10 +644,10 @@ PHP_FUNCTION(unpack)
if (arg != 1 || namelen == 0) {
/* Need to add element number to name */
- sprintf(n, "%.*s%d", namelen, name, i + 1);
+ snprintf(n, sizeof(n), "%.*s%d", namelen, name, i + 1);
} else {
/* Truncate name to next format code or end of string */
- sprintf(n, "%.*s", namelen, name);
+ snprintf(n, sizeof(n), "%.*s", namelen, name);
}
if (size != 0 && size != -1 && INT_MAX - size + 1 < inputpos) {
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index 7f92554ed1..15cea0d836 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -747,8 +747,7 @@ PHP_FUNCTION(proc_open)
if (bypass_shell) {
newprocok = CreateProcess(NULL, command, &security, &security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, &si, &pi);
} else {
- command_with_cmd = emalloc(command_len + sizeof(COMSPEC_9X) + 1 + sizeof(" /c "));
- sprintf(command_with_cmd, "%s /c %s", GetVersion() < 0x80000000 ? COMSPEC_NT : COMSPEC_9X, command);
+ spprintf(&command_with_cmd, 0, "%s /c %s", GetVersion() < 0x80000000 ? COMSPEC_NT : COMSPEC_9X, command);
newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, &si, &pi);
diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c
index e82d9140fc..baddeb24b2 100644
--- a/ext/standard/scanf.c
+++ b/ext/standard/scanf.c
@@ -1094,7 +1094,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
*end = '\0';
value = (int) (*fn)(buf, NULL, base);
if ((flags & SCAN_UNSIGNED) && (value < 0)) {
- sprintf(buf, "%u", value); /* INTL: ISO digit */
+ snprintf(buf, sizeof(buf), "%u", value); /* INTL: ISO digit */
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 355792778b..a82aa0c34f 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -905,7 +905,7 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC)
case IS_LONG: {
char stmp[MAX_LENGTH_OF_LONG + 1];
- str_len = sprintf(stmp, "%ld", Z_LVAL_PP(tmp));
+ str_len = snprintf(stmp, sizeof(stmp), "%ld", Z_LVAL_PP(tmp));
smart_str_appendl(&implstr, stmp, str_len);
}
break;
@@ -2915,7 +2915,7 @@ char *php_strerror(int errnum)
return(sys_errlist[errnum]);
}
- (void) sprintf(BG(str_ebuf), "Unknown error: %d", errnum);
+ (void) snprintf(BG(str_ebuf), sizeof(php_basic_globals.str_ebuf), "Unknown error: %d", errnum);
return(BG(str_ebuf));
}
/* }}} */
diff --git a/ext/standard/type.c b/ext/standard/type.c
index a8ea3909d1..268040903a 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -64,8 +64,7 @@ PHP_FUNCTION(gettype)
int res_len;
res_len = sizeof("object of type ")-1 + Z_OBJCE_P(arg)->name_length;
- result = (char *) emalloc(res_len+1);
- sprintf(result, "object of type %s", Z_OBJCE_P(arg)->name);
+ spprintf(&result, 0, "object of type %s", Z_OBJCE_P(arg)->name);
RETVAL_STRINGL(result, res_len, 0);
}
*/