]> granicus.if.org Git - php/commitdiff
snprintf() -> slprintf()
authorIlia Alshanetsky <iliaa@php.net>
Tue, 27 Feb 2007 03:28:17 +0000 (03:28 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 27 Feb 2007 03:28:17 +0000 (03:28 +0000)
18 files changed:
ext/ftp/ftp.c
ext/hash/hash.c
ext/mbstring/oniguruma/regerror.c
ext/mhash/mhash.c
ext/pcre/pcrelib/pcregrep.c
ext/pdo_firebird/firebird_driver.c
ext/session/mod_mm.c
ext/session/session.c
ext/spl/spl_directory.c
ext/spl/spl_iterators.c
ext/standard/html.c
ext/standard/http_fopen_wrapper.c
ext/standard/string.c
ext/wddx/wddx.c
main/SAPI.c
sapi/cgi/cgi_main.c
sapi/cgi/fastcgi.c
sapi/tux/php_tux.c

index e98fbb20a828c690277a6d3d313dfe781ad22fcc..666f23c582258054bdea5ae5f2d7f9a4788abbd2 100644 (file)
@@ -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;
index bb719e295d1fc4117671bd648aa567a1b48ff6f3..05a4518746b9a826b8c071e022c0bc934ce120d7 100644 (file)
@@ -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;
 
index 0e0174d8a8589c29ae1eb1045180e4a229800136..134cf25c6b6dc4ccb349cb3ba7496fdad24fd308 100644 (file)
@@ -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;
index 3387d44b15c692c3d7ce9f061625364d95c5cde9..f9c2af32303fbc683dfaea3ca2c2173fde13ff60 100644 (file)
@@ -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);
                }
index 4db73485d697106ba0299575aa4dc53f87665256..e5ceec3ace6da48053fe86993ab5e0eb71a11b09 100644 (file)
@@ -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)
index 7e65a880a7a5d209078779970e7d7a7e5a0e7953..6a6bc0969657340f00cca876502003d3754689b8 100644 (file)
@@ -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;
index 80fab9d690837296c113ecfc4887f8ed09b74c1e..17bb0589ec4f48084588e46921ae95cc73f4b30c 100644 (file)
@@ -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;
        }
                
index 50dd3a529760a17c5bcfe333677ff2b409f65dd1..2b20dde0aac4ba3c4dde6509d36a91a1aaca9bf7 100644 (file)
@@ -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, 
index 4847f65edba0ff8bba52cf4a40190661b79f50cc..5b69ac97927d086c4566df92baa9d876b2e4c6fe 100755 (executable)
@@ -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";
index c93ded1762e52be28afe469e238c64d3cf09c1e7..471b24f4333494aa1382ff9d765bfd945dd6eef3 100755 (executable)
@@ -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 {
index 30539cdf6f0dc9ded3b5ba31ccf30acb5d96e806..e2badee4748fa5097b266ff6a3acf52e56c5b2cb 100644 (file)
@@ -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;
                                }
index c43aced2cb3a9d420732e295083d603cf6828a64..5ca17c9ed7b52d27cc91effac347f903097cf9ec 100644 (file)
@@ -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)) {
index c65da880877a28a7fd2f596d01e4f0ddab44e0b7..854c3ec17438618165692d67586cb224e07b1089 100644 (file)
@@ -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;
index 6bdbb05ed3cffc3054bc6cc15383502d8a3fd8ac..a250e20e36573bc64678c2297e4182c04f2c974f 100644 (file)
@@ -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
index db43b32ab80d88b8fa8348e8f9738019d2c4c75d..bb362272797fac83cbab5ac0320f08bf2f6ef494 100644 (file)
@@ -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);
                        }
index fba7686f730b5978af2ee0b574e456d4a3127ddd..d97d75efeb2a7283739cc704a74b465739700db9 100644 (file)
@@ -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
index 6e915804f10d75c0a9eae7dc92d2693228b447bd..8ca3d569a788ea5667fd96fe051c1722e3455577 100644 (file)
@@ -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);
index fd11bd8a42dd94c572f8ffb5dbbeb691484c4c25..3a3a452eea8c1a02e4dd2db2688439c5b0f8a2c9 100644 (file)
@@ -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);