summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-02-27 03:28:17 (GMT)
committerIlia Alshanetsky <iliaa@php.net>2007-02-27 03:28:17 (GMT)
commitefad70c2cc2edd8416a18ea6daf06f8627d1d68d (patch)
tree0a59c0e22bb3b224433600d86b8430276ed87b45
parentcc04404b28d10481f63be986fe815de1fe31088b (diff)
downloadphp-efad70c2cc2edd8416a18ea6daf06f8627d1d68d.tar.gz
snprintf() -> slprintf()
-rw-r--r--ext/ftp/ftp.c4
-rw-r--r--ext/hash/hash.c2
-rw-r--r--ext/mbstring/oniguruma/regerror.c3
-rw-r--r--ext/mhash/mhash.c2
-rw-r--r--ext/pcre/pcrelib/pcregrep.c2
-rw-r--r--ext/pdo_firebird/firebird_driver.c2
-rw-r--r--ext/session/mod_mm.c2
-rw-r--r--ext/session/session.c2
-rwxr-xr-xext/spl/spl_directory.c2
-rwxr-xr-xext/spl/spl_iterators.c2
-rw-r--r--ext/standard/html.c2
-rw-r--r--ext/standard/http_fopen_wrapper.c4
-rw-r--r--ext/standard/string.c2
-rw-r--r--ext/wddx/wddx.c6
-rw-r--r--main/SAPI.c6
-rw-r--r--sapi/cgi/cgi_main.c8
-rw-r--r--sapi/cgi/fastcgi.c4
-rw-r--r--sapi/tux/php_tux.c4
18 files changed, 31 insertions, 28 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index e98fbb2..666f23c 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -1102,13 +1102,13 @@ ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char *args)
if (strlen(cmd) + strlen(args) + 4 > FTP_BUFSIZE) {
return 0;
}
- size = snprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s %s\r\n", cmd, args);
+ size = slprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s %s\r\n", cmd, args);
} else {
/* "cmd\r\n\0" */
if (strlen(cmd) + 3 > FTP_BUFSIZE) {
return 0;
}
- size = snprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s\r\n", cmd);
+ size = slprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s\r\n", cmd);
}
data = ftp->outbuf;
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index bb719e2..05a4518 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -588,7 +588,7 @@ PHP_MINFO_FUNCTION(hash)
for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos);
(type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, NULL, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT;
zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) {
- s += snprintf(s, e - s, "%s ", str);
+ s += slprintf(s, e - s, "%s ", str);
}
*s = 0;
diff --git a/ext/mbstring/oniguruma/regerror.c b/ext/mbstring/oniguruma/regerror.c
index 0e0174d..134cf25 100644
--- a/ext/mbstring/oniguruma/regerror.c
+++ b/ext/mbstring/oniguruma/regerror.c
@@ -278,6 +278,9 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
va_init_list(args, fmt);
n = vsnprintf((char* )buf, bufsize, (const char* )fmt, args);
+ if (n >= bufsize) {
+ return;
+ }
va_end(args);
need = (pat_end - pat) * 4 + 4;
diff --git a/ext/mhash/mhash.c b/ext/mhash/mhash.c
index 3387d44..f9c2af3 100644
--- a/ext/mhash/mhash.c
+++ b/ext/mhash/mhash.c
@@ -70,7 +70,7 @@ PHP_MINIT_FUNCTION(mhash)
for (i=0; i<n; i++) {
if ((name = mhash_get_hash_name(i))) {
- l = snprintf(buf, 127, "MHASH_%s", name);
+ l = slprintf(buf, 127, "MHASH_%s", name);
zend_register_long_constant(buf, l + 1, i, CONST_PERSISTENT, module_number TSRMLS_CC);
free(name);
}
diff --git a/ext/pcre/pcrelib/pcregrep.c b/ext/pcre/pcrelib/pcregrep.c
index 4db7348..e5ceec3 100644
--- a/ext/pcre/pcrelib/pcregrep.c
+++ b/ext/pcre/pcrelib/pcregrep.c
@@ -1188,7 +1188,7 @@ if ((sep = isdirectory(pathname)) != 0)
while ((nextfile = readdirectory(dir)) != NULL)
{
int frc, blen;
- blen = snprintf(buffer, sizeof(buffer), "%.512s%c%.128s", pathname, sep, nextfile);
+ blen = slprintf(buffer, sizeof(buffer), "%.512s%c%.128s", pathname, sep, nextfile);
if (exclude_compiled != NULL &&
pcre_exec(exclude_compiled, NULL, buffer, blen, 0, 0, NULL, 0) >= 0)
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index 7e65a88..6a6bc09 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -619,7 +619,7 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
/* loop through all the provided arguments and set dpb fields accordingly */
for (i = 0; i < sizeof(dpb_flags); ++i) {
if (dpb_values[i] && buf_len > 0) {
- dpb_len = snprintf(dpb, buf_len, "%c%c%s", dpb_flags[i], (unsigned char)strlen(dpb_values[i]),
+ dpb_len = slprintf(dpb, buf_len, "%c%c%s", dpb_flags[i], (unsigned char)strlen(dpb_values[i]),
dpb_values[i]);
dpb += dpb_len;
buf_len -= dpb_len;
diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c
index 80fab9d..17bb058 100644
--- a/ext/session/mod_mm.c
+++ b/ext/session/mod_mm.c
@@ -262,7 +262,7 @@ PHP_MINIT_FUNCTION(ps_mm)
return FAILURE;
}
- if (!(euid_len = snprintf(euid, sizeof(euid), "%d", geteuid()))) {
+ if (!(euid_len = slprintf(euid, sizeof(euid), "%d", geteuid()))) {
return FAILURE;
}
diff --git a/ext/session/session.c b/ext/session/session.c
index 50dd3a5..2b20dde 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -950,7 +950,7 @@ static void strcpy_gmt(char *ubuf, time_t *when)
php_gmtime_r(when, &tm);
- n = snprintf(buf, sizeof(buf), "%s, %02d %s %d %02d:%02d:%02d GMT", /* SAFE */
+ n = slprintf(buf, sizeof(buf), "%s, %02d %s %d %02d:%02d:%02d GMT", /* SAFE */
week_days[tm.tm_wday], tm.tm_mday,
month_names[tm.tm_mon], tm.tm_year + 1900,
tm.tm_hour, tm.tm_min,
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 4847f65..5b69ac9 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1642,7 +1642,7 @@ SPL_METHOD(SplTempFileObject, __construct)
intern->file_name = "php://memory";
intern->file_name_len = 12;
} else if (ZEND_NUM_ARGS()) {
- intern->file_name_len = snprintf(tmp_fname, sizeof(tmp_fname), "php://temp/maxmemory:%ld", max_memory);
+ intern->file_name_len = slprintf(tmp_fname, sizeof(tmp_fname), "php://temp/maxmemory:%ld", max_memory);
intern->file_name = tmp_fname;
} else {
intern->file_name = "php://temp";
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index c93ded1..471b24f 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -1390,7 +1390,7 @@ SPL_METHOD(RegexIterator, accept)
if (intern->u.regex.flags & REGIT_USE_KEY) {
if (intern->current.key_type == HASH_KEY_IS_LONG) {
- subject_len = snprintf(tmp, sizeof(tmp), "%ld", intern->current.int_key);
+ subject_len = slprintf(tmp, sizeof(tmp), "%ld", intern->current.int_key);
subject = &tmp[0];
use_copy = 0;
} else {
diff --git a/ext/standard/html.c b/ext/standard/html.c
index 30539cd..e2badee 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -912,7 +912,7 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *new
if (entity_map[j].table[k - entity_map[j].basechar] == NULL)
continue;
- entity_length = snprintf(entity, sizeof(entity), "&%s;", entity_map[j].table[k - entity_map[j].basechar]);
+ entity_length = slprintf(entity, sizeof(entity), "&%s;", entity_map[j].table[k - entity_map[j].basechar]);
if (entity_length >= sizeof(entity)) {
continue;
}
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index c43aced..5ca17c9 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -438,7 +438,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
/* ensure the header is only sent if user_agent is not blank */
if (ua_len > sizeof(_UA_HEADER)) {
ua = emalloc(ua_len + 1);
- if ((ua_len = snprintf(ua, ua_len, _UA_HEADER, ua_str)) > 0) {
+ if ((ua_len = slprintf(ua, ua_len, _UA_HEADER, ua_str)) > 0) {
ua[ua_len] = 0;
php_stream_write(stream, ua, ua_len);
} else {
@@ -456,7 +456,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS &&
Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) {
if (!(have_header & HTTP_HEADER_CONTENT_LENGTH)) {
- scratch_len = snprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_PP(tmpzval));
+ scratch_len = slprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_PP(tmpzval));
php_stream_write(stream, scratch, scratch_len);
}
if (!(have_header & HTTP_HEADER_TYPE)) {
diff --git a/ext/standard/string.c b/ext/standard/string.c
index c65da88..854c3ec 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 = snprintf(stmp, sizeof(stmp), "%ld", Z_LVAL_PP(tmp));
+ str_len = slprintf(stmp, sizeof(stmp), "%ld", Z_LVAL_PP(tmp));
smart_str_appendl(&implstr, stmp, str_len);
}
break;
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 6bdbb05..a250e20 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -284,7 +284,7 @@ PS_SERIALIZER_DECODE_FUNC(wddx)
switch (hash_type) {
case HASH_KEY_IS_LONG:
- key_length = snprintf(tmp, sizeof(tmp), "%ld", idx) + 1;
+ key_length = slprintf(tmp, sizeof(tmp), "%ld", idx) + 1;
key = tmp;
/* fallthru */
case HASH_KEY_IS_STRING:
@@ -501,7 +501,7 @@ static void php_wddx_serialize_object(wddx_packet *packet, zval *obj)
zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name);
php_wddx_serialize_var(packet, *ent, prop_name, strlen(prop_name)+1 TSRMLS_CC);
} else {
- key_len = snprintf(tmp_buf, sizeof(tmp_buf), "%ld", idx);
+ key_len = slprintf(tmp_buf, sizeof(tmp_buf), "%ld", idx);
php_wddx_serialize_var(packet, *ent, tmp_buf, key_len TSRMLS_CC);
}
}
@@ -572,7 +572,7 @@ static void php_wddx_serialize_array(wddx_packet *packet, zval *arr)
if (ent_type == HASH_KEY_IS_STRING) {
php_wddx_serialize_var(packet, *ent, key, key_len TSRMLS_CC);
} else {
- key_len = snprintf(tmp_buf, sizeof(tmp_buf), "%ld", idx);
+ key_len = slprintf(tmp_buf, sizeof(tmp_buf), "%ld", idx);
php_wddx_serialize_var(packet, *ent, tmp_buf, key_len TSRMLS_CC);
}
} else
diff --git a/main/SAPI.c b/main/SAPI.c
index db43b32..bb36227 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -687,7 +687,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
/* If there is no realm string at all, append one */
if(!strstr(lower_temp,"realm")) {
efree(result);
- conv_len = snprintf(conv_temp, sizeof(conv_temp), " realm=\"%ld\"",myuid);
+ conv_len = slprintf(conv_temp, sizeof(conv_temp), " realm=\"%ld\"",myuid);
result = emalloc(ptr_len+conv_len+1);
result_len = ptr_len+conv_len;
memcpy(result, ptr, ptr_len);
@@ -774,7 +774,7 @@ SAPI_API int sapi_send_headers(TSRMLS_D)
assert(Z_STRVAL_P(uf_result) != NULL);
- len = snprintf(buf, sizeof(buf), "Content-Encoding: %s", Z_STRVAL_P(uf_result));
+ len = slprintf(buf, sizeof(buf), "Content-Encoding: %s", Z_STRVAL_P(uf_result));
if (len <= 0 || sapi_add_header(buf, len, 1) == FAILURE) {
return FAILURE;
}
@@ -818,7 +818,7 @@ SAPI_API int sapi_send_headers(TSRMLS_D)
http_status_line.header_len = strlen(SG(sapi_headers).http_status_line);
} else {
http_status_line.header = buf;
- http_status_line.header_len = snprintf(buf, sizeof(buf), "HTTP/1.0 %d X", SG(sapi_headers).http_response_code);
+ http_status_line.header_len = slprintf(buf, sizeof(buf), "HTTP/1.0 %d X", SG(sapi_headers).http_response_code);
}
sapi_module.send_header(&http_status_line, SG(server_context) TSRMLS_CC);
}
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index fba7686..d97d75e 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -325,7 +325,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
int len;
if (CGIG(rfc2616_headers) && SG(sapi_headers).http_status_line) {
- len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH,
+ len = slprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH,
"%s\r\n", SG(sapi_headers).http_status_line);
if (len > SAPI_CGI_MAX_HEADER_LENGTH) {
@@ -333,7 +333,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
}
} else {
- len = snprintf(buf, sizeof(buf), "Status: %d\r\n", SG(sapi_headers).http_response_code);
+ len = slprintf(buf, sizeof(buf), "Status: %d\r\n", SG(sapi_headers).http_response_code);
}
PHPWRITE_H(buf, len);
@@ -444,13 +444,13 @@ static char *_sapi_cgibin_putenv(char *name, char *value TSRMLS_DC)
#endif
#if !HAVE_SETENV
if (value) {
- len = snprintf(buf, len - 1, "%s=%s", name, value);
+ len = slprintf(buf, len - 1, "%s=%s", name, value);
putenv(buf);
}
#endif
#if !HAVE_UNSETENV
if (!value) {
- len = snprintf(buf, len - 1, "%s=", name);
+ len = slprintf(buf, len - 1, "%s=", name);
putenv(buf);
}
#endif
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index 6e91580..8ca3d56 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -588,8 +588,8 @@ static int fcgi_read_request(fcgi_request *req)
for (j = 0; j < sizeof(fcgi_mgmt_vars)/sizeof(fcgi_mgmt_vars[0]); j++) {
if (zend_hash_exists(&req->env, fcgi_mgmt_vars[j].name, fcgi_mgmt_vars[j].name_len+1) == 0) {
- sprintf((char*)p, "%c%c%s%c", fcgi_mgmt_vars[j].name_len, 1, fcgi_mgmt_vars[j].name, fcgi_mgmt_vars[j].val);
- p += fcgi_mgmt_vars[j].name_len + 3;
+ sprintf((char*)p, "%c%c%s%c", fcgi_mgmt_vars[j].name_len, 1, fcgi_mgmt_vars[j].name, fcgi_mgmt_vars[j].val);
+ p += fcgi_mgmt_vars[j].name_len + 3;
}
}
len = p - buf - sizeof(fcgi_header);
diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c
index fd11bd8..3a3a452 100644
--- a/sapi/tux/php_tux.c
+++ b/sapi/tux/php_tux.c
@@ -116,7 +116,7 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers)
status_line = malloc(30);
/* safe sprintf use */
- len = snprintf(status_line, 30, "HTTP/1.1 %d NA\r\n", SG(sapi_headers).http_response_code);
+ len = slprintf(status_line, 30, "HTTP/1.1 %d NA\r\n", SG(sapi_headers).http_response_code);
vec[0].iov_base = status_line;
vec[0].iov_len = len;
@@ -195,7 +195,7 @@ static void sapi_tux_register_variables(zval *track_vars_array TSRMLS_DC)
sapi_header_line ctr = {0};
ctr.line = buf;
- ctr.line_len = snprintf(buf, sizeof(buf), "Server: %s", TUXAPI_version);
+ ctr.line_len = slprintf(buf, sizeof(buf), "Server: %s", TUXAPI_version);
sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array TSRMLS_CC);