cvs: php-src /ext/bcmath/libbcmath/src output.c rt.c /ext/com_dotnet com_wrapper.c /ext/dbase dbf_head.c dbf_misc.c /ext/exif exif.c /ext/fbsql
php_fbsql.c /ext/ftp ftp.c /ext/gd/libgd gdtest.c webpng.c /ext/imap php_imap.c /ext/interbase ibase_blobs.c ibase_query.c ibase_service.c
interbase.c /ext/mbstring mbstring.c /ext/mbstring/oniguruma regposerr.c /ext/msql php_msql.c /ext/mssql php_mssql.c /ext/mysql php_mysql.c
/ext/mysqli mysqli.c mysqli_api.c mysqli_prop.c php_mysqli.h /ext/oci8 oci8.c /ext/odbc php_odbc.c /ext/openssl openssl.c /ext/pcre/pcrelib
pcregrep.c pcreposix.c /ext/pdo_firebird firebird_statement.c /ext/pdo_odbc odbc_driver.c /ext/pgsql pgsql.c /ext/pspell pspell.c /ext/session
mod_mm.c session.c /ext/skeleton skeleton.c /ext/soap php_encoding.c php_http.c soap.c /ext/standard dns.c head.c image.c pack.c proc_open.c
scanf.c string.c type.c /ext/sybase_ct php_sybase_ct.c /ext/wddx wddx.c /ext/zip/lib zip_close.c zip_err! or_strerror.c /main fopen_wrappers.c
php_ini.c rfc1867.c /sapi/nsapi nsapi.c /sapi/tux php_tux.c /win32 registry.c sendmail.c ZendEngine2 zend.c
| From: | Marcus Boerger | Date: | Sat, 24 Feb 2007 16:25:56 +0000 |
| Subject: | cvs: php-src /ext/bcmath/libbcmath/src output.c rt.c /ext/com_dotnet com_wrapper.c /ext/dbase dbf_head.c dbf_misc.c /ext/exif exif.c /ext/fbsql php_fbsql.c /ext/ftp ftp.c /ext/gd/libgd gdtest.c webpng.c /ext/imap php_imap.c /ext/interbase ibase_blobs.c ibase_query.c ibase_service.c interbase.c /ext/mbstring mbstring.c /ext/mbstring/oniguruma regposerr.c /ext/msql php_msql.c /ext/mssql php_mssql.c /ext/mysql php_mysql.c /ext/mysqli mysqli.c mysqli_api.c mysqli_prop.c php_mysqli.h /ext/oci8 oci8.c /ext/odbc php_odbc.c /ext/openssl openssl.c /ext/pcre/pcrelib pcregrep.c pcreposix.c /ext/pdo_firebird firebird_statement.c /ext/pdo_odbc odbc_driver.c /ext/pgsql pgsql.c /ext/pspell pspell.c /ext/session mod_mm.c session.c /ext/skeleton skeleton.c /ext/soap php_encoding.c php_http.c soap.c /ext/standard dns.c head.c image.c pack.c proc_open.c scanf.c string.c type.c /ext/sybase_ct php_sybase_ct.c /ext/wddx wddx.c /ext/zip/lib zip_close.c zip_err! or_strerror.c /main fopen_wrappers.c php_ini.c rfc1867.c /sapi/nsapi nsapi.c /sapi/tux php_tux.c /win32 registry.c sendmail.c ZendEngine2 zend.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-43256@lists.php.net to get a copy of this message | ||
helly Sat Feb 24 16:25:56 2007 UTC
Modified files:
/ZendEngine2 zend.c
/php-src/ext/bcmath/libbcmath/src output.c rt.c
/php-src/ext/com_dotnet com_wrapper.c
/php-src/ext/dbase dbf_head.c dbf_misc.c
/php-src/ext/exif exif.c
/php-src/ext/fbsql php_fbsql.c
/php-src/ext/ftp ftp.c
/php-src/ext/gd/libgd gdtest.c webpng.c
/php-src/ext/imap php_imap.c
/php-src/ext/interbase ibase_blobs.c ibase_query.c ibase_service.c
interbase.c
/php-src/ext/mbstring mbstring.c
/php-src/ext/mbstring/oniguruma regposerr.c
/php-src/ext/msql php_msql.c
/php-src/ext/mssql php_mssql.c
/php-src/ext/mysql php_mysql.c
/php-src/ext/mysqli mysqli.c mysqli_api.c mysqli_prop.c
php_mysqli.h
/php-src/ext/oci8 oci8.c
/php-src/ext/odbc php_odbc.c
/php-src/ext/openssl openssl.c
/php-src/ext/pcre/pcrelib pcregrep.c pcreposix.c
/php-src/ext/pdo_firebird firebird_statement.c
/php-src/ext/pdo_odbc odbc_driver.c
/php-src/ext/pgsql pgsql.c
/php-src/ext/pspell pspell.c
/php-src/ext/session mod_mm.c session.c
/php-src/ext/skeleton skeleton.c
/php-src/ext/soap php_encoding.c php_http.c soap.c
/php-src/ext/standard dns.c head.c image.c pack.c proc_open.c
scanf.c string.c type.c
/php-src/ext/sybase_ct php_sybase_ct.c
/php-src/ext/wddx wddx.c
/php-src/ext/zip/lib zip_close.c zip_error_strerror.c
/php-src/main fopen_wrappers.c php_ini.c rfc1867.c
/php-src/sapi/nsapi nsapi.c
/php-src/sapi/tux php_tux.c
/php-src/win32 registry.c sendmail.c
Log:
- avoid sprintf
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.393&r2=1.394&diff_format=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.393 ZendEngine2/zend.c:1.394 --- ZendEngine2/zend.c:1.393 Fri Jan 19 22:19:08 2007 +++ ZendEngine2/zend.c Sat Feb 24 16:25:53 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.393 2007/01/19 22:19:08 helly Exp $ */ +/* $Id: zend.c,v 1.394 2007/02/24 16:25:53 helly Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -1697,8 +1697,7 @@ cur_lineno = 0; } - compiled_string_description = emalloc(sizeof(COMPILED_STRING_DESCRIPTION_FORMAT)+strlen(name)+strlen(cur_filename)+MAX_LENGTH_OF_LONG); - sprintf(compiled_string_description, COMPILED_STRING_DESCRIPTION_FORMAT, cur_filename, cur_lineno, name); + zend_spprintf(&compiled_string_description, 0, COMPILED_STRING_DESCRIPTION_FORMAT, cur_filename, cur_lineno, name); return compiled_string_description; } http://cvs.php.net/viewvc.cgi/php-src/ext/bcmath/libbcmath/src/output.c?r1=1.5&r2=1.6&diff_format=u Index: php-src/ext/bcmath/libbcmath/src/output.c diff -u php-src/ext/bcmath/libbcmath/src/output.c:1.5 php-src/ext/bcmath/libbcmath/src/output.c:1.6 --- php-src/ext/bcmath/libbcmath/src/output.c:1.5 Fri Nov 22 09:25:29 2002 +++ php-src/ext/bcmath/libbcmath/src/output.c Sat Feb 24 16:25:53 2007 @@ -71,7 +71,7 @@ int len, ix; if (space) (*out_char) (' '); - sprintf (digits, "%ld", val); + snprintf(digits, sizeof(digits), "%ld", val); len = strlen (digits); while (size > len) { http://cvs.php.net/viewvc.cgi/php-src/ext/bcmath/libbcmath/src/rt.c?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/bcmath/libbcmath/src/rt.c diff -u php-src/ext/bcmath/libbcmath/src/rt.c:1.1 php-src/ext/bcmath/libbcmath/src/rt.c:1.2 --- php-src/ext/bcmath/libbcmath/src/rt.c:1.1 Wed Nov 22 20:20:02 2000 +++ php-src/ext/bcmath/libbcmath/src/rt.c Sat Feb 24 16:25:53 2007 @@ -45,7 +45,7 @@ char error_mesg [255]; va_start (args, mesg); - vsprintf (error_mesg, mesg, args); + vsnprintf (error_mesg, sizeof(error_mesg), mesg, args); va_end (args); fprintf (stderr, "bc math warning: %s\n", error_mesg); @@ -58,7 +58,7 @@ char error_mesg [255]; va_start (args, mesg); - vsprintf (error_mesg, mesg, args); + vsnprintf (error_mesg, sizeof(error_mesg), mesg, args); va_end (args); fprintf (stderr, "bc math error: %s\n", error_mesg); http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_wrapper.c?r1=1.13&r2=1.14&diff_format=u Index: php-src/ext/com_dotnet/com_wrapper.c diff -u php-src/ext/com_dotnet/com_wrapper.c:1.13 php-src/ext/com_dotnet/com_wrapper.c:1.14 --- php-src/ext/com_dotnet/com_wrapper.c:1.13 Fri Feb 2 08:42:32 2007 +++ php-src/ext/com_dotnet/com_wrapper.c Sat Feb 24 16:25:53 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: com_wrapper.c,v 1.13 2007/02/02 08:42:32 wharmby Exp $ */ +/* $Id: com_wrapper.c,v 1.14 2007/02/24 16:25:53 helly Exp $ */ /* This module exports a PHP object as a COM object by wrapping it * using IDispatchEx */ @@ -74,7 +74,7 @@ va_list ap; char buf[4096]; - sprintf(buf, "T=%08x ", GetCurrentThreadId()); + snprintf(buf, sizeof(buf), "T=%08x ", GetCurrentThreadId()); OutputDebugString(buf); va_start(ap, fmt); @@ -474,7 +474,7 @@ &namelen, &pid, 0, &pos))) { char namebuf[32]; if (keytype == HASH_KEY_IS_LONG) { - sprintf(namebuf, "%d", pid); + snprintf(namebuf, sizeof(namebuf), "%d", pid); name = namebuf; namelen = strlen(namebuf)+1; } @@ -506,7 +506,7 @@ char namebuf[32]; if (keytype == HASH_KEY_IS_LONG) { - sprintf(namebuf, "%d", pid); + snprintf(namebuf, sizeof(namebuf), "%d", pid); name = namebuf; namelen = strlen(namebuf) + 1; } http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbf_head.c?r1=1.18&r2=1.19&diff_format=u Index: php-src/ext/dbase/dbf_head.c diff -u php-src/ext/dbase/dbf_head.c:1.18 php-src/ext/dbase/dbf_head.c:1.19 --- php-src/ext/dbase/dbf_head.c:1.18 Wed Sep 6 11:34:15 2006 +++ php-src/ext/dbase/dbf_head.c Sat Feb 24 16:25:53 2007 @@ -215,7 +215,7 @@ int fcnt; if ((cp = db_cur_date(NULL))) { - strncpy(dbh->db_date, cp, 8); + strlcpy(dbh->db_date, cp, 8); free(cp); } put_dbf_head(dbh); @@ -232,16 +232,16 @@ /* build the field format for printf */ switch (dbf->db_type) { case 'C': - sprintf(format, "%%-%ds", dbf->db_flen); + snprintf(format, sizeof(format), "%%-%ds", dbf->db_flen); break; case 'N': case 'L': case 'D': case 'F': - sprintf(format, "%%%ds", dbf->db_flen); + snprintf(format, sizeof(format), "%%%ds", dbf->db_flen); break; case 'M': - strcpy(format, "%s"); + strlcpy(format, "%s", sizeof(format)); break; default: return NULL; http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbf_misc.c?r1=1.6&r2=1.7&diff_format=u Index: php-src/ext/dbase/dbf_misc.c diff -u php-src/ext/dbase/dbf_misc.c:1.6 php-src/ext/dbase/dbf_misc.c:1.7 --- php-src/ext/dbase/dbf_misc.c:1.6 Sun Sep 9 13:28:46 2001 +++ php-src/ext/dbase/dbf_misc.c Sat Feb 24 16:25:53 2007 @@ -114,12 +114,7 @@ month = 0; if (day > 31) day = 0; - sprintf(cp, "%d", year); - cp[4] = month / 10 + '0'; - cp[5] = month % 10 + '0'; - cp[6] = day / 10 + '0'; - cp[7] = day % 10 + '0'; - cp[8] = 0; + snprintf(cp, 9, "%04d%02d%02d", year, month, day); } int db_date_year(char *cp) http://cvs.php.net/viewvc.cgi/php-src/ext/exif/exif.c?r1=1.191&r2=1.192&diff_format=u Index: php-src/ext/exif/exif.c diff -u php-src/ext/exif/exif.c:1.191 php-src/ext/exif/exif.c:1.192 --- php-src/ext/exif/exif.c:1.191 Tue Jan 9 17:52:02 2007 +++ php-src/ext/exif/exif.c Sat Feb 24 16:25:53 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: exif.c,v 1.191 2007/01/09 17:52:02 helly Exp $ */ +/* $Id: exif.c,v 1.192 2007/02/24 16:25:53 helly Exp $ */ /* ToDos * @@ -139,7 +139,7 @@ }; /* }}} */ -#define EXIF_VERSION "1.4 $Id: exif.c,v 1.191 2007/01/09 17:52:02 helly Exp $" +#define EXIF_VERSION "1.4 $Id: exif.c,v 1.192 2007/02/24 16:25:53 helly Exp $" /* {{{ PHP_MINFO_FUNCTION */ @@ -1035,22 +1035,22 @@ static unsigned char tmp[20]; int c, i, p=0, n = 5+31; - p += sprintf(buf+p, "\nDump Len: %08X (%d)", len, len); + p += snprintf(buf+p, sizeof(buf)-p, "\nDump Len: %08X (%d)", len, len); if (len) { for(i=0; i<len+15 && p+n<=sizeof(buf); i++) { if (i%16==0) { - p += sprintf(buf+p, "\n%08X: ", i+offset); + p += snprintf(buf+p, sizeof(buf)-p, "\n%08X: ", i+offset); } if (i<len) { c = *addr++; - p += sprintf(buf+p, "%02X ", c); + p += snprintf(buf+p, sizeof(buf)-p, "%02X ", c); tmp[i%16] = c>=32 ? c : '.'; tmp[(i%16)+1] = '\0'; } else { - p += sprintf(buf+p, " "); + p += snprintf(buf+p, sizeof(buf)-p, " "); } if (i%16==15) { - p += sprintf(buf+p, " %s", tmp); + p += snprintf(buf+p, sizeof(buf)-p, " %s", tmp); if (i>=len) { break; } @@ -1181,44 +1181,44 @@ case TAG_FMT_UNDEFINED: case TAG_FMT_STRING: case TAG_FMT_SBYTE: - dump = erealloc(dump, len + 4); - sprintf(dump + len, "0x%02X", *value_ptr); + dump = erealloc(dump, len + 4 + 1); + snprintf(dump + len, 4 + 1, "0x%02X", *value_ptr); len += 4; value_ptr++; break; case TAG_FMT_USHORT: case TAG_FMT_SSHORT: - dump = erealloc(dump, len + 6); - sprintf(dump + len, "0x%04X", php_ifd_get16s(value_ptr, motorola_intel)); + dump = erealloc(dump, len + 6 + 1); + snprintf(dump + len, 6 + 1, "0x%04X", php_ifd_get16s(value_ptr, motorola_intel)); len += 6; value_ptr += 2; break; case TAG_FMT_ULONG: case TAG_FMT_SLONG: - dump = erealloc(dump, len + 6); - sprintf(dump + len, "0x%04X", php_ifd_get32s(value_ptr, motorola_intel)); + dump = erealloc(dump, len + 6 + 1); + snprintf(dump + len, 6 + 1, "0x%04X", php_ifd_get32s(value_ptr, motorola_intel)); len += 6; value_ptr += 4; break; case TAG_FMT_URATIONAL: case TAG_FMT_SRATIONAL: - dump = erealloc(dump, len + 13); - sprintf(dump + len, "0x%04X/0x%04X", php_ifd_get32s(value_ptr, motorola_intel), php_ifd_get32s(value_ptr+4, motorola_intel)); + dump = erealloc(dump, len + 13 + 1); + snprintf(dump + len, 13 + 1, "0x%04X/0x%04X", php_ifd_get32s(value_ptr, motorola_intel), php_ifd_get32s(value_ptr+4, motorola_intel)); len += 13; value_ptr += 8; break; } if (components > 0) { - dump = erealloc(dump, len + 2); - sprintf(dump + len, ", "); + dump = erealloc(dump, len + 2 + 1); + snprintf(dump + len, 2 + 1, ", "); len += 2; components--; } else{ break; } } - dump = erealloc(dump, len + 2); - sprintf(dump + len, "}"); + dump = erealloc(dump, len + 1 + 1); + snprintf(dump + len, 1 + 1, "}"); return dump; } /* }}} */ @@ -1448,18 +1448,18 @@ */ static char *exif_get_sectionlist(int sectionlist TSRMLS_DC) { - int i, len=0; + int i, len, ml = 0; char *sections; for(i=0; i<SECTION_COUNT; i++) { - len += strlen(exif_get_sectionname(i))+2; + ml += strlen(exif_get_sectionname(i))+2; } - sections = safe_emalloc(len, 1, 1); + sections = safe_emalloc(ml, 1, 1); sections[0] = '\0'; len = 0; for(i=0; i<SECTION_COUNT; i++) { if (sectionlist&(1<<i)) { - sprintf(sections+len, "%s, ", exif_get_sectionname(i)); + snprintf(sections+len, ml-len, "%s, ", exif_get_sectionname(i)); len = strlen(sections); } } @@ -3891,8 +3891,7 @@ if(ac >= 2) { convert_to_string_ex(p_sections_needed); - sections_str = safe_emalloc(strlen(Z_STRVAL_PP(p_sections_needed)), 1, 3); - sprintf(sections_str, ",%s,", Z_STRVAL_PP(p_sections_needed)); + spprintf(§ions_str, 0, ",%s,", Z_STRVAL_PP(p_sections_needed)); /* sections_str DOES start with , and SPACES are NOT allowed in names */ s = sections_str; while(*++s) { http://cvs.php.net/viewvc.cgi/php-src/ext/fbsql/php_fbsql.c?r1=1.122&r2=1.123&diff_format=u Index: php-src/ext/fbsql/php_fbsql.c diff -u php-src/ext/fbsql/php_fbsql.c:1.122 php-src/ext/fbsql/php_fbsql.c:1.123 --- php-src/ext/fbsql/php_fbsql.c:1.122 Mon Jan 1 09:29:23 2007 +++ php-src/ext/fbsql/php_fbsql.c Sat Feb 24 16:25:53 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_fbsql.c,v 1.122 2007/01/01 09:29:23 sebastian Exp $ */ +/* $Id: php_fbsql.c,v 1.123 2007/02/24 16:25:53 helly Exp $ */ /* TODO: * @@ -851,7 +851,7 @@ php_info_print_table_row(2, "Active Links", buf); /* - sprintf(buf, "%ld", FB_SQL_G(resultCount)); + snprintf(buf, sizeof(buf), "%ld", FB_SQL_G(resultCount)); php_info_print_table_row(2, "Active Results", buf); */ @@ -2944,7 +2944,7 @@ for (i = 0; i < nBits / 8; i++) { char c[4]; - sprintf(c, "%02x", ptr->bytes[i]); + snprintf(c, sizeof(c), "%02x", ptr->bytes[i]); r[i*2+2] = c[0]; r[i*2+3] = c[1]; } http://cvs.php.net/viewvc.cgi/php-src/ext/ftp/ftp.c?r1=1.121&r2=1.122&diff_format=u Index: php-src/ext/ftp/ftp.c diff -u php-src/ext/ftp/ftp.c:1.121 php-src/ext/ftp/ftp.c:1.122 --- php-src/ext/ftp/ftp.c:1.121 Tue Feb 13 18:30:19 2007 +++ php-src/ext/ftp/ftp.c Sat Feb 24 16:25:53 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ftp.c,v 1.121 2007/02/13 18:30:19 nlopess Exp $ */ +/* $Id: ftp.c,v 1.122 2007/02/24 16:25:53 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -586,11 +586,7 @@ return 0; } - if (!(buffer = emalloc(32 + filename_len + 1))) { - return 0; - } - - sprintf(buffer, "CHMOD %o %s", mode, filename); + spprintf(&buffer, 0, "CHMOD %o %s", mode, filename); if (!ftp_putcmd(ftp, "SITE", buffer)) { efree(buffer); @@ -810,7 +806,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483647 bytes"); goto bail; } - sprintf(arg, "%u", resumepos); + snprintf(arg, sizeof(arg), "%u", resumepos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -907,7 +903,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes"); goto bail; } - sprintf(arg, "%u", startpos); + snprintf(arg, sizeof(arg), "%u", startpos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -1106,13 +1102,13 @@ if (strlen(cmd) + strlen(args) + 4 > FTP_BUFSIZE) { return 0; } - size = sprintf(ftp->outbuf, "%s %s\r\n", cmd, args); + size = snprintf(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 = sprintf(ftp->outbuf, "%s\r\n", cmd); + size = snprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s\r\n", cmd); } data = ftp->outbuf; @@ -1438,7 +1434,7 @@ char eprtarg[INET6_ADDRSTRLEN + sizeof("|x||xxxxx|")]; char out[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &((struct sockaddr_in6*) sa)->sin6_addr, out, sizeof(out)); - sprintf(eprtarg, "|2|%s|%hu|", out, ntohs(((struct sockaddr_in6 *) &addr)->sin6_port)); + snprintf(eprtarg, sizeof(eprtarg), "|2|%s|%hu|", out, ntohs(((struct sockaddr_in6 *) &addr)->sin6_port)); if (!ftp_putcmd(ftp, "EPRT", eprtarg)) { goto bail; @@ -1456,7 +1452,7 @@ /* send the PORT */ ipbox.ia[0] = ((struct sockaddr_in*) sa)->sin_addr; ipbox.s[2] = ((struct sockaddr_in*) &addr)->sin_port; - sprintf(arg, "%u,%u,%u,%u,%u,%u", ipbox.c[0], ipbox.c[1], ipbox.c[2], ipbox.c[3], ipbox.c[4], ipbox.c[5]); + snprintf(arg, sizeof(arg), "%u,%u,%u,%u,%u,%u", ipbox.c[0], ipbox.c[1], ipbox.c[2], ipbox.c[3], ipbox.c[4], ipbox.c[5]); if (!ftp_putcmd(ftp, "PORT", arg)) { goto bail; @@ -1713,7 +1709,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483648 bytes"); goto bail; } - sprintf(arg, "%u", resumepos); + snprintf(arg, sizeof(arg), "%u", resumepos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -1831,7 +1827,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes"); goto bail; } - sprintf(arg, "%u", startpos); + snprintf(arg, sizeof(arg), "%u", startpos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gdtest.c?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/gd/libgd/gdtest.c diff -u php-src/ext/gd/libgd/gdtest.c:1.2 php-src/ext/gd/libgd/gdtest.c:1.3 --- php-src/ext/gd/libgd/gdtest.c:1.2 Tue Oct 29 23:08:01 2002 +++ php-src/ext/gd/libgd/gdtest.c Sat Feb 24 16:25:53 2007 @@ -56,7 +56,7 @@ /* */ /* Send to PNG File then Ptr */ /* */ - sprintf (of, "%s.png", argv[1]); + snprintf (of, sizeof(of), "%s.png", argv[1]); out = fopen (of, "wb"); gdImagePng (im, out); fclose (out); @@ -88,7 +88,7 @@ /* */ /* Send to GD2 File then Ptr */ /* */ - sprintf (of, "%s.gd2", argv[1]); + snprintf (of, sizeof(of), "%s.gd2", argv[1]); out = fopen (of, "wb"); gdImageGd2 (im, out, 128, 2); fclose (out); @@ -123,7 +123,7 @@ /* */ /* Send to GD File then Ptr */ /* */ - sprintf (of, "%s.gd", argv[1]); + snprintf (of, sizeof(of), "%s.gd", argv[1]); out = fopen (of, "wb"); gdImageGd (im, out); fclose (out); @@ -180,7 +180,7 @@ ** Test gdImagePngToSink' * */ - sprintf (of, "%s.snk", argv[1]); + snprintf (of, sizeof(of), "%s.snk", argv[1]); out = fopen (of, "wb"); imgsnk.sink = fwriteWrapper; imgsnk.context = out; http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/webpng.c?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/gd/libgd/webpng.c diff -u php-src/ext/gd/libgd/webpng.c:1.3 php-src/ext/gd/libgd/webpng.c:1.4 --- php-src/ext/gd/libgd/webpng.c:1.3 Sun Dec 28 20:11:08 2003 +++ php-src/ext/gd/libgd/webpng.c Sat Feb 24 16:25:53 2007 @@ -252,7 +252,7 @@ /* Open a temporary file. */ /* "temp.tmp" is not good temporary filename. */ - sprintf (outFn, "webpng.tmp%d", getpid ()); + snprintf (outFn, sizeof(outFn), "webpng.tmp%d", getpid ()); out = fopen (outFn, "wb"); if (!out) http://cvs.php.net/viewvc.cgi/php-src/ext/imap/php_imap.c?r1=1.237&r2=1.238&diff_format=u Index: php-src/ext/imap/php_imap.c diff -u php-src/ext/imap/php_imap.c:1.237 php-src/ext/imap/php_imap.c:1.238 --- php-src/ext/imap/php_imap.c:1.237 Mon Feb 19 16:04:14 2007 +++ php-src/ext/imap/php_imap.c Sat Feb 24 16:25:53 2007 @@ -26,7 +26,7 @@ | PHP 4.0 updates: Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_imap.c,v 1.237 2007/02/19 16:04:14 edink Exp $ */ +/* $Id: php_imap.c,v 1.238 2007/02/24 16:25:53 helly Exp $ */ #define IMAP41 @@ -1169,7 +1169,7 @@ tmp[3] = cache->answered ? 'A' : ' '; tmp[4] = cache->deleted ? 'D' : ' '; tmp[5] = cache->draft ? 'X' : ' '; - sprintf(tmp + 6, "%4ld) ", cache->msgno); + snprintf(tmp + 6, sizeof(tmp) - 6, "%4ld) ", cache->msgno); mail_date(tmp+11, cache); tmp[22] = ' '; tmp[23] = '\0'; @@ -1621,13 +1621,13 @@ add_property_string(return_value, "Deleted", cache->deleted ? "D" : " ", 1); add_property_string(return_value, "Draft", cache->draft ? "X" : " ", 1); - sprintf(dummy, "%4ld", cache->msgno); + snprintf(dummy, sizeof(dummy), "%4ld", cache->msgno); add_property_string(return_value, "Msgno", dummy, 1); mail_date(dummy, cache); add_property_string(return_value, "MailDate", dummy, 1); - sprintf(dummy, "%ld", cache->rfc822_size); + snprintf(dummy, sizeof(dummy), "%ld", cache->rfc822_size); add_property_string(return_value, "Size", dummy, 1); add_property_long(return_value, "udate", mail_longdate(cache)); @@ -3371,7 +3371,8 @@ char *tsm_errmsg = NULL; ADDRESS *addr; char *bufferTo = NULL, *bufferCc = NULL, *bufferBcc = NULL, *bufferHeader = NULL; - int offset, bufferLen = 0;; + int offset, bufferLen = 0; + size_t bt_len; if (headers) { bufferLen += strlen(headers); @@ -3393,7 +3394,9 @@ strlcat(bufferHeader, to, bufferLen + 1); strlcat(bufferHeader, "\r\n", bufferLen + 1); tempMailTo = estrdup(to); - bufferTo = (char *)emalloc(strlen(to) + 1); + bt_len = strlen(to); + bufferTo = (char *)safe_emalloc(bt_len, 1, 1); + bt_len++; offset = 0; addr = NULL; rfc822_parse_adrlist(&addr, tempMailTo, NULL); @@ -3401,7 +3404,11 @@ if (strcmp(addr->host, ERRHOST) == 0) { PHP_IMAP_BAD_DEST; } else { - offset += sprintf(bufferTo + offset, "%s@%s,", addr->mailbox, addr->host); + bufferTo = safe_erealloc(bufferTo, bt_len, 1, strlen(addr->mailbox)); + bt_len += strlen(addr->mailbox); + bufferTo = safe_erealloc(bufferTo, bt_len, 1, strlen(addr->host)); + bt_len += strlen(addr->host); + offset += snprintf(bufferTo + offset, bt_len - offset, "%s@%s,", addr->mailbox, addr->host); } addr = addr->next; } @@ -3416,7 +3423,9 @@ strlcat(bufferHeader, cc, bufferLen + 1); strlcat(bufferHeader, "\r\n", bufferLen + 1); tempMailTo = estrdup(cc); - bufferCc = (char *)emalloc(strlen(cc) + 1); + bt_len = strlen(cc); + bufferCc = (char *)safe_emalloc(bt_len, 1, 1); + bt_len++; offset = 0; addr = NULL; rfc822_parse_adrlist(&addr, tempMailTo, NULL); @@ -3424,7 +3433,11 @@ if (strcmp(addr->host, ERRHOST) == 0) { PHP_IMAP_BAD_DEST; } else { - offset += sprintf(bufferCc + offset, "%s@%s,", addr->mailbox, addr->host); + bufferCc = safe_erealloc(bufferCc, bt_len, 1, strlen(addr->mailbox)); + bt_len += strlen(addr->mailbox); + bufferCc = safe_erealloc(bufferCc, bt_len, 1, strlen(addr->host)); + bt_len += strlen(addr->host); + offset += snprintf(bufferCc + offset, bt_len - offset, "%s@%s,", addr->mailbox, addr->host); } addr = addr->next; } @@ -3436,7 +3449,9 @@ if (bcc && *bcc) { tempMailTo = estrdup(bcc); - bufferBcc = (char *)emalloc(strlen(bcc) + 1); + bt_len = strlen(bcc); + bufferBcc = (char *)safe_emalloc(bt_len, 1, 1); + bt_len++; offset = 0; addr = NULL; rfc822_parse_adrlist(&addr, tempMailTo, NULL); @@ -3444,7 +3459,11 @@ if (strcmp(addr->host, ERRHOST) == 0) { PHP_IMAP_BAD_DEST; } else { - offset += sprintf(bufferBcc + offset, "%s@%s,", addr->mailbox, addr->host); + bufferBcc = safe_erealloc(bufferBcc, bt_len, 1, strlen(addr->mailbox)); + bt_len += strlen(addr->mailbox); + bufferBcc = safe_erealloc(bufferBcc, bt_len, 1, strlen(addr->host)); + bt_len += strlen(addr->host); + offset += snprintf(bufferBcc + offset, bt_len - offset, "%s@%s,", addr->mailbox, addr->host); } addr = addr->next; } http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_blobs.c?r1=1.12&r2=1.13&diff_format=u Index: php-src/ext/interbase/ibase_blobs.c diff -u php-src/ext/interbase/ibase_blobs.c:1.12 php-src/ext/interbase/ibase_blobs.c:1.13 --- php-src/ext/interbase/ibase_blobs.c:1.12 Mon Jan 1 09:29:24 2007 +++ php-src/ext/interbase/ibase_blobs.c Sat Feb 24 16:25:53 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ibase_blobs.c,v 1.12 2007/01/01 09:29:24 sebastian Exp $ */ +/* $Id: ibase_blobs.c,v 1.13 2007/02/24 16:25:53 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -74,16 +74,15 @@ char *_php_ibase_quad_to_string(ISC_QUAD const qd) /* {{{ */ { - char *result = (char *) emalloc(BLOB_ID_LEN+1); + char *result; /* shortcut for most common case */ if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) { - sprintf(result, "0x%0*" LL_MASK "x", 16, *(ISC_UINT64*)(void *) &qd); + spprintf(&result, BLOB_ID_LEN+1, "0x%0*" LL_MASK "x", 16, *(ISC_UINT64*)(void *) &qd); } else { ISC_UINT64 res = ((ISC_UINT64) qd.gds_quad_high << 0x20) | qd.gds_quad_low; - sprintf(result, "0x%0*" LL_MASK "x", 16, res); + spprintf(&result, BLOB_ID_LEN+1, "0x%0*" LL_MASK "x", 16, res); } - result[BLOB_ID_LEN] = '\0'; return result; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.30&r2=1.31&diff_format=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.30 php-src/ext/interbase/ibase_query.c:1.31 --- php-src/ext/interbase/ibase_query.c:1.30 Mon Jan 22 09:08:21 2007 +++ php-src/ext/interbase/ibase_query.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ibase_query.c,v 1.30 2007/01/22 09:08:21 tony2001 Exp $ */ +/* $Id: ibase_query.c,v 1.31 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1312,17 +1312,17 @@ goto _sql_long; #else if (scale == 0) { - l = sprintf(string_data, "%" LL_MASK "d", *(ISC_INT64 *) data); + l = snprintf(string_data, sizeof(string_data), "%" LL_MASK "d", *(ISC_INT64 *) data); ZVAL_STRINGL(val,string_data,l,1); } else { ISC_INT64 n = *(ISC_INT64 *) data, f = scales[-scale]; if (n >= 0) { - l = sprintf(string_data, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -scale, n % f); + l = snprintf(string_data, sizeof(string_data), "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -scale, n % f); } else if (n <= -f) { - l = sprintf(string_data, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -scale, -n % f); + l = snprintf(string_data, sizeof(string_data), "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -scale, -n % f); } else { - l = sprintf(string_data, "-0.%0*" LL_MASK "d", -scale, -n % f); + l = snprintf(string_data, sizeof(string_data), "-0.%0*" LL_MASK "d", -scale, -n % f); } ZVAL_STRINGL(val,string_data,l,1); } @@ -1337,11 +1337,11 @@ long f = (long) scales[-scale]; if (n >= 0) { - l = sprintf(string_data, "%ld.%0*ld", n / f, -scale, n % f); + l = snprintf(string_data, sizeof(string_data), "%ld.%0*ld", n / f, -scale, n % f); } else if (n <= -f) { - l = sprintf(string_data, "%ld.%0*ld", n / f, -scale, -n % f); + l = snprintf(string_data, sizeof(string_data), "%ld.%0*ld", n / f, -scale, -n % f); } else { - l = sprintf(string_data, "-0.%0*ld", -scale, -n % f); + l = snprintf(string_data, sizeof(string_data), "-0.%0*ld", -scale, -n % f); } ZVAL_STRINGL(val,string_data,l,1); } @@ -1381,14 +1381,14 @@ #else switch (type & ~1) { default: - l = sprintf(string_data, "%02d/%02d/%4d %02d:%02d:%02d", t.tm_mon+1, t.tm_mday, + l = snprintf(string_data, sizeof(string_data), "%02d/%02d/%4d %02d:%02d:%02d", t.tm_mon+1, t.tm_mday, t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec); break; case SQL_TYPE_DATE: - l = sprintf(string_data, "%02d/%02d/%4d", t.tm_mon + 1, t.tm_mday, t.tm_year+1900); + l = snprintf(string_data, sizeof(string_data), "%02d/%02d/%4d", t.tm_mon + 1, t.tm_mday, t.tm_year+1900); break; case SQL_TYPE_TIME: - l = sprintf(string_data, "%02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec); + l = snprintf(string_data, sizeof(string_data), "%02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec); break; } #endif @@ -1520,7 +1520,7 @@ Z_ARRVAL_P(return_value),alias,strlen(alias)+1,&p)) { case '\0': - sprintf(alias = buf, "%s_%02d", base, i++); + snprintf(alias = buf, sizeof(buf), "%s_%02d", base, i++); } } } http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_service.c?r1=1.15&r2=1.16&diff_format=u Index: php-src/ext/interbase/ibase_service.c diff -u php-src/ext/interbase/ibase_service.c:1.15 php-src/ext/interbase/ibase_service.c:1.16 --- php-src/ext/interbase/ibase_service.c:1.15 Mon Jan 22 09:05:19 2007 +++ php-src/ext/interbase/ibase_service.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ibase_service.c,v 1.15 2007/01/22 09:05:19 tony2001 Exp $ */ +/* $Id: ibase_service.c,v 1.16 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -322,7 +322,7 @@ heap_p = heap_buf + res_size; } result += 2; - sprintf(heap_p, "%s\n", result); + snprintf(heap_p, sizeof(heap_buf_size), "%s\n", result); heap_p += line_len +2; goto query_loop; /* repeat until result is exhausted */ http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/interbase.c?r1=1.233&r2=1.234&diff_format=u Index: php-src/ext/interbase/interbase.c diff -u php-src/ext/interbase/interbase.c:1.233 php-src/ext/interbase/interbase.c:1.234 --- php-src/ext/interbase/interbase.c:1.233 Thu Jan 18 15:53:53 2007 +++ php-src/ext/interbase/interbase.c Sat Feb 24 16:25:54 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: interbase.c,v 1.233 2007/01/18 15:53:53 tony2001 Exp $ */ +/* $Id: interbase.c,v 1.234 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -542,7 +542,7 @@ #endif #ifdef FB_API_VER - sprintf( (s = tmp), "Firebird API version %d", FB_API_VER); + snprintf( (s = tmp), sizeof(tmp), "Firebird API version %d", FB_API_VER); #elif (SQLDA_CURRENT_VERSION > 1) s = "Interbase 7.0 and up"; #elif !defined(DSC_null) @@ -607,7 +607,7 @@ buf_len -= dpb_len; } if (largs[SYNC] && buf_len > 0) { - dpb_len = sprintf(dpb, buf_len, "%c\1%c", isc_dpb_force_write, largs[SYNC] == isc_spb_prp_wm_sync ? 1 : 0); + dpb_len = snprintf(dpb, buf_len, "%c\1%c", isc_dpb_force_write, largs[SYNC] == isc_spb_prp_wm_sync ? 1 : 0); dpb += dpb_len; buf_len -= dpb_len; } @@ -1170,7 +1170,7 @@ PHP_IBASE_LINK_TRANS(link, ib_link, trans); - sprintf(query, "SELECT GEN_ID(%s,%ld) FROM rdb$database", generator, inc); + snprintf(query, sizeof(query), "SELECT GEN_ID(%s,%ld) FROM rdb$database", generator, inc); /* allocate a minimal descriptor area */ out_sqlda.sqln = out_sqlda.sqld = 1; @@ -1192,10 +1192,11 @@ /* don't return the generator value as a string unless it doesn't fit in a long */ #if SIZEOF_LONG < 8 if (result < LONG_MIN || result > LONG_MAX) { - char res[24]; + char *res; + int l - sprintf(res, "%" LL_MASK "d", result); - RETURN_STRING(res,1); + l = spprintf(&res, 0, "%" LL_MASK "d", result); + RETURN_STRINGL(res, l, 0); } #endif RETURN_LONG((long)result); http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.266&r2=1.267&diff_format=u Index: php-src/ext/mbstring/mbstring.c diff -u php-src/ext/mbstring/mbstring.c:1.266 php-src/ext/mbstring/mbstring.c:1.267 --- php-src/ext/mbstring/mbstring.c:1.266 Fri Jan 12 12:06:33 2007 +++ php-src/ext/mbstring/mbstring.c Sat Feb 24 16:25:54 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.266 2007/01/12 12:06:33 tony2001 Exp $ */ +/* $Id: mbstring.c,v 1.267 2007/02/24 16:25:54 helly Exp $ */ /* * PHP 4 Multibyte String module "mbstring" @@ -1052,7 +1052,7 @@ { char buf[32]; php_info_print_table_row(2, "Multibyte (japanese) regex support", "enabled"); - sprintf(buf, "%d.%d.%d", + snprintf(buf, sizeof(buf), "%d.%d.%d", ONIGURUMA_VERSION_MAJOR,ONIGURUMA_VERSION_MINOR,ONIGURUMA_VERSION_TEENY); php_info_print_table_row(2, "Multibyte regex (oniguruma) version", buf); } http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/oniguruma/regposerr.c?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/mbstring/oniguruma/regposerr.c diff -u php-src/ext/mbstring/oniguruma/regposerr.c:1.3 php-src/ext/mbstring/oniguruma/regposerr.c:1.4 --- php-src/ext/mbstring/oniguruma/regposerr.c:1.3 Sun Feb 20 22:18:08 2005 +++ php-src/ext/mbstring/oniguruma/regposerr.c Sat Feb 24 16:25:54 2007 @@ -76,7 +76,7 @@ s = ""; } else { - sprintf(tbuf, "undefined error code (%d)", posix_ecode); + snprintf(tbuf, sizeof(tbuf), "undefined error code (%d)", posix_ecode); s = tbuf; } http://cvs.php.net/viewvc.cgi/php-src/ext/msql/php_msql.c?r1=1.66&r2=1.67&diff_format=u Index: php-src/ext/msql/php_msql.c diff -u php-src/ext/msql/php_msql.c:1.66 php-src/ext/msql/php_msql.c:1.67 --- php-src/ext/msql/php_msql.c:1.66 Mon Jan 1 09:29:25 2007 +++ php-src/ext/msql/php_msql.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_msql.c,v 1.66 2007/01/01 09:29:25 sebastian Exp $ */ +/* $Id: php_msql.c,v 1.67 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -250,9 +250,7 @@ } convert_to_string(yyhost); host = Z_STRVAL_P(yyhost); - hashed_details_length = Z_STRLEN_P(yyhost)+4+1; - hashed_details = emalloc(hashed_details_length+1); - sprintf(hashed_details,"msql_%s",Z_STRVAL_P(yyhost)); /* SAFE */ + hashed_details_length = spprintf(&hashed_details, 0, "msql_%s",Z_STRVAL_P(yyhost)); } break; default: http://cvs.php.net/viewvc.cgi/php-src/ext/mssql/php_mssql.c?r1=1.168&r2=1.169&diff_format=u Index: php-src/ext/mssql/php_mssql.c diff -u php-src/ext/mssql/php_mssql.c:1.168 php-src/ext/mssql/php_mssql.c:1.169 --- php-src/ext/mssql/php_mssql.c:1.168 Sun Feb 4 21:24:28 2007 +++ php-src/ext/mssql/php_mssql.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mssql.c,v 1.168 2007/02/04 21:24:28 fmk Exp $ */ +/* $Id: php_mssql.c,v 1.169 2007/02/24 16:25:54 helly Exp $ */ #ifdef COMPILE_DL_MSSQL #define HAVE_MSSQL 1 @@ -373,9 +373,9 @@ php_info_print_table_start(); php_info_print_table_header(2, "MSSQL Support", "enabled"); - sprintf(buf, "%ld", MS_SQL_G(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", MS_SQL_G(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", MS_SQL_G(num_links)); + snprintf(buf, sizeof(buf), "%ld", MS_SQL_G(num_links)); php_info_print_table_row(2, "Active Links", buf); php_info_print_table_row(2, "Library version", MSSQL_VERSION); @@ -391,7 +391,7 @@ char *hashed_details; int hashed_details_length, new_link = 0; mssql_link mssql, *mssql_ptr; - char buffer[32]; + char buffer[40]; switch(ZEND_NUM_ARGS()) { case 0: /* defaults */ @@ -409,9 +409,7 @@ convert_to_string_ex(yyhost); host = Z_STRVAL_PP(yyhost); user=passwd=NULL; - hashed_details_length = Z_STRLEN_PP(yyhost)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details,"mssql_%s__",Z_STRVAL_PP(yyhost)); + hashed_details_length = spprintf(&hashed_details, 0, "mssql_%s__", Z_STRVAL_PP(yyhost)); } break; case 2: { @@ -425,9 +423,7 @@ host = Z_STRVAL_PP(yyhost); user = Z_STRVAL_PP(yyuser); passwd=NULL; - hashed_details_length = Z_STRLEN_PP(yyhost)+Z_STRLEN_PP(yyuser)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details,"mssql_%s_%s_",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser)); + hashed_details_length = spprintf(&hashed_details, 0, "mssql_%s_%s_",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser)); } break; case 3: { @@ -442,9 +438,7 @@ host = Z_STRVAL_PP(yyhost); user = Z_STRVAL_PP(yyuser); passwd = Z_STRVAL_PP(yypasswd); - hashed_details_length = Z_STRLEN_PP(yyhost)+Z_STRLEN_PP(yyuser)+Z_STRLEN_PP(yypasswd)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); /* SAFE */ + hashed_details_length = spprintf(&hashed_details,0,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); } break; case 4: { @@ -461,9 +455,7 @@ user = Z_STRVAL_PP(yyuser); passwd = Z_STRVAL_PP(yypasswd); new_link = Z_LVAL_PP(yynew_link); - hashed_details_length = Z_STRLEN_PP(yyhost)+Z_STRLEN_PP(yyuser)+Z_STRLEN_PP(yypasswd)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); /* SAFE */ + hashed_details_length = spprintf(&hashed_details,0,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); } break; default: @@ -554,7 +546,7 @@ #ifndef HAVE_FREETDS if (MS_SQL_G(textlimit) != -1) { - sprintf(buffer, "%li", MS_SQL_G(textlimit)); + snprintf(buffer, sizeof(buffer), "%li", MS_SQL_G(textlimit)); if (DBSETOPT(mssql.link, DBTEXTLIMIT, buffer)==FAIL) { efree(hashed_details); dbfreelogin(mssql.login); @@ -564,7 +556,7 @@ } #endif if (MS_SQL_G(textsize) != -1) { - sprintf(buffer, "SET TEXTSIZE %li", MS_SQL_G(textsize)); + snprintf(buffer, sizeof(buffer), "SET TEXTSIZE %li", MS_SQL_G(textsize)); dbcmd(mssql.link, buffer); dbsqlexec(mssql.link); dbresults(mssql.link); @@ -681,7 +673,7 @@ #ifndef HAVE_FREETDS if (MS_SQL_G(textlimit) != -1) { - sprintf(buffer, "%li", MS_SQL_G(textlimit)); + snprintf(buffer, sizeof(buffer), "%li", MS_SQL_G(textlimit)); if (DBSETOPT(mssql.link, DBTEXTLIMIT, buffer)==FAIL) { efree(hashed_details); dbfreelogin(mssql.login); @@ -691,7 +683,7 @@ } #endif if (MS_SQL_G(textsize) != -1) { - sprintf(buffer, "SET TEXTSIZE %li", MS_SQL_G(textsize)); + snprintf(buffer, sizeof(buffer), "SET TEXTSIZE %li", MS_SQL_G(textsize)); dbcmd(mssql.link, buffer); dbsqlexec(mssql.link); dbresults(mssql.link); @@ -929,8 +921,7 @@ } res_length = 19; - res_buf = (unsigned char *) emalloc(res_length+1); - sprintf(res_buf, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second); + spprintf(&res_buf, 0, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second); } ZVAL_STRINGL(result, res_buf, res_length, 0); @@ -999,8 +990,7 @@ } res_length = 19; - res_buf = (unsigned char *) emalloc(res_length+1); - sprintf(res_buf, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second); + spprintf(&res_buf, 0, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second); } ZVAL_STRINGL(result, res_buf, res_length, 0); http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/php_mysql.c?r1=1.230&r2=1.231&diff_format=u Index: php-src/ext/mysql/php_mysql.c diff -u php-src/ext/mysql/php_mysql.c:1.230 php-src/ext/mysql/php_mysql.c:1.231 --- php-src/ext/mysql/php_mysql.c:1.230 Mon Jan 1 09:29:25 2007 +++ php-src/ext/mysql/php_mysql.c Sat Feb 24 16:25:54 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mysql.c,v 1.230 2007/01/01 09:29:25 sebastian Exp $ */ +/* $Id: php_mysql.c,v 1.231 2007/02/24 16:25:54 helly Exp $ */ /* TODO: * @@ -441,9 +441,9 @@ php_info_print_table_start(); php_info_print_table_header(2, "MySQL Support", "enabled"); - sprintf(buf, "%ld", MySG(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", MySG(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", MySG(num_links)); + snprintf(buf, sizeof(buf), "%ld", MySG(num_links)); php_info_print_table_row(2, "Active Links", buf); php_info_print_table_row(2, "Client API version", mysql_get_client_info()); #if !defined (PHP_WIN32) && !defined (NETWARE) @@ -513,9 +513,7 @@ } host_and_port=passwd=NULL; user=php_get_current_user(); - hashed_details_length = strlen(user)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details, "mysql__%s_", user); + hashed_details_length = spprintf(&hashed_details, 0, "mysql__%s_", user); client_flags = CLIENT_INTERACTIVE; } else { host_and_port = MySG(default_host); @@ -538,9 +536,7 @@ client_flags ^= CLIENT_LOCAL_FILES; } - hashed_details_length = sizeof("mysql___")-1 + strlen(SAFE_STRING(host_and_port))+strlen(SAFE_STRING(user))+strlen(SAFE_STRING(passwd)); - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details, "mysql_%s_%s_%s", SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd)); + hashed_details_length = spprintf(&hashed_details, 0, "mysql_%s_%s_%s", SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd)); } /* We cannot use mysql_port anymore in windows, need to use @@ -1137,8 +1133,8 @@ if (!strncasecmp("select", query, 6)){ MYSQL_ROW row; - char *newquery = (char *)emalloc(strlen(query) + 10); - sprintf ((char *)newquery, "EXPLAIN %s", query); + char *newquery; + spprintf(&newquery, 0, "EXPLAIN %s", query); mysql_real_query(&mysql->conn, newquery, strlen(newquery)); efree (newquery); if (mysql_errno(&mysql->conn)) { http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli.c?r1=1.102&r2=1.103&diff_format=u Index: php-src/ext/mysqli/mysqli.c diff -u php-src/ext/mysqli/mysqli.c:1.102 php-src/ext/mysqli/mysqli.c:1.103 --- php-src/ext/mysqli/mysqli.c:1.102 Fri Feb 16 18:49:06 2007 +++ php-src/ext/mysqli/mysqli.c Sat Feb 24 16:25:54 2007 @@ -15,7 +15,7 @@ | Author: Georg Richter <georg@php.net> | +----------------------------------------------------------------------+ - $Id: mysqli.c,v 1.102 2007/02/16 18:49:06 stas Exp $ + $Id: mysqli.c,v 1.103 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H @@ -1058,7 +1058,7 @@ mysql->li_stream = php_stream_open_wrapper_ex((char *)filename, "r", 0, NULL, context); if (mysql->li_stream == NULL) { - sprintf((char *)data->error_msg, "Can't find file '%-.64s'.", filename); + snprintf((char *)data->error_msg, sizeof(data->error_msg), "Can't find file '%-.64s'.", filename); return 1; } http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli_api.c?r1=1.143&r2=1.144&diff_format=u Index: php-src/ext/mysqli/mysqli_api.c diff -u php-src/ext/mysqli/mysqli_api.c:1.143 php-src/ext/mysqli/mysqli_api.c:1.144 --- php-src/ext/mysqli/mysqli_api.c:1.143 Fri Jan 12 20:26:35 2007 +++ php-src/ext/mysqli/mysqli_api.c Sat Feb 24 16:25:54 2007 @@ -15,7 +15,7 @@ | Author: Georg Richter <georg@php.net> | +----------------------------------------------------------------------+ - $Id: mysqli_api.c,v 1.143 2007/01/12 20:26:35 andrey Exp $ + $Id: mysqli_api.c,v 1.144 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H @@ -751,7 +751,7 @@ * may be negative. Therefor we cannot use MYSQLI_LLU_SPEC and must * use MYSQLI_LL_SPEC. */ - sprintf((char *)&tmp, (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval); + snprintf(tmp, sizeof(tmp), (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval); ZVAL_UTF8_STRING(stmt->result.vars[i], tmp, ZSTR_DUPLICATE); } else { ZVAL_LONG(stmt->result.vars[i], llval); http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli_prop.c?r1=1.29&r2=1.30&diff_format=u Index: php-src/ext/mysqli/mysqli_prop.c diff -u php-src/ext/mysqli/mysqli_prop.c:1.29 php-src/ext/mysqli/mysqli_prop.c:1.30 --- php-src/ext/mysqli/mysqli_prop.c:1.29 Mon Jan 1 09:29:25 2007 +++ php-src/ext/mysqli/mysqli_prop.c Sat Feb 24 16:25:54 2007 @@ -15,7 +15,7 @@ | Author: Georg Richter <georg@php.net> | +----------------------------------------------------------------------+ - $Id: mysqli_prop.c,v 1.29 2007/01/01 09:29:25 sebastian Exp $ + $Id: mysqli_prop.c,v 1.30 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H @@ -85,9 +85,9 @@ if (l < LONG_MAX) {\ ZVAL_LONG(*retval, l);\ } else { \ - char ret[40]; \ - sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong)l); \ - ZVAL_STRING(*retval, ret, 1); \ + char *ret; \ + int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (my_ulonglong)l); \ + ZVAL_STRINGL(*retval, ret, l, 0); \ } \ }\ return SUCCESS;\ @@ -175,9 +175,9 @@ if (rc < LONG_MAX) { ZVAL_LONG(*retval, rc); } else { - char ret[40]; - sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc); - ZVAL_STRING(*retval, ret, 1); + char *ret; + int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (my_ulonglong) rc); + ZVAL_STRINGL(*retval, ret, l, 0); } } return SUCCESS; @@ -294,9 +294,9 @@ if (rc < LONG_MAX) { ZVAL_LONG(*retval, rc); } else { - char ret[40]; - sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc); - ZVAL_STRING(*retval, ret, 1); + char *ret; + int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (my_ulonglong) rc); + ZVAL_STRINGL(*retval, ret, l, 0); } } return SUCCESS; http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/php_mysqli.h?r1=1.63&r2=1.64&diff_format=u Index: php-src/ext/mysqli/php_mysqli.h diff -u php-src/ext/mysqli/php_mysqli.h:1.63 php-src/ext/mysqli/php_mysqli.h:1.64 --- php-src/ext/mysqli/php_mysqli.h:1.63 Mon Jan 1 09:29:26 2007 +++ php-src/ext/mysqli/php_mysqli.h Sat Feb 24 16:25:54 2007 @@ -15,7 +15,7 @@ | Author: Georg Richter <georg@php.net> | +----------------------------------------------------------------------+ - $Id: php_mysqli.h,v 1.63 2007/01/01 09:29:26 sebastian Exp $ + $Id: php_mysqli.h,v 1.64 2007/02/24 16:25:54 helly Exp $ */ /* A little hack to prevent build break, when mysql is used together with @@ -257,9 +257,9 @@ if ((__val) < LONG_MAX) { \ RETURN_LONG((__val)); \ } else { \ - char ret[40]; \ - sprintf(ret, "%llu", (__val)); \ - RETURN_STRING(ret,1); \ + char *ret; \ + int l = spprintf(&ret, 0, "%llu", (__val)); \ + RETURN_STRINGL(ret, l, 0); \ } \ } http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8.c?r1=1.329&r2=1.330&diff_format=u Index: php-src/ext/oci8/oci8.c diff -u php-src/ext/oci8/oci8.c:1.329 php-src/ext/oci8/oci8.c:1.330 --- php-src/ext/oci8/oci8.c:1.329 Mon Feb 12 09:36:11 2007 +++ php-src/ext/oci8/oci8.c Sat Feb 24 16:25:54 2007 @@ -26,7 +26,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.329 2007/02/12 09:36:11 tony2001 Exp $ */ +/* $Id: oci8.c,v 1.330 2007/02/24 16:25:54 helly Exp $ */ /* TODO * * file://localhost/www/docs/oci10/ociaahan.htm#423823 - implement lob_empty() with OCI_ATTR_LOBEMPTY @@ -674,11 +674,11 @@ php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); php_info_print_table_row(2, "Version", "1.2.2"); - php_info_print_table_row(2, "Revision", "$Revision: 1.329 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.330 $"); - sprintf(buf, "%ld", OCI_G(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent)); php_info_print_table_row(2, "Active Persistent Connections", buf); - sprintf(buf, "%ld", OCI_G(num_links)); + snprintf(buf, sizeof(buf), "%ld", OCI_G(num_links)); php_info_print_table_row(2, "Active Connections", buf); #if !defined(PHP_WIN32) && !defined(HAVE_OCI_INSTANT_CLIENT) @@ -687,7 +687,7 @@ php_info_print_table_row(2, "Libraries Used", PHP_OCI8_SHARED_LIBADD ); #else # if defined(HAVE_OCI_INSTANT_CLIENT) && defined(OCI_MAJOR_VERSION) && defined(OCI_MINOR_VERSION) - sprintf(buf, "%d.%d", OCI_MAJOR_VERSION, OCI_MINOR_VERSION); + snprintf(buf, sizeof(buf), "%d.%d", OCI_MAJOR_VERSION, OCI_MINOR_VERSION); php_info_print_table_row(2, "Oracle Instant Client Version", buf); # endif #endif http://cvs.php.net/viewvc.cgi/php-src/ext/odbc/php_odbc.c?r1=1.200&r2=1.201&diff_format=u Index: php-src/ext/odbc/php_odbc.c diff -u php-src/ext/odbc/php_odbc.c:1.200 php-src/ext/odbc/php_odbc.c:1.201 --- php-src/ext/odbc/php_odbc.c:1.200 Mon Feb 19 20:22:29 2007 +++ php-src/ext/odbc/php_odbc.c Sat Feb 24 16:25:54 2007 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_odbc.c,v 1.200 2007/02/19 20:22:29 tony2001 Exp $ */ +/* $Id: php_odbc.c,v 1.201 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -544,9 +544,9 @@ php_info_print_table_start(); php_info_print_table_header(2, "ODBC Support", "enabled"); - sprintf(buf, "%ld", ODBCG(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", ODBCG(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", ODBCG(num_links)); + snprintf(buf, sizeof(buf), "%ld", ODBCG(num_links)); php_info_print_table_row(2, "Active Links", buf); php_info_print_table_row(2, "ODBC library", PHP_ODBC_TYPE); #ifndef PHP_WIN32 @@ -588,8 +588,8 @@ */ rc = SQLError(henv, conn, stmt, state, &error, errormsg, sizeof(errormsg)-1, &errormsgsize); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - sprintf(state, "HY000"); - sprintf(errormsg, "Failed to fetch error message"); + snprintf(state, sizeof(state), "HY000"); + snprintf(errormsg, sizeof(errormsg), "Failed to fetch error message"); } if (conn_resource) { memcpy(conn_resource->laststate, state, sizeof(state)); @@ -1155,7 +1155,7 @@ result->stmt, state, &error, errormsg, sizeof(errormsg)-1, &errormsgsize); if (!strncmp(state,"S1015",5)) { - sprintf(cursorname,"php_curs_%d", (int)result->stmt); + snprintf(cursorname, max_len+1, "php_curs_%d", (int)result->stmt); if (SQLSetCursorName(result->stmt,cursorname,SQL_NTS) != SQL_SUCCESS) { odbc_sql_error(result->conn_ptr, result->stmt, "SQLSetCursorName"); RETVAL_FALSE; @@ -2148,8 +2148,7 @@ if (strstr((char*)db, ";")) { direct = 1; if (uid && !strstr ((char*)db, "uid") && !strstr((char*)db, "UID")) { - ldb = (char*) emalloc(strlen(db) + strlen(uid) + strlen(pwd) + 12); - sprintf(ldb, "%s;UID=%s;PWD=%s", db, uid, pwd); + spprintf(&ldb, 0, "%s;UID=%s;PWD=%s", db, uid, pwd); } else { ldb_len = strlen(db)+1; ldb = (char*) emalloc(ldb_len); http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.133&r2=1.134&diff_format=u Index: php-src/ext/openssl/openssl.c diff -u php-src/ext/openssl/openssl.c:1.133 php-src/ext/openssl/openssl.c:1.134 --- php-src/ext/openssl/openssl.c:1.133 Fri Jan 19 19:23:20 2007 +++ php-src/ext/openssl/openssl.c Sat Feb 24 16:25:54 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: openssl.c,v 1.133 2007/01/19 19:23:20 rrichards Exp $ */ +/* $Id: openssl.c,v 1.134 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -302,7 +302,7 @@ /* This is how the time string is formatted: - sprintf(p,"%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100, + snprintf(p, sizeof(p), "%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100, ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); */ http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/pcrelib/pcregrep.c?r1=1.13&r2=1.14&diff_format=u Index: php-src/ext/pcre/pcrelib/pcregrep.c diff -u php-src/ext/pcre/pcrelib/pcregrep.c:1.13 php-src/ext/pcre/pcrelib/pcregrep.c:1.14 --- php-src/ext/pcre/pcrelib/pcregrep.c:1.13 Fri Feb 9 20:13:17 2007 +++ php-src/ext/pcre/pcrelib/pcregrep.c Sat Feb 24 16:25:54 2007 @@ -1188,8 +1188,7 @@ while ((nextfile = readdirectory(dir)) != NULL) { int frc, blen; - sprintf(buffer, "%.512s%c%.128s", pathname, sep, nextfile); - blen = strlen(buffer); + blen = snprintf(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) @@ -1281,7 +1280,7 @@ { int n; char s[4]; - if (op->one_char > 0) sprintf(s, "-%c,", op->one_char); else strcpy(s, " "); + if (op->one_char > 0) snprintf(s, sizeof(s), "-%c,", op->one_char); else strcpy(s, " "); printf(" %s --%s%n", s, op->long_name, &n); n = 30 - n; if (n < 1) n = 1; @@ -1355,7 +1354,7 @@ { static char buffer[8]; char *p = buffer; -sprintf(p, "%d", n); +snprintf(p, sizeof(buffer), "%d", n); while (*p != 0) p++; switch (n%10) { @@ -1401,7 +1400,7 @@ return FALSE; } -sprintf(buffer, "%s%.*s%s", prefix[process_options], MBUFTHIRD, pattern, +snprintf(buffer, sizeof(buffer), "%s%.*s%s", prefix[process_options], MBUFTHIRD, pattern, suffix[process_options]); pattern_list[pattern_count] = pcre_compile(buffer, options, &error, &errptr, pcretables); @@ -1463,7 +1462,7 @@ char *p = end_of_line(pattern, eop, &ellength); if (ellength == 0) return compile_single_pattern(pattern, options, filename, count); - sprintf(buffer, "%.*s", p - pattern - ellength, pattern); + snprintf(buffer, sizeof(buffer), "%.*s", p - pattern - ellength, pattern); pattern = p; if (!compile_single_pattern(buffer, options, filename, count)) return FALSE; @@ -1579,8 +1578,8 @@ char buff1[24]; char buff2[24]; int baselen = opbra - op->long_name; - sprintf(buff1, "%.*s", baselen, op->long_name); - sprintf(buff2, "%s%.*s", buff1, strlen(op->long_name) - baselen - 2, + snprintf(buff1, sizeof(buff1), "%.*s", baselen, op->long_name); + snprintf(buff2, sizeof(buff2), "%s%.*s", buff1, strlen(op->long_name) - baselen - 2, opbra + 1); if (strcmp(arg, buff1) == 0 || strcmp(arg, buff2) == 0) break; @@ -1935,7 +1934,7 @@ if (error != NULL) { char s[16]; - if (pattern_count == 1) s[0] = 0; else sprintf(s, " number %d", j); + if (pattern_count == 1) s[0] = 0; else snprintf(s, sizeof(s), " number %d", j); fprintf(stderr, "pcregrep: Error while studying regex%s: %s\n", s, error); return 2; } http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/pcrelib/pcreposix.c?r1=1.19&r2=1.20&diff_format=u Index: php-src/ext/pcre/pcrelib/pcreposix.c diff -u php-src/ext/pcre/pcrelib/pcreposix.c:1.19 php-src/ext/pcre/pcrelib/pcreposix.c:1.20 --- php-src/ext/pcre/pcrelib/pcreposix.c:1.19 Fri Feb 9 20:13:17 2007 +++ php-src/ext/pcre/pcrelib/pcreposix.c Sat Feb 24 16:25:54 2007 @@ -158,7 +158,7 @@ if (errbuf_size > 0) { if (addlength > 0 && errbuf_size >= length + addlength) - sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset); + snprintf(errbuf, errbuf_size, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset); else { strncpy(errbuf, message, errbuf_size - 1); http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_firebird/firebird_statement.c?r1=1.20&r2=1.21&diff_format=u Index: php-src/ext/pdo_firebird/firebird_statement.c diff -u php-src/ext/pdo_firebird/firebird_statement.c:1.20 php-src/ext/pdo_firebird/firebird_statement.c:1.21 --- php-src/ext/pdo_firebird/firebird_statement.c:1.20 Mon Jan 1 09:29:27 2007 +++ php-src/ext/pdo_firebird/firebird_statement.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: firebird_statement.c,v 1.20 2007/01/01 09:29:27 sebastian Exp $ */ +/* $Id: firebird_statement.c,v 1.21 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -211,6 +211,8 @@ #define FETCH_BUF(buf,type,len,lenvar) ((buf) = (buf) ? (buf) : \ emalloc((len) ? (len * sizeof(type)) : ((*(unsigned long*)lenvar) = sizeof(type)))) +#define CHAR_BUF_LEN 24 + /* fetch a blob into a fetch buffer */ static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */ unsigned long *len, ISC_QUAD *blob_id TSRMLS_DC) @@ -322,16 +324,16 @@ n = *(ISC_INT64*)var->sqldata; } - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); if (n >= 0) { - *len = sprintf(*ptr, "%" LL_MASK "d.%0*" LL_MASK "d", + *len = snprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -var->sqlscale, n % f); } else if (n < -f) { - *len = sprintf(*ptr, "%" LL_MASK "d.%0*" LL_MASK "d", + *len = snprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -var->sqlscale, -n % f); } else { - *len = sprintf(*ptr, "-0.%0*" LL_MASK "d", -var->sqlscale, -n % f); + *len = snprintf(*ptr, CHAR_BUF_LEN, "-0.%0*" LL_MASK "d", -var->sqlscale, -n % f); } } else { switch (var->sqltype & ~1) { @@ -353,24 +355,24 @@ break; /* --- cut here --- */ case SQL_SHORT: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%d", *(short*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%d", *(short*)var->sqldata); break; case SQL_LONG: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%ld", *(ISC_LONG*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%ld", *(ISC_LONG*)var->sqldata); break; case SQL_INT64: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%" LL_MASK "d", *(ISC_INT64*)var->sqldata); break; case SQL_FLOAT: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%f", *(float*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%f", *(float*)var->sqldata); break; case SQL_DOUBLE: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%f" , *(double*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%f" , *(double*)var->sqldata); break; /* --- cut here --- */ #if abies_0 @@ -391,8 +393,8 @@ #if SIZEOF_LONG == 8 *ptr = var->sqldata; #else - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 20, NULL); - *len = sprintf(*ptr, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata); #endif break; case SQL_FLOAT: http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_odbc/odbc_driver.c?r1=1.30&r2=1.31&diff_format=u Index: php-src/ext/pdo_odbc/odbc_driver.c diff -u php-src/ext/pdo_odbc/odbc_driver.c:1.30 php-src/ext/pdo_odbc/odbc_driver.c:1.31 --- php-src/ext/pdo_odbc/odbc_driver.c:1.30 Mon Jan 1 09:29:28 2007 +++ php-src/ext/pdo_odbc/odbc_driver.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: odbc_driver.c,v 1.30 2007/01/01 09:29:28 sebastian Exp $ */ +/* $Id: odbc_driver.c,v 1.31 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -387,8 +387,8 @@ /* Force UID and PWD to be set in the DSN */ if (dbh->username && *dbh->username && !strstr(dbh->data_source, "uid") && !strstr(dbh->data_source, "UID")) { - char *dsn = pemalloc(strlen(dbh->data_source) + strlen(dbh->username) + strlen(dbh->password) + sizeof(";UID=;PWD="), dbh->is_persistent); - sprintf(dsn, "%s;UID=%s;PWD=%s", dbh->data_source, dbh->username, dbh->password); + char *dsn; + spprintf(&dsn, 0, "%s;UID=%s;PWD=%s", dbh->data_source, dbh->username, dbh->password); pefree((char*)dbh->data_source, dbh->is_persistent); dbh->data_source = dsn; } http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.365&r2=1.366&diff_format=u Index: php-src/ext/pgsql/pgsql.c diff -u php-src/ext/pgsql/pgsql.c:1.365 php-src/ext/pgsql/pgsql.c:1.366 --- php-src/ext/pgsql/pgsql.c:1.365 Thu Jan 11 16:45:27 2007 +++ php-src/ext/pgsql/pgsql.c Sat Feb 24 16:25:54 2007 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.365 2007/01/11 16:45:27 tony2001 Exp $ */ +/* $Id: pgsql.c,v 1.366 2007/02/24 16:25:54 helly Exp $ */ #include <stdlib.h> @@ -599,9 +599,9 @@ php_info_print_table_row(2, "SSL support", "disabled"); #endif #endif /* HAVE_PG_CONFIG_H */ - sprintf(buf, "%ld", PGG(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", PGG(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", PGG(num_links)); + snprintf(buf, sizeof(buf), "%ld", PGG(num_links)); php_info_print_table_row(2, "Active Links", buf); php_info_print_table_end(); http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/pspell.c?r1=1.57&r2=1.58&diff_format=u Index: php-src/ext/pspell/pspell.c diff -u php-src/ext/pspell/pspell.c:1.57 php-src/ext/pspell/pspell.c:1.58 --- php-src/ext/pspell/pspell.c:1.57 Sat Feb 17 01:47:26 2007 +++ php-src/ext/pspell/pspell.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pspell.c,v 1.57 2007/02/17 01:47:26 stas Exp $ */ +/* $Id: pspell.c,v 1.58 2007/02/24 16:25:55 helly Exp $ */ #define IS_EXT_MODULE @@ -778,7 +778,7 @@ convert_to_long_ex(pignore); ignore = Z_LVAL_PP(pignore); - sprintf(ignore_str, "%ld", ignore); + snprintf(ignore_str, sizeof(ignore_str), "%ld", ignore); pspell_config_replace(config, "ignore", ignore_str); RETURN_TRUE; http://cvs.php.net/viewvc.cgi/php-src/ext/session/mod_mm.c?r1=1.49&r2=1.50&diff_format=u Index: php-src/ext/session/mod_mm.c diff -u php-src/ext/session/mod_mm.c:1.49 php-src/ext/session/mod_mm.c:1.50 --- php-src/ext/session/mod_mm.c:1.49 Thu Jan 4 22:04:38 2007 +++ php-src/ext/session/mod_mm.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_mm.c,v 1.49 2007/01/04 22:04:38 pollita Exp $ */ +/* $Id: mod_mm.c,v 1.50 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" @@ -269,7 +269,7 @@ return FAILURE; } - if (!sprintf(euid,"%d", geteuid())) { + if (!snprintf(euid, sizeof(euid), "%d", geteuid())) { return FAILURE; } http://cvs.php.net/viewvc.cgi/php-src/ext/session/session.c?r1=1.465&r2=1.466&diff_format=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.465 php-src/ext/session/session.c:1.466 --- php-src/ext/session/session.c:1.465 Fri Jan 5 14:53:30 2007 +++ php-src/ext/session/session.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: session.c,v 1.465 2007/01/05 14:53:30 sebastian Exp $ */ +/* $Id: session.c,v 1.466 2007/02/24 16:25:55 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -287,10 +287,8 @@ remote_addr = Z_STRVAL_PP(token); } - buf = emalloc(PS_ID_INITIAL_SIZE); - /* maximum 15+19+19+10 bytes */ - sprintf(buf, "%.15s%ld%ld%0.8F", remote_addr ? remote_addr : "", + spprintf(&buf, 0, "%.15s%ld%ld%0.8F", remote_addr ? remote_addr : "", tv.tv_sec, (long int)tv.tv_usec, php_combined_lcg(TSRMLS_C) * 10); switch (PS(hash_func)) { @@ -936,7 +934,7 @@ php_gmtime_r(when, &tm); - n = sprintf(buf, "%s, %02d %s %d %02d:%02d:%02d GMT", /* SAFE */ + n = snprintf(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, @@ -977,7 +975,7 @@ strcpy_gmt(buf + sizeof(EXPIRES) - 1, &now); ADD_HEADER(buf); - sprintf(buf, "Cache-Control: public, max-age=%ld", PS(cache_expire) * 60); /* SAFE */ + snprintf(buf, sizeof(buf) , "Cache-Control: public, max-age=%ld", PS(cache_expire) * 60); /* SAFE */ ADD_HEADER(buf); last_modified(TSRMLS_C); @@ -987,7 +985,7 @@ { char buf[MAX_STR + 1]; - sprintf(buf, "Cache-Control: private, max-age=%ld, pre-check=%ld", PS(cache_expire) * 60, PS(cache_expire) * 60); /* SAFE */ + snprintf(buf, sizeof(buf), "Cache-Control: private, max-age=%ld, pre-check=%ld", PS(cache_expire) * 60, PS(cache_expire) * 60); /* SAFE */ ADD_HEADER(buf); last_modified(TSRMLS_C); http://cvs.php.net/viewvc.cgi/php-src/ext/skeleton/skeleton.c?r1=1.37&r2=1.38&diff_format=u Index: php-src/ext/skeleton/skeleton.c diff -u php-src/ext/skeleton/skeleton.c:1.37 php-src/ext/skeleton/skeleton.c:1.38 --- php-src/ext/skeleton/skeleton.c:1.37 Tue Jun 13 13:12:19 2006 +++ php-src/ext/skeleton/skeleton.c Sat Feb 24 16:25:55 2007 @@ -138,14 +138,14 @@ { char *arg = NULL; int arg_len, len; - char string[256]; + char *strg; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { return; } - len = sprintf(string, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "extname", arg); - RETURN_STRINGL(string, len, 1); + len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "extname", arg); + RETURN_STRINGL(strg, len, 0); } /* }}} */ /* The previous line is meant for vim and emacs, so it can correctly fold and http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_encoding.c?r1=1.152&r2=1.153&diff_format=u Index: php-src/ext/soap/php_encoding.c diff -u php-src/ext/soap/php_encoding.c:1.152 php-src/ext/soap/php_encoding.c:1.153 --- php-src/ext/soap/php_encoding.c:1.152 Thu Feb 15 14:49:13 2007 +++ php-src/ext/soap/php_encoding.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ | Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_encoding.c,v 1.152 2007/02/15 14:49:13 dmitry Exp $ */ +/* $Id: php_encoding.c,v 1.153 2007/02/24 16:25:55 helly Exp $ */ #include <time.h> @@ -904,7 +904,7 @@ if (Z_TYPE_P(data) == IS_DOUBLE) { char s[256]; - sprintf(s, "%0.0f",floor(Z_DVAL_P(data))); + snprintf(s, sizeof(s), "%0.0f",floor(Z_DVAL_P(data))); xmlNodeSetContent(ret, BAD_CAST(s)); } else { zval tmp = *data; @@ -2660,12 +2660,12 @@ /* Time zone support */ #ifdef HAVE_TM_GMTOFF - sprintf(tzbuf, "%c%02d:%02d", (ta->tm_gmtoff < 0) ? '-' : '+', abs(ta->tm_gmtoff / 3600), abs( (ta->tm_gmtoff % 3600) / 60 )); + snprintf(tzbuf, sizeof(tzbuf), "%c%02d:%02d", (ta->tm_gmtoff < 0) ? '-' : '+', abs(ta->tm_gmtoff / 3600), abs( (ta->tm_gmtoff % 3600) / 60 )); #else # ifdef __CYGWIN__ - sprintf(tzbuf, "%c%02d:%02d", ((ta->tm_isdst ? _timezone - 3600:_timezone)>0)?'-':'+', abs((ta->tm_isdst ? _timezone - 3600 : _timezone) / 3600), abs(((ta->tm_isdst ? _timezone - 3600 : _timezone) % 3600) / 60)); + snprintf(tzbuf, sizeof(tzbuf), "%c%02d:%02d", ((ta->tm_isdst ? _timezone - 3600:_timezone)>0)?'-':'+', abs((ta->tm_isdst ? _timezone - 3600 : _timezone) / 3600), abs(((ta->tm_isdst ? _timezone - 3600 : _timezone) % 3600) / 60)); # else - sprintf(tzbuf, "%c%02d:%02d", ((ta->tm_isdst ? timezone - 3600:timezone)>0)?'-':'+', abs((ta->tm_isdst ? timezone - 3600 : timezone) / 3600), abs(((ta->tm_isdst ? timezone - 3600 : timezone) % 3600) / 60)); + snprintf(tzbuf, sizeof(tzbuf), "%c%02d:%02d", ((ta->tm_isdst ? timezone - 3600:timezone)>0)?'-':'+', abs((ta->tm_isdst ? timezone - 3600 : timezone) / 3600), abs(((ta->tm_isdst ? timezone - 3600 : timezone) % 3600) / 60)); # endif #endif if (strcmp(tzbuf,"+00:00") == 0) { http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_http.c?r1=1.102&r2=1.103&diff_format=u Index: php-src/ext/soap/php_http.c diff -u php-src/ext/soap/php_http.c:1.102 php-src/ext/soap/php_http.c:1.103 --- php-src/ext/soap/php_http.c:1.102 Wed Feb 21 21:11:32 2007 +++ php-src/ext/soap/php_http.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ | Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_http.c,v 1.102 2007/02/21 21:11:32 stas Exp $ */ +/* $Id: php_http.c,v 1.103 2007/02/24 16:25:55 helly Exp $ */ #include "php_soap.h" #include "ext/standard/base64.h" @@ -468,7 +468,7 @@ unsigned int ctx; PHP_MD5Init(&md5ctx); - sprintf(cnonce, "%d", php_rand_r(&ctx)); + snprintf(cnonce, sizeof(cnonce), "%d", php_rand_r(&ctx)); PHP_MD5Update(&md5ctx, (unsigned char*)cnonce, strlen(cnonce)); PHP_MD5Final(hash, &md5ctx); make_digest(cnonce, hash); http://cvs.php.net/viewvc.cgi/php-src/ext/soap/soap.c?r1=1.218&r2=1.219&diff_format=u Index: php-src/ext/soap/soap.c diff -u php-src/ext/soap/soap.c:1.218 php-src/ext/soap/soap.c:1.219 --- php-src/ext/soap/soap.c:1.218 Thu Jan 18 16:20:59 2007 +++ php-src/ext/soap/soap.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ | Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: soap.c,v 1.218 2007/01/18 16:20:59 tony2001 Exp $ */ +/* $Id: soap.c,v 1.219 2007/02/24 16:25:55 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -464,8 +464,7 @@ if (defaultEncoding[i].details.type_str) { if (defaultEncoding[i].details.ns != NULL) { char *ns_type; - ns_type = emalloc(strlen(defaultEncoding[i].details.ns) + strlen(defaultEncoding[i].details.type_str) + 2); - sprintf(ns_type, "%s:%s", defaultEncoding[i].details.ns, defaultEncoding[i].details.type_str); + spprintf(&ns_type, 0, "%s:%s", defaultEncoding[i].details.ns, defaultEncoding[i].details.type_str); zend_hash_add(&defEnc, ns_type, strlen(ns_type) + 1, &enc, sizeof(encodePtr), NULL); efree(ns_type); } else { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dns.c?r1=1.83&r2=1.84&diff_format=u Index: php-src/ext/standard/dns.c diff -u php-src/ext/standard/dns.c:1.83 php-src/ext/standard/dns.c:1.84 --- php-src/ext/standard/dns.c:1.83 Mon Jan 1 09:29:31 2007 +++ php-src/ext/standard/dns.c Sat Feb 24 16:25:55 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dns.c,v 1.83 2007/01/01 09:29:31 sebastian Exp $ */ +/* $Id: dns.c,v 1.84 2007/02/24 16:25:55 helly Exp $ */ /* {{{ includes */ #include "php.h" @@ -409,7 +409,7 @@ switch (type) { case DNS_T_A: add_ascii_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_ascii_assoc_rt_string(*subarray, "ip", name, ZSTR_DUPLICATE); cp += dlen; break; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/head.c?r1=1.94&r2=1.95&diff_format=u Index: php-src/ext/standard/head.c diff -u php-src/ext/standard/head.c:1.94 php-src/ext/standard/head.c:1.95 --- php-src/ext/standard/head.c:1.94 Mon Jan 1 09:29:31 2007 +++ php-src/ext/standard/head.c Sat Feb 24 16:25:55 2007 @@ -15,7 +15,7 @@ | Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: head.c,v 1.94 2007/01/01 09:29:31 sebastian Exp $ */ +/* $Id: head.c,v 1.95 2007/02/24 16:25:55 helly Exp $ */ #include <stdio.h> #include "php.h" @@ -94,8 +94,6 @@ 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 @@ */ 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) { strcat(cookie, "; expires="); 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); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/image.c?r1=1.128&r2=1.129&diff_format=u Index: php-src/ext/standard/image.c diff -u php-src/ext/standard/image.c:1.128 php-src/ext/standard/image.c:1.129 --- php-src/ext/standard/image.c:1.128 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/image.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: image.c,v 1.128 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: image.c,v 1.129 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" #include <stdio.h> @@ -454,7 +454,7 @@ return 0; } - sprintf(markername, "APP%d", marker - M_APP0); + snprintf(markername, sizeof(markername), "APP%d", marker - M_APP0); if (zend_ascii_hash_find(Z_ARRVAL_P(info), markername, strlen(markername)+1, (void **) &tmp) == FAILURE) { /* XXX we onyl catch the 1st tag of it's kind! */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/pack.c?r1=1.65&r2=1.66&diff_format=u Index: php-src/ext/standard/pack.c diff -u php-src/ext/standard/pack.c:1.65 php-src/ext/standard/pack.c:1.66 --- php-src/ext/standard/pack.c:1.65 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/pack.c Sat Feb 24 16:25:55 2007 @@ -15,7 +15,7 @@ | Author: Chris Schneider <cschneid@relog.ch> | +----------------------------------------------------------------------+ */ -/* $Id: pack.c,v 1.65 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: pack.c,v 1.66 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" @@ -622,10 +622,10 @@ 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) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.53&r2=1.54&diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.53 php-src/ext/standard/proc_open.c:1.54 --- php-src/ext/standard/proc_open.c:1.53 Wed Feb 14 19:20:14 2007 +++ php-src/ext/standard/proc_open.c Sat Feb 24 16:25:55 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong <wez@thebrainroom.com> | +----------------------------------------------------------------------+ */ -/* $Id: proc_open.c,v 1.53 2007/02/14 19:20:14 nlopess Exp $ */ +/* $Id: proc_open.c,v 1.54 2007/02/24 16:25:55 helly Exp $ */ #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -740,8 +740,7 @@ 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); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/scanf.c?r1=1.37&r2=1.38&diff_format=u Index: php-src/ext/standard/scanf.c diff -u php-src/ext/standard/scanf.c:1.37 php-src/ext/standard/scanf.c:1.38 --- php-src/ext/standard/scanf.c:1.37 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/scanf.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: scanf.c,v 1.37 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: scanf.c,v 1.38 2007/02/24 16:25:55 helly Exp $ */ /* scanf.c -- @@ -1562,7 +1562,7 @@ *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) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.631&r2=1.632&diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.631 php-src/ext/standard/string.c:1.632 --- php-src/ext/standard/string.c:1.631 Sat Feb 10 00:48:17 2007 +++ php-src/ext/standard/string.c Sat Feb 24 16:25:55 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.631 2007/02/10 00:48:17 tony2001 Exp $ */ +/* $Id: string.c,v 1.632 2007/02/24 16:25:55 helly Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4641,7 +4641,7 @@ 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)); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/type.c?r1=1.49&r2=1.50&diff_format=u Index: php-src/ext/standard/type.c diff -u php-src/ext/standard/type.c:1.49 php-src/ext/standard/type.c:1.50 --- php-src/ext/standard/type.c:1.49 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/type.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: type.c,v 1.49 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: type.c,v 1.50 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" #include "php_incomplete_class.h" @@ -68,8 +68,7 @@ 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); } */ http://cvs.php.net/viewvc.cgi/php-src/ext/sybase_ct/php_sybase_ct.c?r1=1.116&r2=1.117&diff_format=u Index: php-src/ext/sybase_ct/php_sybase_ct.c diff -u php-src/ext/sybase_ct/php_sybase_ct.c:1.116 php-src/ext/sybase_ct/php_sybase_ct.c:1.117 --- php-src/ext/sybase_ct/php_sybase_ct.c:1.116 Mon Jan 1 09:29:32 2007 +++ php-src/ext/sybase_ct/php_sybase_ct.c Sat Feb 24 16:25:55 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_sybase_ct.c,v 1.116 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: php_sybase_ct.c,v 1.117 2007/02/24 16:25:55 helly Exp $ */ #ifdef HAVE_CONFIG_H @@ -1006,8 +1006,7 @@ ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, sybase_link_index, id, "Sybase-Link", le_link, le_plink); convert_to_string_ex(db); - cmdbuf = (char *) emalloc(sizeof("use ")+Z_STRLEN_PP(db)+1); - sprintf(cmdbuf, "use %s", Z_STRVAL_PP(db)); /* SAFE */ + spprintf(&cmdbuf, 0, "use %s", Z_STRVAL_PP(db)); /* SAFE */ if (exec_cmd(sybase_ptr, cmdbuf)==FAILURE) { efree(cmdbuf); @@ -2121,16 +2120,16 @@ php_info_print_table_start(); php_info_print_table_header(2, "Sybase_CT Support", "enabled" ); - sprintf(buf, "%ld", SybCtG(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", SybCtG(num_links)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(num_links)); php_info_print_table_row(2, "Active Links", buf); - sprintf(buf, "%ld", SybCtG(min_server_severity)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(min_server_severity)); php_info_print_table_row(2, "Min server severity", buf); - sprintf(buf, "%ld", SybCtG(min_client_severity)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(min_client_severity)); php_info_print_table_row(2, "Min client severity", buf); php_info_print_table_row(2, "Application Name", SybCtG(appname)); - sprintf(buf, "%ld", SybCtG(deadlock_retry_count)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(deadlock_retry_count)); php_info_print_table_row(2, "Deadlock retry count", buf); php_info_print_table_end(); http://cvs.php.net/viewvc.cgi/php-src/ext/wddx/wddx.c?r1=1.143&r2=1.144&diff_format=u Index: php-src/ext/wddx/wddx.c diff -u php-src/ext/wddx/wddx.c:1.143 php-src/ext/wddx/wddx.c:1.144 --- php-src/ext/wddx/wddx.c:1.143 Thu Jan 18 16:21:00 2007 +++ php-src/ext/wddx/wddx.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: wddx.c,v 1.143 2007/01/18 16:21:00 tony2001 Exp $ */ +/* $Id: wddx.c,v 1.144 2007/02/24 16:25:55 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -285,7 +285,7 @@ switch (hash_type) { case HASH_KEY_IS_LONG: - key_length = sprintf(tmp, "%ld", idx) + 1; + key_length = snprintf(tmp, sizeof(tmp), "%ld", idx) + 1; key = tmp; /* fallthru */ case HASH_KEY_IS_STRING: @@ -410,7 +410,7 @@ { char tmp_buf[WDDX_BUF_LEN]; - sprintf(tmp_buf, WDDX_BOOLEAN, Z_LVAL_P(var) ? "true" : "false"); + snprintf(tmp_buf, sizeof(tmp_buf), WDDX_BOOLEAN, Z_LVAL_P(var) ? "true" : "false"); php_wddx_add_chunk(packet, tmp_buf); } /* }}} */ @@ -502,7 +502,7 @@ 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 = sprintf(tmp_buf, "%ld", idx); + key_len = snprintf(tmp_buf, sizeof(tmp_buf), "%ld", idx); php_wddx_serialize_var(packet, *ent, tmp_buf, key_len TSRMLS_CC); } } @@ -557,7 +557,7 @@ if (is_struct) { php_wddx_add_chunk_static(packet, WDDX_STRUCT_S); } else { - sprintf(tmp_buf, WDDX_ARRAY_S, zend_hash_num_elements(target_hash)); + snprintf(tmp_buf, sizeof(tmp_buf), WDDX_ARRAY_S, zend_hash_num_elements(target_hash)); php_wddx_add_chunk(packet, tmp_buf); } @@ -573,7 +573,7 @@ if (ent_type == HASH_KEY_IS_STRING) { php_wddx_serialize_var(packet, *ent, key, key_len TSRMLS_CC); } else { - key_len = sprintf(tmp_buf, "%ld", idx); + key_len = snprintf(tmp_buf, sizeof(tmp_buf), "%ld", idx); php_wddx_serialize_var(packet, *ent, tmp_buf, key_len TSRMLS_CC); } } else @@ -725,7 +725,7 @@ if (!strcmp(atts[i], EL_CHAR_CODE) && atts[++i] && atts[i][0]) { char tmp_buf[2]; - sprintf(tmp_buf, "%c", (char)strtol(atts[i], NULL, 16)); + snprintf(tmp_buf, sizeof(tmp_buf), "%c", (char)strtol(atts[i], NULL, 16)); php_wddx_process_data(user_data, tmp_buf, strlen(tmp_buf)); break; } http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_close.c?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/zip/lib/zip_close.c diff -u php-src/ext/zip/lib/zip_close.c:1.3 php-src/ext/zip/lib/zip_close.c:1.4 --- php-src/ext/zip/lib/zip_close.c:1.3 Mon Jan 1 09:29:34 2007 +++ php-src/ext/zip/lib/zip_close.c Sat Feb 24 16:25:55 2007 @@ -535,7 +535,7 @@ return NULL; } - sprintf(temp, "%s.XXXXXX", za->zn); + snprintf(temp, sizeof(temp), "%s.XXXXXX", za->zn); if ((tfd=mkstemp(temp)) == -1) { _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_error_strerror.c?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/zip/lib/zip_error_strerror.c diff -u php-src/ext/zip/lib/zip_error_strerror.c:1.2 php-src/ext/zip/lib/zip_error_strerror.c:1.3 --- php-src/ext/zip/lib/zip_error_strerror.c:1.2 Mon Jan 1 09:29:34 2007 +++ php-src/ext/zip/lib/zip_error_strerror.c Sat Feb 24 16:25:55 2007 @@ -54,7 +54,7 @@ _zip_error_fini(err); if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) { - sprintf(buf, "Unknown error %d", err->zip_err); + snprintf(buf, sizeof(buf), "Unknown error %d", err->zip_err); zs = NULL; ss = buf; } @@ -78,11 +78,11 @@ if (ss == NULL) return zs; else { - if ((s=(char *)malloc(strlen(ss) - + (zs ? strlen(zs)+2 : 0) + 1)) == NULL) + int l = strlen(ss) + (zs ? strlen(zs)+2 : 0) + 1; + if ((s=(char *)malloc(l)) == NULL) return _zip_err_str[ZIP_ER_MEMORY]; - sprintf(s, "%s%s%s", + snprintf(s, l, "%s%s%s", (zs ? zs : ""), (zs ? ": " : ""), ss); http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?r1=1.190&r2=1.191&diff_format=u Index: php-src/main/fopen_wrappers.c diff -u php-src/main/fopen_wrappers.c:1.190 php-src/main/fopen_wrappers.c:1.191 --- php-src/main/fopen_wrappers.c:1.190 Fri Jan 12 14:34:46 2007 +++ php-src/main/fopen_wrappers.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c,v 1.190 2007/01/12 14:34:46 bjori Exp $ */ +/* $Id: fopen_wrappers.c,v 1.191 2007/02/24 16:25:55 helly Exp $ */ /* {{{ includes */ @@ -305,13 +305,10 @@ pw = getpwnam(user); #endif if (pw && pw->pw_dir) { - filename = emalloc(strlen(PG(user_dir)) + strlen(path_info) + strlen(pw->pw_dir) + 4); - if (filename) { - sprintf(filename, "%s%c%s%c%s", pw->pw_dir, PHP_DIR_SEPARATOR, + spprintf(&filename, 0, "%s%c%s%c%s", pw->pw_dir, PHP_DIR_SEPARATOR, PG(user_dir), PHP_DIR_SEPARATOR, s+1); /* Safe */ - STR_FREE(SG(request_info).path_translated); - SG(request_info).path_translated = filename; - } + STR_FREE(SG(request_info).path_translated); + SG(request_info).path_translated = filename; } #if defined(ZTS) && defined(HAVE_GETPWNAM_R) && defined(_SC_GETPW_R_SIZE_MAX) efree(pwbuf); http://cvs.php.net/viewvc.cgi/php-src/main/php_ini.c?r1=1.147&r2=1.148&diff_format=u Index: php-src/main/php_ini.c diff -u php-src/main/php_ini.c:1.147 php-src/main/php_ini.c:1.148 --- php-src/main/php_ini.c:1.147 Mon Jan 1 09:29:35 2007 +++ php-src/main/php_ini.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ini.c,v 1.147 2007/01/01 09:29:35 sebastian Exp $ */ +/* $Id: php_ini.c,v 1.148 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" #include "ext/standard/info.h" @@ -438,8 +438,8 @@ /* Search php-%sapi-module-name%.ini file in search path */ if (!fh.handle.fp) { const char *fmt = "php-%s.ini"; - char *ini_fname = emalloc(strlen(fmt) + strlen(sapi_module.name)); - sprintf(ini_fname, fmt, sapi_module.name); + char *ini_fname; + spprintf(&ini_fname, 0, fmt, sapi_module.name); fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); efree(ini_fname); if (fh.handle.fp) { http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.189&r2=1.190&diff_format=u Index: php-src/main/rfc1867.c diff -u php-src/main/rfc1867.c:1.189 php-src/main/rfc1867.c:1.190 --- php-src/main/rfc1867.c:1.189 Mon Jan 1 09:29:35 2007 +++ php-src/main/rfc1867.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: rfc1867.c,v 1.189 2007/01/01 09:29:35 sebastian Exp $ */ +/* $Id: rfc1867.c,v 1.190 2007/02/24 16:25:55 helly Exp $ */ /* * This product includes software developed by the Apache Group @@ -475,12 +475,9 @@ self->buffer = (char *) ecalloc(1, minsize + 1); self->bufsize = minsize; - self->boundary = (char *) ecalloc(1, boundary_len + 3); - sprintf(self->boundary, "--%s", boundary); + spprintf(&self->boundary, 0, "--%s", boundary); - self->boundary_next = (char *) ecalloc(1, boundary_len + 4); - sprintf(self->boundary_next, "\n--%s", boundary); - self->boundary_next_len = boundary_len + 3; + self->boundary_next_len = spprintf(&self->boundary_next, 0, "\n--%s", boundary); self->buf_begin = self->buffer; self->bytes_in_buffer = 0; @@ -1015,6 +1012,7 @@ U_STRING_DECL(filename_key, "filename", 8); U_STRING_DECL(maxfilesize_key, "MAX_FILE_SIZE", 13); static zend_bool did_string_init = FALSE; + int llen = 0; if (SG(request_info).content_length > SG(post_max_size)) { sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size)); @@ -1322,14 +1320,15 @@ if (lbuf) { efree(lbuf); } - lbuf = eumalloc(u_strlen(param) + MAX_SIZE_OF_INDEX + 1); + llen = u_strlen(param) + MAX_SIZE_OF_INDEX + 1; + lbuf = eumalloc(llen); if (is_arr_upload) { if (abuf) efree(abuf); abuf = eustrndup(param, u_strlen(param)-array_len); - u_sprintf(lbuf, "%S_name[%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S_name[%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S_name", param); + u_snprintf(lbuf, llen, "%S_name", param); } /* The \ check should technically be needed for win32 systems only where @@ -1353,9 +1352,9 @@ /* Add $foo[name] */ if (is_arr_upload) { - u_sprintf(lbuf, "%S[name][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[name][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[name]", param); + u_snprintf(lbuf, llen, "%S[name]", param); } if (s && s > filename) { register_u_http_post_files_variable(lbuf, s+1, u_strlen(s+1), http_post_files, 0 TSRMLS_CC); @@ -1383,9 +1382,9 @@ /* Add $foo_type */ if (is_arr_upload) { - u_sprintf(lbuf, "%S_type[%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S_type[%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S_type", param); + u_snprintf(lbuf, llen, "%S_type", param); } if (!is_anonymous) { safe_u_php_register_variable(lbuf, ucd, ucd_len, NULL, 0 TSRMLS_CC); @@ -1393,9 +1392,9 @@ /* Add $foo[type] */ if (is_arr_upload) { - u_sprintf(lbuf, "%S[type][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[type][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[type]", param); + u_snprintf(lbuf, llen, "%S[type]", param); } register_u_http_post_files_variable(lbuf, ucd, ucd_len, http_post_files, 0 TSRMLS_CC); @@ -1417,9 +1416,9 @@ /* Add $foo[tmp_name] */ if (is_arr_upload) { - u_sprintf(lbuf, "%S[tmp_name][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[tmp_name][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[tmp_name]", param); + u_snprintf(lbuf, llen, "%S[tmp_name]", param); } add_u_protected_variable(lbuf TSRMLS_CC); register_u_http_post_files_variable(lbuf, temp_filename, u_strlen(temp_filename), http_post_files, 1 TSRMLS_CC); @@ -1440,17 +1439,17 @@ } if (is_arr_upload) { - u_sprintf(lbuf, "%S[error][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[error][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[error]", param); + u_snprintf(lbuf, llen, "%S[error]", param); } register_u_http_post_files_variable_ex(lbuf, &error_type, http_post_files, 0 TSRMLS_CC); /* Add $foo_size */ if (is_arr_upload) { - u_sprintf(lbuf, "%S_size[%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S_size[%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S_size", param); + u_snprintf(lbuf, llen, "%S_size", param); } if (!is_anonymous) { safe_u_php_register_variable_ex(lbuf, &file_size, NULL, 0 TSRMLS_CC); @@ -1458,9 +1457,9 @@ /* Add $foo[size] */ if (is_arr_upload) { - u_sprintf(lbuf, "%S[size][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[size][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[size]", param); + u_snprintf(lbuf, llen, "%S[size]", param); } register_u_http_post_files_variable_ex(lbuf, &file_size, http_post_files, 0 TSRMLS_CC); } @@ -1487,6 +1486,7 @@ zval *array_ptr = (zval *) arg; int fd=-1; zend_llist header; + int llen = 0; if (SG(request_info).content_length > SG(post_max_size)) { sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size)); @@ -1768,14 +1768,15 @@ if (lbuf) { efree(lbuf); } - lbuf = (char *) emalloc(strlen(param) + MAX_SIZE_OF_INDEX + 1); + llen = strlen(param) + MAX_SIZE_OF_INDEX + 1; + lbuf = (char *) emalloc(llen); if (is_arr_upload) { if (abuf) efree(abuf); abuf = estrndup(param, strlen(param)-array_len); - sprintf(lbuf, "%s_name[%s]", abuf, array_index); + snprintf(lbuf, llen, "%s_name[%s]", abuf, array_index); } else { - sprintf(lbuf, "%s_name", param); + snprintf(lbuf, llen, "%s_name", param); } #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING) @@ -1824,9 +1825,9 @@ /* Add $foo[name] */ if (is_arr_upload) { - sprintf(lbuf, "%s[name][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[name][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[name]", param); + snprintf(lbuf, llen, "%s[name]", param); } if (s && s > filename) { register_http_post_files_variable(lbuf, s+1, http_post_files, 0 TSRMLS_CC); @@ -1849,9 +1850,9 @@ /* Add $foo_type */ if (is_arr_upload) { - sprintf(lbuf, "%s_type[%s]", abuf, array_index); + snprintf(lbuf, llen, "%s_type[%s]", abuf, array_index); } else { - sprintf(lbuf, "%s_type", param); + snprintf(lbuf, llen, "%s_type", param); } if (!is_anonymous) { safe_php_register_variable(lbuf, cd, strlen(cd), NULL, 0 TSRMLS_CC); @@ -1859,9 +1860,9 @@ /* Add $foo[type] */ if (is_arr_upload) { - sprintf(lbuf, "%s[type][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[type][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[type]", param); + snprintf(lbuf, llen, "%s[type]", param); } register_http_post_files_variable(lbuf, cd, http_post_files, 0 TSRMLS_CC); @@ -1881,9 +1882,9 @@ /* Add $foo[tmp_name] */ if (is_arr_upload) { - sprintf(lbuf, "%s[tmp_name][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[tmp_name][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[tmp_name]", param); + snprintf(lbuf, llen, "%s[tmp_name]", param); } add_protected_variable(lbuf TSRMLS_CC); register_http_post_files_variable(lbuf, temp_filename, http_post_files, 1 TSRMLS_CC); @@ -1904,17 +1905,17 @@ } if (is_arr_upload) { - sprintf(lbuf, "%s[error][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[error][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[error]", param); + snprintf(lbuf, llen, "%s[error]", param); } register_http_post_files_variable_ex(lbuf, &error_type, http_post_files, 0 TSRMLS_CC); /* Add $foo_size */ if (is_arr_upload) { - sprintf(lbuf, "%s_size[%s]", abuf, array_index); + snprintf(lbuf, llen, "%s_size[%s]", abuf, array_index); } else { - sprintf(lbuf, "%s_size", param); + snprintf(lbuf, llen, "%s_size", param); } if (!is_anonymous) { safe_php_register_variable_ex(lbuf, &file_size, NULL, 0 TSRMLS_CC); @@ -1922,9 +1923,9 @@ /* Add $foo[size] */ if (is_arr_upload) { - sprintf(lbuf, "%s[size][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[size][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[size]", param); + snprintf(lbuf, llen, "%s[size]", param); } register_http_post_files_variable_ex(lbuf, &file_size, http_post_files, 0 TSRMLS_CC); } http://cvs.php.net/viewvc.cgi/php-src/sapi/nsapi/nsapi.c?r1=1.77&r2=1.78&diff_format=u Index: php-src/sapi/nsapi/nsapi.c diff -u php-src/sapi/nsapi/nsapi.c:1.77 php-src/sapi/nsapi/nsapi.c:1.78 --- php-src/sapi/nsapi/nsapi.c:1.77 Mon Jan 1 09:29:36 2007 +++ php-src/sapi/nsapi/nsapi.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: nsapi.c,v 1.77 2007/01/01 09:29:36 sebastian Exp $ */ +/* $Id: nsapi.c,v 1.78 2007/02/24 16:25:55 helly Exp $ */ /* * PHP includes @@ -310,7 +310,7 @@ PHP_MINFO_FUNCTION(nsapi) { php_info_print_table_start(); - php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.77 $"); + php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.78 $"); php_info_print_table_row(2, "Server Software", system_version()); php_info_print_table_row(2, "Sub-requests with nsapi_virtual()", (nsapi_servact_service)?((zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0))?"not supported with zlib.output_compression":"enabled"):"not supported on this platform" ); @@ -638,7 +638,7 @@ nsapi_free(value); } - sprintf(buf, "%d", conf_getglobals()->Vport); + snprintf(buf, sizeof(buf), "%d", conf_getglobals()->Vport); php_register_variable("SERVER_PORT", buf, track_vars_array TSRMLS_CC); php_register_variable("SERVER_NAME", conf_getglobals()->Vserver_hostname, track_vars_array TSRMLS_CC); @@ -691,7 +691,7 @@ /* special variables in error mode */ if (rc->http_error) { - sprintf(buf, "%d", rc->http_error); + snprintf(buf, sizeof(buf), "%d", rc->http_error); php_register_variable("ERROR_TYPE", buf, track_vars_array TSRMLS_CC); } } http://cvs.php.net/viewvc.cgi/php-src/sapi/tux/php_tux.c?r1=1.28&r2=1.29&diff_format=u Index: php-src/sapi/tux/php_tux.c diff -u php-src/sapi/tux/php_tux.c:1.28 php-src/sapi/tux/php_tux.c:1.29 --- php-src/sapi/tux/php_tux.c:1.28 Mon Jan 1 09:29:37 2007 +++ php-src/sapi/tux/php_tux.c Sat Feb 24 16:25:55 2007 @@ -116,7 +116,7 @@ status_line = malloc(30); /* safe sprintf use */ - len = sprintf(status_line, "HTTP/1.1 %d NA\r\n", SG(sapi_headers).http_response_code); + len = snprintf(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 @@ sapi_header_line ctr = {0}; ctr.line = buf; - ctr.line_len = sprintf(buf, "Server: %s", TUXAPI_version); + ctr.line_len = snprintf(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); @@ -215,7 +215,7 @@ ADD_STRING("REMOTE_HOST"); } - sprintf(buf, "%d", CGI_SERVER_PORT(TG(req))); + snprintf(buf, sizeof(buf), "%d", CGI_SERVER_PORT(TG(req))); ADD_STRING("SERVER_PORT"); #if 0 @@ -241,7 +241,7 @@ #if 0 if (TG(hc)->contentlength != -1) { - sprintf(buf, "%ld", (long) TG(hc)->contentlength); + snprintf(buf, sizeof(buf), "%ld", (long) TG(hc)->contentlength); ADD_STRING("CONTENT_LENGTH"); } #endif http://cvs.php.net/viewvc.cgi/php-src/win32/registry.c?r1=1.18&r2=1.19&diff_format=u Index: php-src/win32/registry.c diff -u php-src/win32/registry.c:1.18 php-src/win32/registry.c:1.19 --- php-src/win32/registry.c:1.18 Fri Nov 10 11:42:40 2006 +++ php-src/win32/registry.c Sat Feb 24 16:25:55 2007 @@ -217,8 +217,7 @@ while (*cwd == '\\' || *cwd == '/') { cwd++; } - path = (char *) emalloc(2+strlen(cwd)+1+strlen(orig_path)+1); - sprintf(path, "%c\\%s\\%s", drive_letter, cwd, orig_path); + spprintf(&path, 0, "%c\\%s\\%s", drive_letter, cwd, orig_path); efree(orig_path); orig_path = path; } http://cvs.php.net/viewvc.cgi/php-src/win32/sendmail.c?r1=1.68&r2=1.69&diff_format=u Index: php-src/win32/sendmail.c diff -u php-src/win32/sendmail.c:1.68 php-src/win32/sendmail.c:1.69 --- php-src/win32/sendmail.c:1.68 Mon Jan 1 09:29:37 2007 +++ php-src/win32/sendmail.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ * */ -/* $Id: sendmail.c,v 1.68 2007/01/01 09:29:37 sebastian Exp $ */ +/* $Id: sendmail.c,v 1.69 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" /*php specific */ #include <stdio.h> @@ -405,7 +405,7 @@ return (BAD_MSG_DESTINATION); */ - sprintf(Buffer, "HELO %s\r\n", LocalHost); + snprintf(Buffer, sizeof(Buffer), "HELO %s\r\n", LocalHost); /* in the beggining of the dialog */ /* attempt reconnect if the first Post fail */ @@ -699,16 +699,13 @@ } } - if (NULL == (header_buffer = ecalloc(1, MAIL_BUFFER_SIZE))) { - efree(headers_lc); - return OUT_OF_MEMORY; - } + header_buffer = ecalloc(1, MAIL_BUFFER_SIZE); if (!xheaders || !strstr(headers_lc, "date:")) { time_t tNow = time(NULL); char *dt = php_format_date("r", 1, tNow, 1 TSRMLS_CC); - sprintf(header_buffer, "Date: %s\r\n", dt); + snprintf(header_buffer, MAIL_BUFFER_SIZE, "Date: %s\r\n", dt); efree(dt); }
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.393&r2=1.394&diff_format=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.393 ZendEngine2/zend.c:1.394 --- ZendEngine2/zend.c:1.393 Fri Jan 19 22:19:08 2007 +++ ZendEngine2/zend.c Sat Feb 24 16:25:53 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.393 2007/01/19 22:19:08 helly Exp $ */ +/* $Id: zend.c,v 1.394 2007/02/24 16:25:53 helly Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -1697,8 +1697,7 @@ cur_lineno = 0; } - compiled_string_description = emalloc(sizeof(COMPILED_STRING_DESCRIPTION_FORMAT)+strlen(name)+strlen(cur_filename)+MAX_LENGTH_OF_LONG); - sprintf(compiled_string_description, COMPILED_STRING_DESCRIPTION_FORMAT, cur_filename, cur_lineno, name); + zend_spprintf(&compiled_string_description, 0, COMPILED_STRING_DESCRIPTION_FORMAT, cur_filename, cur_lineno, name); return compiled_string_description; } http://cvs.php.net/viewvc.cgi/php-src/ext/bcmath/libbcmath/src/output.c?r1=1.5&r2=1.6&diff_format=u Index: php-src/ext/bcmath/libbcmath/src/output.c diff -u php-src/ext/bcmath/libbcmath/src/output.c:1.5 php-src/ext/bcmath/libbcmath/src/output.c:1.6 --- php-src/ext/bcmath/libbcmath/src/output.c:1.5 Fri Nov 22 09:25:29 2002 +++ php-src/ext/bcmath/libbcmath/src/output.c Sat Feb 24 16:25:53 2007 @@ -71,7 +71,7 @@ int len, ix; if (space) (*out_char) (' '); - sprintf (digits, "%ld", val); + snprintf(digits, sizeof(digits), "%ld", val); len = strlen (digits); while (size > len) { http://cvs.php.net/viewvc.cgi/php-src/ext/bcmath/libbcmath/src/rt.c?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/bcmath/libbcmath/src/rt.c diff -u php-src/ext/bcmath/libbcmath/src/rt.c:1.1 php-src/ext/bcmath/libbcmath/src/rt.c:1.2 --- php-src/ext/bcmath/libbcmath/src/rt.c:1.1 Wed Nov 22 20:20:02 2000 +++ php-src/ext/bcmath/libbcmath/src/rt.c Sat Feb 24 16:25:53 2007 @@ -45,7 +45,7 @@ char error_mesg [255]; va_start (args, mesg); - vsprintf (error_mesg, mesg, args); + vsnprintf (error_mesg, sizeof(error_mesg), mesg, args); va_end (args); fprintf (stderr, "bc math warning: %s\n", error_mesg); @@ -58,7 +58,7 @@ char error_mesg [255]; va_start (args, mesg); - vsprintf (error_mesg, mesg, args); + vsnprintf (error_mesg, sizeof(error_mesg), mesg, args); va_end (args); fprintf (stderr, "bc math error: %s\n", error_mesg); http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_wrapper.c?r1=1.13&r2=1.14&diff_format=u Index: php-src/ext/com_dotnet/com_wrapper.c diff -u php-src/ext/com_dotnet/com_wrapper.c:1.13 php-src/ext/com_dotnet/com_wrapper.c:1.14 --- php-src/ext/com_dotnet/com_wrapper.c:1.13 Fri Feb 2 08:42:32 2007 +++ php-src/ext/com_dotnet/com_wrapper.c Sat Feb 24 16:25:53 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: com_wrapper.c,v 1.13 2007/02/02 08:42:32 wharmby Exp $ */ +/* $Id: com_wrapper.c,v 1.14 2007/02/24 16:25:53 helly Exp $ */ /* This module exports a PHP object as a COM object by wrapping it * using IDispatchEx */ @@ -74,7 +74,7 @@ va_list ap; char buf[4096]; - sprintf(buf, "T=%08x ", GetCurrentThreadId()); + snprintf(buf, sizeof(buf), "T=%08x ", GetCurrentThreadId()); OutputDebugString(buf); va_start(ap, fmt); @@ -474,7 +474,7 @@ &namelen, &pid, 0, &pos))) { char namebuf[32]; if (keytype == HASH_KEY_IS_LONG) { - sprintf(namebuf, "%d", pid); + snprintf(namebuf, sizeof(namebuf), "%d", pid); name = namebuf; namelen = strlen(namebuf)+1; } @@ -506,7 +506,7 @@ char namebuf[32]; if (keytype == HASH_KEY_IS_LONG) { - sprintf(namebuf, "%d", pid); + snprintf(namebuf, sizeof(namebuf), "%d", pid); name = namebuf; namelen = strlen(namebuf) + 1; } http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbf_head.c?r1=1.18&r2=1.19&diff_format=u Index: php-src/ext/dbase/dbf_head.c diff -u php-src/ext/dbase/dbf_head.c:1.18 php-src/ext/dbase/dbf_head.c:1.19 --- php-src/ext/dbase/dbf_head.c:1.18 Wed Sep 6 11:34:15 2006 +++ php-src/ext/dbase/dbf_head.c Sat Feb 24 16:25:53 2007 @@ -215,7 +215,7 @@ int fcnt; if ((cp = db_cur_date(NULL))) { - strncpy(dbh->db_date, cp, 8); + strlcpy(dbh->db_date, cp, 8); free(cp); } put_dbf_head(dbh); @@ -232,16 +232,16 @@ /* build the field format for printf */ switch (dbf->db_type) { case 'C': - sprintf(format, "%%-%ds", dbf->db_flen); + snprintf(format, sizeof(format), "%%-%ds", dbf->db_flen); break; case 'N': case 'L': case 'D': case 'F': - sprintf(format, "%%%ds", dbf->db_flen); + snprintf(format, sizeof(format), "%%%ds", dbf->db_flen); break; case 'M': - strcpy(format, "%s"); + strlcpy(format, "%s", sizeof(format)); break; default: return NULL; http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbf_misc.c?r1=1.6&r2=1.7&diff_format=u Index: php-src/ext/dbase/dbf_misc.c diff -u php-src/ext/dbase/dbf_misc.c:1.6 php-src/ext/dbase/dbf_misc.c:1.7 --- php-src/ext/dbase/dbf_misc.c:1.6 Sun Sep 9 13:28:46 2001 +++ php-src/ext/dbase/dbf_misc.c Sat Feb 24 16:25:53 2007 @@ -114,12 +114,7 @@ month = 0; if (day > 31) day = 0; - sprintf(cp, "%d", year); - cp[4] = month / 10 + '0'; - cp[5] = month % 10 + '0'; - cp[6] = day / 10 + '0'; - cp[7] = day % 10 + '0'; - cp[8] = 0; + snprintf(cp, 9, "%04d%02d%02d", year, month, day); } int db_date_year(char *cp) http://cvs.php.net/viewvc.cgi/php-src/ext/exif/exif.c?r1=1.191&r2=1.192&diff_format=u Index: php-src/ext/exif/exif.c diff -u php-src/ext/exif/exif.c:1.191 php-src/ext/exif/exif.c:1.192 --- php-src/ext/exif/exif.c:1.191 Tue Jan 9 17:52:02 2007 +++ php-src/ext/exif/exif.c Sat Feb 24 16:25:53 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: exif.c,v 1.191 2007/01/09 17:52:02 helly Exp $ */ +/* $Id: exif.c,v 1.192 2007/02/24 16:25:53 helly Exp $ */ /* ToDos * @@ -139,7 +139,7 @@ }; /* }}} */ -#define EXIF_VERSION "1.4 $Id: exif.c,v 1.191 2007/01/09 17:52:02 helly Exp $" +#define EXIF_VERSION "1.4 $Id: exif.c,v 1.192 2007/02/24 16:25:53 helly Exp $" /* {{{ PHP_MINFO_FUNCTION */ @@ -1035,22 +1035,22 @@ static unsigned char tmp[20]; int c, i, p=0, n = 5+31; - p += sprintf(buf+p, "\nDump Len: %08X (%d)", len, len); + p += snprintf(buf+p, sizeof(buf)-p, "\nDump Len: %08X (%d)", len, len); if (len) { for(i=0; i<len+15 && p+n<=sizeof(buf); i++) { if (i%16==0) { - p += sprintf(buf+p, "\n%08X: ", i+offset); + p += snprintf(buf+p, sizeof(buf)-p, "\n%08X: ", i+offset); } if (i<len) { c = *addr++; - p += sprintf(buf+p, "%02X ", c); + p += snprintf(buf+p, sizeof(buf)-p, "%02X ", c); tmp[i%16] = c>=32 ? c : '.'; tmp[(i%16)+1] = '\0'; } else { - p += sprintf(buf+p, " "); + p += snprintf(buf+p, sizeof(buf)-p, " "); } if (i%16==15) { - p += sprintf(buf+p, " %s", tmp); + p += snprintf(buf+p, sizeof(buf)-p, " %s", tmp); if (i>=len) { break; } @@ -1181,44 +1181,44 @@ case TAG_FMT_UNDEFINED: case TAG_FMT_STRING: case TAG_FMT_SBYTE: - dump = erealloc(dump, len + 4); - sprintf(dump + len, "0x%02X", *value_ptr); + dump = erealloc(dump, len + 4 + 1); + snprintf(dump + len, 4 + 1, "0x%02X", *value_ptr); len += 4; value_ptr++; break; case TAG_FMT_USHORT: case TAG_FMT_SSHORT: - dump = erealloc(dump, len + 6); - sprintf(dump + len, "0x%04X", php_ifd_get16s(value_ptr, motorola_intel)); + dump = erealloc(dump, len + 6 + 1); + snprintf(dump + len, 6 + 1, "0x%04X", php_ifd_get16s(value_ptr, motorola_intel)); len += 6; value_ptr += 2; break; case TAG_FMT_ULONG: case TAG_FMT_SLONG: - dump = erealloc(dump, len + 6); - sprintf(dump + len, "0x%04X", php_ifd_get32s(value_ptr, motorola_intel)); + dump = erealloc(dump, len + 6 + 1); + snprintf(dump + len, 6 + 1, "0x%04X", php_ifd_get32s(value_ptr, motorola_intel)); len += 6; value_ptr += 4; break; case TAG_FMT_URATIONAL: case TAG_FMT_SRATIONAL: - dump = erealloc(dump, len + 13); - sprintf(dump + len, "0x%04X/0x%04X", php_ifd_get32s(value_ptr, motorola_intel), php_ifd_get32s(value_ptr+4, motorola_intel)); + dump = erealloc(dump, len + 13 + 1); + snprintf(dump + len, 13 + 1, "0x%04X/0x%04X", php_ifd_get32s(value_ptr, motorola_intel), php_ifd_get32s(value_ptr+4, motorola_intel)); len += 13; value_ptr += 8; break; } if (components > 0) { - dump = erealloc(dump, len + 2); - sprintf(dump + len, ", "); + dump = erealloc(dump, len + 2 + 1); + snprintf(dump + len, 2 + 1, ", "); len += 2; components--; } else{ break; } } - dump = erealloc(dump, len + 2); - sprintf(dump + len, "}"); + dump = erealloc(dump, len + 1 + 1); + snprintf(dump + len, 1 + 1, "}"); return dump; } /* }}} */ @@ -1448,18 +1448,18 @@ */ static char *exif_get_sectionlist(int sectionlist TSRMLS_DC) { - int i, len=0; + int i, len, ml = 0; char *sections; for(i=0; i<SECTION_COUNT; i++) { - len += strlen(exif_get_sectionname(i))+2; + ml += strlen(exif_get_sectionname(i))+2; } - sections = safe_emalloc(len, 1, 1); + sections = safe_emalloc(ml, 1, 1); sections[0] = '\0'; len = 0; for(i=0; i<SECTION_COUNT; i++) { if (sectionlist&(1<<i)) { - sprintf(sections+len, "%s, ", exif_get_sectionname(i)); + snprintf(sections+len, ml-len, "%s, ", exif_get_sectionname(i)); len = strlen(sections); } } @@ -3891,8 +3891,7 @@ if(ac >= 2) { convert_to_string_ex(p_sections_needed); - sections_str = safe_emalloc(strlen(Z_STRVAL_PP(p_sections_needed)), 1, 3); - sprintf(sections_str, ",%s,", Z_STRVAL_PP(p_sections_needed)); + spprintf(§ions_str, 0, ",%s,", Z_STRVAL_PP(p_sections_needed)); /* sections_str DOES start with , and SPACES are NOT allowed in names */ s = sections_str; while(*++s) { http://cvs.php.net/viewvc.cgi/php-src/ext/fbsql/php_fbsql.c?r1=1.122&r2=1.123&diff_format=u Index: php-src/ext/fbsql/php_fbsql.c diff -u php-src/ext/fbsql/php_fbsql.c:1.122 php-src/ext/fbsql/php_fbsql.c:1.123 --- php-src/ext/fbsql/php_fbsql.c:1.122 Mon Jan 1 09:29:23 2007 +++ php-src/ext/fbsql/php_fbsql.c Sat Feb 24 16:25:53 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_fbsql.c,v 1.122 2007/01/01 09:29:23 sebastian Exp $ */ +/* $Id: php_fbsql.c,v 1.123 2007/02/24 16:25:53 helly Exp $ */ /* TODO: * @@ -851,7 +851,7 @@ php_info_print_table_row(2, "Active Links", buf); /* - sprintf(buf, "%ld", FB_SQL_G(resultCount)); + snprintf(buf, sizeof(buf), "%ld", FB_SQL_G(resultCount)); php_info_print_table_row(2, "Active Results", buf); */ @@ -2944,7 +2944,7 @@ for (i = 0; i < nBits / 8; i++) { char c[4]; - sprintf(c, "%02x", ptr->bytes[i]); + snprintf(c, sizeof(c), "%02x", ptr->bytes[i]); r[i*2+2] = c[0]; r[i*2+3] = c[1]; } http://cvs.php.net/viewvc.cgi/php-src/ext/ftp/ftp.c?r1=1.121&r2=1.122&diff_format=u Index: php-src/ext/ftp/ftp.c diff -u php-src/ext/ftp/ftp.c:1.121 php-src/ext/ftp/ftp.c:1.122 --- php-src/ext/ftp/ftp.c:1.121 Tue Feb 13 18:30:19 2007 +++ php-src/ext/ftp/ftp.c Sat Feb 24 16:25:53 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ftp.c,v 1.121 2007/02/13 18:30:19 nlopess Exp $ */ +/* $Id: ftp.c,v 1.122 2007/02/24 16:25:53 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -586,11 +586,7 @@ return 0; } - if (!(buffer = emalloc(32 + filename_len + 1))) { - return 0; - } - - sprintf(buffer, "CHMOD %o %s", mode, filename); + spprintf(&buffer, 0, "CHMOD %o %s", mode, filename); if (!ftp_putcmd(ftp, "SITE", buffer)) { efree(buffer); @@ -810,7 +806,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483647 bytes"); goto bail; } - sprintf(arg, "%u", resumepos); + snprintf(arg, sizeof(arg), "%u", resumepos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -907,7 +903,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes"); goto bail; } - sprintf(arg, "%u", startpos); + snprintf(arg, sizeof(arg), "%u", startpos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -1106,13 +1102,13 @@ if (strlen(cmd) + strlen(args) + 4 > FTP_BUFSIZE) { return 0; } - size = sprintf(ftp->outbuf, "%s %s\r\n", cmd, args); + size = snprintf(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 = sprintf(ftp->outbuf, "%s\r\n", cmd); + size = snprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s\r\n", cmd); } data = ftp->outbuf; @@ -1438,7 +1434,7 @@ char eprtarg[INET6_ADDRSTRLEN + sizeof("|x||xxxxx|")]; char out[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &((struct sockaddr_in6*) sa)->sin6_addr, out, sizeof(out)); - sprintf(eprtarg, "|2|%s|%hu|", out, ntohs(((struct sockaddr_in6 *) &addr)->sin6_port)); + snprintf(eprtarg, sizeof(eprtarg), "|2|%s|%hu|", out, ntohs(((struct sockaddr_in6 *) &addr)->sin6_port)); if (!ftp_putcmd(ftp, "EPRT", eprtarg)) { goto bail; @@ -1456,7 +1452,7 @@ /* send the PORT */ ipbox.ia[0] = ((struct sockaddr_in*) sa)->sin_addr; ipbox.s[2] = ((struct sockaddr_in*) &addr)->sin_port; - sprintf(arg, "%u,%u,%u,%u,%u,%u", ipbox.c[0], ipbox.c[1], ipbox.c[2], ipbox.c[3], ipbox.c[4], ipbox.c[5]); + snprintf(arg, sizeof(arg), "%u,%u,%u,%u,%u,%u", ipbox.c[0], ipbox.c[1], ipbox.c[2], ipbox.c[3], ipbox.c[4], ipbox.c[5]); if (!ftp_putcmd(ftp, "PORT", arg)) { goto bail; @@ -1713,7 +1709,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483648 bytes"); goto bail; } - sprintf(arg, "%u", resumepos); + snprintf(arg, sizeof(arg), "%u", resumepos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -1831,7 +1827,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes"); goto bail; } - sprintf(arg, "%u", startpos); + snprintf(arg, sizeof(arg), "%u", startpos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gdtest.c?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/gd/libgd/gdtest.c diff -u php-src/ext/gd/libgd/gdtest.c:1.2 php-src/ext/gd/libgd/gdtest.c:1.3 --- php-src/ext/gd/libgd/gdtest.c:1.2 Tue Oct 29 23:08:01 2002 +++ php-src/ext/gd/libgd/gdtest.c Sat Feb 24 16:25:53 2007 @@ -56,7 +56,7 @@ /* */ /* Send to PNG File then Ptr */ /* */ - sprintf (of, "%s.png", argv[1]); + snprintf (of, sizeof(of), "%s.png", argv[1]); out = fopen (of, "wb"); gdImagePng (im, out); fclose (out); @@ -88,7 +88,7 @@ /* */ /* Send to GD2 File then Ptr */ /* */ - sprintf (of, "%s.gd2", argv[1]); + snprintf (of, sizeof(of), "%s.gd2", argv[1]); out = fopen (of, "wb"); gdImageGd2 (im, out, 128, 2); fclose (out); @@ -123,7 +123,7 @@ /* */ /* Send to GD File then Ptr */ /* */ - sprintf (of, "%s.gd", argv[1]); + snprintf (of, sizeof(of), "%s.gd", argv[1]); out = fopen (of, "wb"); gdImageGd (im, out); fclose (out); @@ -180,7 +180,7 @@ ** Test gdImagePngToSink' * */ - sprintf (of, "%s.snk", argv[1]); + snprintf (of, sizeof(of), "%s.snk", argv[1]); out = fopen (of, "wb"); imgsnk.sink = fwriteWrapper; imgsnk.context = out; http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/webpng.c?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/gd/libgd/webpng.c diff -u php-src/ext/gd/libgd/webpng.c:1.3 php-src/ext/gd/libgd/webpng.c:1.4 --- php-src/ext/gd/libgd/webpng.c:1.3 Sun Dec 28 20:11:08 2003 +++ php-src/ext/gd/libgd/webpng.c Sat Feb 24 16:25:53 2007 @@ -252,7 +252,7 @@ /* Open a temporary file. */ /* "temp.tmp" is not good temporary filename. */ - sprintf (outFn, "webpng.tmp%d", getpid ()); + snprintf (outFn, sizeof(outFn), "webpng.tmp%d", getpid ()); out = fopen (outFn, "wb"); if (!out) http://cvs.php.net/viewvc.cgi/php-src/ext/imap/php_imap.c?r1=1.237&r2=1.238&diff_format=u Index: php-src/ext/imap/php_imap.c diff -u php-src/ext/imap/php_imap.c:1.237 php-src/ext/imap/php_imap.c:1.238 --- php-src/ext/imap/php_imap.c:1.237 Mon Feb 19 16:04:14 2007 +++ php-src/ext/imap/php_imap.c Sat Feb 24 16:25:53 2007 @@ -26,7 +26,7 @@ | PHP 4.0 updates: Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_imap.c,v 1.237 2007/02/19 16:04:14 edink Exp $ */ +/* $Id: php_imap.c,v 1.238 2007/02/24 16:25:53 helly Exp $ */ #define IMAP41 @@ -1169,7 +1169,7 @@ tmp[3] = cache->answered ? 'A' : ' '; tmp[4] = cache->deleted ? 'D' : ' '; tmp[5] = cache->draft ? 'X' : ' '; - sprintf(tmp + 6, "%4ld) ", cache->msgno); + snprintf(tmp + 6, sizeof(tmp) - 6, "%4ld) ", cache->msgno); mail_date(tmp+11, cache); tmp[22] = ' '; tmp[23] = '\0'; @@ -1621,13 +1621,13 @@ add_property_string(return_value, "Deleted", cache->deleted ? "D" : " ", 1); add_property_string(return_value, "Draft", cache->draft ? "X" : " ", 1); - sprintf(dummy, "%4ld", cache->msgno); + snprintf(dummy, sizeof(dummy), "%4ld", cache->msgno); add_property_string(return_value, "Msgno", dummy, 1); mail_date(dummy, cache); add_property_string(return_value, "MailDate", dummy, 1); - sprintf(dummy, "%ld", cache->rfc822_size); + snprintf(dummy, sizeof(dummy), "%ld", cache->rfc822_size); add_property_string(return_value, "Size", dummy, 1); add_property_long(return_value, "udate", mail_longdate(cache)); @@ -3371,7 +3371,8 @@ char *tsm_errmsg = NULL; ADDRESS *addr; char *bufferTo = NULL, *bufferCc = NULL, *bufferBcc = NULL, *bufferHeader = NULL; - int offset, bufferLen = 0;; + int offset, bufferLen = 0; + size_t bt_len; if (headers) { bufferLen += strlen(headers); @@ -3393,7 +3394,9 @@ strlcat(bufferHeader, to, bufferLen + 1); strlcat(bufferHeader, "\r\n", bufferLen + 1); tempMailTo = estrdup(to); - bufferTo = (char *)emalloc(strlen(to) + 1); + bt_len = strlen(to); + bufferTo = (char *)safe_emalloc(bt_len, 1, 1); + bt_len++; offset = 0; addr = NULL; rfc822_parse_adrlist(&addr, tempMailTo, NULL); @@ -3401,7 +3404,11 @@ if (strcmp(addr->host, ERRHOST) == 0) { PHP_IMAP_BAD_DEST; } else { - offset += sprintf(bufferTo + offset, "%s@%s,", addr->mailbox, addr->host); + bufferTo = safe_erealloc(bufferTo, bt_len, 1, strlen(addr->mailbox)); + bt_len += strlen(addr->mailbox); + bufferTo = safe_erealloc(bufferTo, bt_len, 1, strlen(addr->host)); + bt_len += strlen(addr->host); + offset += snprintf(bufferTo + offset, bt_len - offset, "%s@%s,", addr->mailbox, addr->host); } addr = addr->next; } @@ -3416,7 +3423,9 @@ strlcat(bufferHeader, cc, bufferLen + 1); strlcat(bufferHeader, "\r\n", bufferLen + 1); tempMailTo = estrdup(cc); - bufferCc = (char *)emalloc(strlen(cc) + 1); + bt_len = strlen(cc); + bufferCc = (char *)safe_emalloc(bt_len, 1, 1); + bt_len++; offset = 0; addr = NULL; rfc822_parse_adrlist(&addr, tempMailTo, NULL); @@ -3424,7 +3433,11 @@ if (strcmp(addr->host, ERRHOST) == 0) { PHP_IMAP_BAD_DEST; } else { - offset += sprintf(bufferCc + offset, "%s@%s,", addr->mailbox, addr->host); + bufferCc = safe_erealloc(bufferCc, bt_len, 1, strlen(addr->mailbox)); + bt_len += strlen(addr->mailbox); + bufferCc = safe_erealloc(bufferCc, bt_len, 1, strlen(addr->host)); + bt_len += strlen(addr->host); + offset += snprintf(bufferCc + offset, bt_len - offset, "%s@%s,", addr->mailbox, addr->host); } addr = addr->next; } @@ -3436,7 +3449,9 @@ if (bcc && *bcc) { tempMailTo = estrdup(bcc); - bufferBcc = (char *)emalloc(strlen(bcc) + 1); + bt_len = strlen(bcc); + bufferBcc = (char *)safe_emalloc(bt_len, 1, 1); + bt_len++; offset = 0; addr = NULL; rfc822_parse_adrlist(&addr, tempMailTo, NULL); @@ -3444,7 +3459,11 @@ if (strcmp(addr->host, ERRHOST) == 0) { PHP_IMAP_BAD_DEST; } else { - offset += sprintf(bufferBcc + offset, "%s@%s,", addr->mailbox, addr->host); + bufferBcc = safe_erealloc(bufferBcc, bt_len, 1, strlen(addr->mailbox)); + bt_len += strlen(addr->mailbox); + bufferBcc = safe_erealloc(bufferBcc, bt_len, 1, strlen(addr->host)); + bt_len += strlen(addr->host); + offset += snprintf(bufferBcc + offset, bt_len - offset, "%s@%s,", addr->mailbox, addr->host); } addr = addr->next; } http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_blobs.c?r1=1.12&r2=1.13&diff_format=u Index: php-src/ext/interbase/ibase_blobs.c diff -u php-src/ext/interbase/ibase_blobs.c:1.12 php-src/ext/interbase/ibase_blobs.c:1.13 --- php-src/ext/interbase/ibase_blobs.c:1.12 Mon Jan 1 09:29:24 2007 +++ php-src/ext/interbase/ibase_blobs.c Sat Feb 24 16:25:53 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ibase_blobs.c,v 1.12 2007/01/01 09:29:24 sebastian Exp $ */ +/* $Id: ibase_blobs.c,v 1.13 2007/02/24 16:25:53 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -74,16 +74,15 @@ char *_php_ibase_quad_to_string(ISC_QUAD const qd) /* {{{ */ { - char *result = (char *) emalloc(BLOB_ID_LEN+1); + char *result; /* shortcut for most common case */ if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) { - sprintf(result, "0x%0*" LL_MASK "x", 16, *(ISC_UINT64*)(void *) &qd); + spprintf(&result, BLOB_ID_LEN+1, "0x%0*" LL_MASK "x", 16, *(ISC_UINT64*)(void *) &qd); } else { ISC_UINT64 res = ((ISC_UINT64) qd.gds_quad_high << 0x20) | qd.gds_quad_low; - sprintf(result, "0x%0*" LL_MASK "x", 16, res); + spprintf(&result, BLOB_ID_LEN+1, "0x%0*" LL_MASK "x", 16, res); } - result[BLOB_ID_LEN] = '\0'; return result; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.30&r2=1.31&diff_format=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.30 php-src/ext/interbase/ibase_query.c:1.31 --- php-src/ext/interbase/ibase_query.c:1.30 Mon Jan 22 09:08:21 2007 +++ php-src/ext/interbase/ibase_query.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ibase_query.c,v 1.30 2007/01/22 09:08:21 tony2001 Exp $ */ +/* $Id: ibase_query.c,v 1.31 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1312,17 +1312,17 @@ goto _sql_long; #else if (scale == 0) { - l = sprintf(string_data, "%" LL_MASK "d", *(ISC_INT64 *) data); + l = snprintf(string_data, sizeof(string_data), "%" LL_MASK "d", *(ISC_INT64 *) data); ZVAL_STRINGL(val,string_data,l,1); } else { ISC_INT64 n = *(ISC_INT64 *) data, f = scales[-scale]; if (n >= 0) { - l = sprintf(string_data, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -scale, n % f); + l = snprintf(string_data, sizeof(string_data), "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -scale, n % f); } else if (n <= -f) { - l = sprintf(string_data, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -scale, -n % f); + l = snprintf(string_data, sizeof(string_data), "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -scale, -n % f); } else { - l = sprintf(string_data, "-0.%0*" LL_MASK "d", -scale, -n % f); + l = snprintf(string_data, sizeof(string_data), "-0.%0*" LL_MASK "d", -scale, -n % f); } ZVAL_STRINGL(val,string_data,l,1); } @@ -1337,11 +1337,11 @@ long f = (long) scales[-scale]; if (n >= 0) { - l = sprintf(string_data, "%ld.%0*ld", n / f, -scale, n % f); + l = snprintf(string_data, sizeof(string_data), "%ld.%0*ld", n / f, -scale, n % f); } else if (n <= -f) { - l = sprintf(string_data, "%ld.%0*ld", n / f, -scale, -n % f); + l = snprintf(string_data, sizeof(string_data), "%ld.%0*ld", n / f, -scale, -n % f); } else { - l = sprintf(string_data, "-0.%0*ld", -scale, -n % f); + l = snprintf(string_data, sizeof(string_data), "-0.%0*ld", -scale, -n % f); } ZVAL_STRINGL(val,string_data,l,1); } @@ -1381,14 +1381,14 @@ #else switch (type & ~1) { default: - l = sprintf(string_data, "%02d/%02d/%4d %02d:%02d:%02d", t.tm_mon+1, t.tm_mday, + l = snprintf(string_data, sizeof(string_data), "%02d/%02d/%4d %02d:%02d:%02d", t.tm_mon+1, t.tm_mday, t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec); break; case SQL_TYPE_DATE: - l = sprintf(string_data, "%02d/%02d/%4d", t.tm_mon + 1, t.tm_mday, t.tm_year+1900); + l = snprintf(string_data, sizeof(string_data), "%02d/%02d/%4d", t.tm_mon + 1, t.tm_mday, t.tm_year+1900); break; case SQL_TYPE_TIME: - l = sprintf(string_data, "%02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec); + l = snprintf(string_data, sizeof(string_data), "%02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec); break; } #endif @@ -1520,7 +1520,7 @@ Z_ARRVAL_P(return_value),alias,strlen(alias)+1,&p)) { case '\0': - sprintf(alias = buf, "%s_%02d", base, i++); + snprintf(alias = buf, sizeof(buf), "%s_%02d", base, i++); } } } http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_service.c?r1=1.15&r2=1.16&diff_format=u Index: php-src/ext/interbase/ibase_service.c diff -u php-src/ext/interbase/ibase_service.c:1.15 php-src/ext/interbase/ibase_service.c:1.16 --- php-src/ext/interbase/ibase_service.c:1.15 Mon Jan 22 09:05:19 2007 +++ php-src/ext/interbase/ibase_service.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ibase_service.c,v 1.15 2007/01/22 09:05:19 tony2001 Exp $ */ +/* $Id: ibase_service.c,v 1.16 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -322,7 +322,7 @@ heap_p = heap_buf + res_size; } result += 2; - sprintf(heap_p, "%s\n", result); + snprintf(heap_p, sizeof(heap_buf_size), "%s\n", result); heap_p += line_len +2; goto query_loop; /* repeat until result is exhausted */ http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/interbase.c?r1=1.233&r2=1.234&diff_format=u Index: php-src/ext/interbase/interbase.c diff -u php-src/ext/interbase/interbase.c:1.233 php-src/ext/interbase/interbase.c:1.234 --- php-src/ext/interbase/interbase.c:1.233 Thu Jan 18 15:53:53 2007 +++ php-src/ext/interbase/interbase.c Sat Feb 24 16:25:54 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: interbase.c,v 1.233 2007/01/18 15:53:53 tony2001 Exp $ */ +/* $Id: interbase.c,v 1.234 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -542,7 +542,7 @@ #endif #ifdef FB_API_VER - sprintf( (s = tmp), "Firebird API version %d", FB_API_VER); + snprintf( (s = tmp), sizeof(tmp), "Firebird API version %d", FB_API_VER); #elif (SQLDA_CURRENT_VERSION > 1) s = "Interbase 7.0 and up"; #elif !defined(DSC_null) @@ -607,7 +607,7 @@ buf_len -= dpb_len; } if (largs[SYNC] && buf_len > 0) { - dpb_len = sprintf(dpb, buf_len, "%c\1%c", isc_dpb_force_write, largs[SYNC] == isc_spb_prp_wm_sync ? 1 : 0); + dpb_len = snprintf(dpb, buf_len, "%c\1%c", isc_dpb_force_write, largs[SYNC] == isc_spb_prp_wm_sync ? 1 : 0); dpb += dpb_len; buf_len -= dpb_len; } @@ -1170,7 +1170,7 @@ PHP_IBASE_LINK_TRANS(link, ib_link, trans); - sprintf(query, "SELECT GEN_ID(%s,%ld) FROM rdb$database", generator, inc); + snprintf(query, sizeof(query), "SELECT GEN_ID(%s,%ld) FROM rdb$database", generator, inc); /* allocate a minimal descriptor area */ out_sqlda.sqln = out_sqlda.sqld = 1; @@ -1192,10 +1192,11 @@ /* don't return the generator value as a string unless it doesn't fit in a long */ #if SIZEOF_LONG < 8 if (result < LONG_MIN || result > LONG_MAX) { - char res[24]; + char *res; + int l - sprintf(res, "%" LL_MASK "d", result); - RETURN_STRING(res,1); + l = spprintf(&res, 0, "%" LL_MASK "d", result); + RETURN_STRINGL(res, l, 0); } #endif RETURN_LONG((long)result); http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.266&r2=1.267&diff_format=u Index: php-src/ext/mbstring/mbstring.c diff -u php-src/ext/mbstring/mbstring.c:1.266 php-src/ext/mbstring/mbstring.c:1.267 --- php-src/ext/mbstring/mbstring.c:1.266 Fri Jan 12 12:06:33 2007 +++ php-src/ext/mbstring/mbstring.c Sat Feb 24 16:25:54 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.266 2007/01/12 12:06:33 tony2001 Exp $ */ +/* $Id: mbstring.c,v 1.267 2007/02/24 16:25:54 helly Exp $ */ /* * PHP 4 Multibyte String module "mbstring" @@ -1052,7 +1052,7 @@ { char buf[32]; php_info_print_table_row(2, "Multibyte (japanese) regex support", "enabled"); - sprintf(buf, "%d.%d.%d", + snprintf(buf, sizeof(buf), "%d.%d.%d", ONIGURUMA_VERSION_MAJOR,ONIGURUMA_VERSION_MINOR,ONIGURUMA_VERSION_TEENY); php_info_print_table_row(2, "Multibyte regex (oniguruma) version", buf); } http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/oniguruma/regposerr.c?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/mbstring/oniguruma/regposerr.c diff -u php-src/ext/mbstring/oniguruma/regposerr.c:1.3 php-src/ext/mbstring/oniguruma/regposerr.c:1.4 --- php-src/ext/mbstring/oniguruma/regposerr.c:1.3 Sun Feb 20 22:18:08 2005 +++ php-src/ext/mbstring/oniguruma/regposerr.c Sat Feb 24 16:25:54 2007 @@ -76,7 +76,7 @@ s = ""; } else { - sprintf(tbuf, "undefined error code (%d)", posix_ecode); + snprintf(tbuf, sizeof(tbuf), "undefined error code (%d)", posix_ecode); s = tbuf; } http://cvs.php.net/viewvc.cgi/php-src/ext/msql/php_msql.c?r1=1.66&r2=1.67&diff_format=u Index: php-src/ext/msql/php_msql.c diff -u php-src/ext/msql/php_msql.c:1.66 php-src/ext/msql/php_msql.c:1.67 --- php-src/ext/msql/php_msql.c:1.66 Mon Jan 1 09:29:25 2007 +++ php-src/ext/msql/php_msql.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_msql.c,v 1.66 2007/01/01 09:29:25 sebastian Exp $ */ +/* $Id: php_msql.c,v 1.67 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -250,9 +250,7 @@ } convert_to_string(yyhost); host = Z_STRVAL_P(yyhost); - hashed_details_length = Z_STRLEN_P(yyhost)+4+1; - hashed_details = emalloc(hashed_details_length+1); - sprintf(hashed_details,"msql_%s",Z_STRVAL_P(yyhost)); /* SAFE */ + hashed_details_length = spprintf(&hashed_details, 0, "msql_%s",Z_STRVAL_P(yyhost)); } break; default: http://cvs.php.net/viewvc.cgi/php-src/ext/mssql/php_mssql.c?r1=1.168&r2=1.169&diff_format=u Index: php-src/ext/mssql/php_mssql.c diff -u php-src/ext/mssql/php_mssql.c:1.168 php-src/ext/mssql/php_mssql.c:1.169 --- php-src/ext/mssql/php_mssql.c:1.168 Sun Feb 4 21:24:28 2007 +++ php-src/ext/mssql/php_mssql.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mssql.c,v 1.168 2007/02/04 21:24:28 fmk Exp $ */ +/* $Id: php_mssql.c,v 1.169 2007/02/24 16:25:54 helly Exp $ */ #ifdef COMPILE_DL_MSSQL #define HAVE_MSSQL 1 @@ -373,9 +373,9 @@ php_info_print_table_start(); php_info_print_table_header(2, "MSSQL Support", "enabled"); - sprintf(buf, "%ld", MS_SQL_G(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", MS_SQL_G(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", MS_SQL_G(num_links)); + snprintf(buf, sizeof(buf), "%ld", MS_SQL_G(num_links)); php_info_print_table_row(2, "Active Links", buf); php_info_print_table_row(2, "Library version", MSSQL_VERSION); @@ -391,7 +391,7 @@ char *hashed_details; int hashed_details_length, new_link = 0; mssql_link mssql, *mssql_ptr; - char buffer[32]; + char buffer[40]; switch(ZEND_NUM_ARGS()) { case 0: /* defaults */ @@ -409,9 +409,7 @@ convert_to_string_ex(yyhost); host = Z_STRVAL_PP(yyhost); user=passwd=NULL; - hashed_details_length = Z_STRLEN_PP(yyhost)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details,"mssql_%s__",Z_STRVAL_PP(yyhost)); + hashed_details_length = spprintf(&hashed_details, 0, "mssql_%s__", Z_STRVAL_PP(yyhost)); } break; case 2: { @@ -425,9 +423,7 @@ host = Z_STRVAL_PP(yyhost); user = Z_STRVAL_PP(yyuser); passwd=NULL; - hashed_details_length = Z_STRLEN_PP(yyhost)+Z_STRLEN_PP(yyuser)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details,"mssql_%s_%s_",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser)); + hashed_details_length = spprintf(&hashed_details, 0, "mssql_%s_%s_",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser)); } break; case 3: { @@ -442,9 +438,7 @@ host = Z_STRVAL_PP(yyhost); user = Z_STRVAL_PP(yyuser); passwd = Z_STRVAL_PP(yypasswd); - hashed_details_length = Z_STRLEN_PP(yyhost)+Z_STRLEN_PP(yyuser)+Z_STRLEN_PP(yypasswd)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); /* SAFE */ + hashed_details_length = spprintf(&hashed_details,0,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); } break; case 4: { @@ -461,9 +455,7 @@ user = Z_STRVAL_PP(yyuser); passwd = Z_STRVAL_PP(yypasswd); new_link = Z_LVAL_PP(yynew_link); - hashed_details_length = Z_STRLEN_PP(yyhost)+Z_STRLEN_PP(yyuser)+Z_STRLEN_PP(yypasswd)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); /* SAFE */ + hashed_details_length = spprintf(&hashed_details,0,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); } break; default: @@ -554,7 +546,7 @@ #ifndef HAVE_FREETDS if (MS_SQL_G(textlimit) != -1) { - sprintf(buffer, "%li", MS_SQL_G(textlimit)); + snprintf(buffer, sizeof(buffer), "%li", MS_SQL_G(textlimit)); if (DBSETOPT(mssql.link, DBTEXTLIMIT, buffer)==FAIL) { efree(hashed_details); dbfreelogin(mssql.login); @@ -564,7 +556,7 @@ } #endif if (MS_SQL_G(textsize) != -1) { - sprintf(buffer, "SET TEXTSIZE %li", MS_SQL_G(textsize)); + snprintf(buffer, sizeof(buffer), "SET TEXTSIZE %li", MS_SQL_G(textsize)); dbcmd(mssql.link, buffer); dbsqlexec(mssql.link); dbresults(mssql.link); @@ -681,7 +673,7 @@ #ifndef HAVE_FREETDS if (MS_SQL_G(textlimit) != -1) { - sprintf(buffer, "%li", MS_SQL_G(textlimit)); + snprintf(buffer, sizeof(buffer), "%li", MS_SQL_G(textlimit)); if (DBSETOPT(mssql.link, DBTEXTLIMIT, buffer)==FAIL) { efree(hashed_details); dbfreelogin(mssql.login); @@ -691,7 +683,7 @@ } #endif if (MS_SQL_G(textsize) != -1) { - sprintf(buffer, "SET TEXTSIZE %li", MS_SQL_G(textsize)); + snprintf(buffer, sizeof(buffer), "SET TEXTSIZE %li", MS_SQL_G(textsize)); dbcmd(mssql.link, buffer); dbsqlexec(mssql.link); dbresults(mssql.link); @@ -929,8 +921,7 @@ } res_length = 19; - res_buf = (unsigned char *) emalloc(res_length+1); - sprintf(res_buf, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second); + spprintf(&res_buf, 0, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second); } ZVAL_STRINGL(result, res_buf, res_length, 0); @@ -999,8 +990,7 @@ } res_length = 19; - res_buf = (unsigned char *) emalloc(res_length+1); - sprintf(res_buf, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second); + spprintf(&res_buf, 0, "%d-%02d-%02d %02d:%02d:%02d" , dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, dateinfo.second); } ZVAL_STRINGL(result, res_buf, res_length, 0); http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/php_mysql.c?r1=1.230&r2=1.231&diff_format=u Index: php-src/ext/mysql/php_mysql.c diff -u php-src/ext/mysql/php_mysql.c:1.230 php-src/ext/mysql/php_mysql.c:1.231 --- php-src/ext/mysql/php_mysql.c:1.230 Mon Jan 1 09:29:25 2007 +++ php-src/ext/mysql/php_mysql.c Sat Feb 24 16:25:54 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mysql.c,v 1.230 2007/01/01 09:29:25 sebastian Exp $ */ +/* $Id: php_mysql.c,v 1.231 2007/02/24 16:25:54 helly Exp $ */ /* TODO: * @@ -441,9 +441,9 @@ php_info_print_table_start(); php_info_print_table_header(2, "MySQL Support", "enabled"); - sprintf(buf, "%ld", MySG(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", MySG(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", MySG(num_links)); + snprintf(buf, sizeof(buf), "%ld", MySG(num_links)); php_info_print_table_row(2, "Active Links", buf); php_info_print_table_row(2, "Client API version", mysql_get_client_info()); #if !defined (PHP_WIN32) && !defined (NETWARE) @@ -513,9 +513,7 @@ } host_and_port=passwd=NULL; user=php_get_current_user(); - hashed_details_length = strlen(user)+5+3; - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details, "mysql__%s_", user); + hashed_details_length = spprintf(&hashed_details, 0, "mysql__%s_", user); client_flags = CLIENT_INTERACTIVE; } else { host_and_port = MySG(default_host); @@ -538,9 +536,7 @@ client_flags ^= CLIENT_LOCAL_FILES; } - hashed_details_length = sizeof("mysql___")-1 + strlen(SAFE_STRING(host_and_port))+strlen(SAFE_STRING(user))+strlen(SAFE_STRING(passwd)); - hashed_details = (char *) emalloc(hashed_details_length+1); - sprintf(hashed_details, "mysql_%s_%s_%s", SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd)); + hashed_details_length = spprintf(&hashed_details, 0, "mysql_%s_%s_%s", SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd)); } /* We cannot use mysql_port anymore in windows, need to use @@ -1137,8 +1133,8 @@ if (!strncasecmp("select", query, 6)){ MYSQL_ROW row; - char *newquery = (char *)emalloc(strlen(query) + 10); - sprintf ((char *)newquery, "EXPLAIN %s", query); + char *newquery; + spprintf(&newquery, 0, "EXPLAIN %s", query); mysql_real_query(&mysql->conn, newquery, strlen(newquery)); efree (newquery); if (mysql_errno(&mysql->conn)) { http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli.c?r1=1.102&r2=1.103&diff_format=u Index: php-src/ext/mysqli/mysqli.c diff -u php-src/ext/mysqli/mysqli.c:1.102 php-src/ext/mysqli/mysqli.c:1.103 --- php-src/ext/mysqli/mysqli.c:1.102 Fri Feb 16 18:49:06 2007 +++ php-src/ext/mysqli/mysqli.c Sat Feb 24 16:25:54 2007 @@ -15,7 +15,7 @@ | Author: Georg Richter <georg@php.net> | +----------------------------------------------------------------------+ - $Id: mysqli.c,v 1.102 2007/02/16 18:49:06 stas Exp $ + $Id: mysqli.c,v 1.103 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H @@ -1058,7 +1058,7 @@ mysql->li_stream = php_stream_open_wrapper_ex((char *)filename, "r", 0, NULL, context); if (mysql->li_stream == NULL) { - sprintf((char *)data->error_msg, "Can't find file '%-.64s'.", filename); + snprintf((char *)data->error_msg, sizeof(data->error_msg), "Can't find file '%-.64s'.", filename); return 1; } http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli_api.c?r1=1.143&r2=1.144&diff_format=u Index: php-src/ext/mysqli/mysqli_api.c diff -u php-src/ext/mysqli/mysqli_api.c:1.143 php-src/ext/mysqli/mysqli_api.c:1.144 --- php-src/ext/mysqli/mysqli_api.c:1.143 Fri Jan 12 20:26:35 2007 +++ php-src/ext/mysqli/mysqli_api.c Sat Feb 24 16:25:54 2007 @@ -15,7 +15,7 @@ | Author: Georg Richter <georg@php.net> | +----------------------------------------------------------------------+ - $Id: mysqli_api.c,v 1.143 2007/01/12 20:26:35 andrey Exp $ + $Id: mysqli_api.c,v 1.144 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H @@ -751,7 +751,7 @@ * may be negative. Therefor we cannot use MYSQLI_LLU_SPEC and must * use MYSQLI_LL_SPEC. */ - sprintf((char *)&tmp, (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval); + snprintf(tmp, sizeof(tmp), (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval); ZVAL_UTF8_STRING(stmt->result.vars[i], tmp, ZSTR_DUPLICATE); } else { ZVAL_LONG(stmt->result.vars[i], llval); http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli_prop.c?r1=1.29&r2=1.30&diff_format=u Index: php-src/ext/mysqli/mysqli_prop.c diff -u php-src/ext/mysqli/mysqli_prop.c:1.29 php-src/ext/mysqli/mysqli_prop.c:1.30 --- php-src/ext/mysqli/mysqli_prop.c:1.29 Mon Jan 1 09:29:25 2007 +++ php-src/ext/mysqli/mysqli_prop.c Sat Feb 24 16:25:54 2007 @@ -15,7 +15,7 @@ | Author: Georg Richter <georg@php.net> | +----------------------------------------------------------------------+ - $Id: mysqli_prop.c,v 1.29 2007/01/01 09:29:25 sebastian Exp $ + $Id: mysqli_prop.c,v 1.30 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H @@ -85,9 +85,9 @@ if (l < LONG_MAX) {\ ZVAL_LONG(*retval, l);\ } else { \ - char ret[40]; \ - sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong)l); \ - ZVAL_STRING(*retval, ret, 1); \ + char *ret; \ + int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (my_ulonglong)l); \ + ZVAL_STRINGL(*retval, ret, l, 0); \ } \ }\ return SUCCESS;\ @@ -175,9 +175,9 @@ if (rc < LONG_MAX) { ZVAL_LONG(*retval, rc); } else { - char ret[40]; - sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc); - ZVAL_STRING(*retval, ret, 1); + char *ret; + int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (my_ulonglong) rc); + ZVAL_STRINGL(*retval, ret, l, 0); } } return SUCCESS; @@ -294,9 +294,9 @@ if (rc < LONG_MAX) { ZVAL_LONG(*retval, rc); } else { - char ret[40]; - sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc); - ZVAL_STRING(*retval, ret, 1); + char *ret; + int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (my_ulonglong) rc); + ZVAL_STRINGL(*retval, ret, l, 0); } } return SUCCESS; http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/php_mysqli.h?r1=1.63&r2=1.64&diff_format=u Index: php-src/ext/mysqli/php_mysqli.h diff -u php-src/ext/mysqli/php_mysqli.h:1.63 php-src/ext/mysqli/php_mysqli.h:1.64 --- php-src/ext/mysqli/php_mysqli.h:1.63 Mon Jan 1 09:29:26 2007 +++ php-src/ext/mysqli/php_mysqli.h Sat Feb 24 16:25:54 2007 @@ -15,7 +15,7 @@ | Author: Georg Richter <georg@php.net> | +----------------------------------------------------------------------+ - $Id: php_mysqli.h,v 1.63 2007/01/01 09:29:26 sebastian Exp $ + $Id: php_mysqli.h,v 1.64 2007/02/24 16:25:54 helly Exp $ */ /* A little hack to prevent build break, when mysql is used together with @@ -257,9 +257,9 @@ if ((__val) < LONG_MAX) { \ RETURN_LONG((__val)); \ } else { \ - char ret[40]; \ - sprintf(ret, "%llu", (__val)); \ - RETURN_STRING(ret,1); \ + char *ret; \ + int l = spprintf(&ret, 0, "%llu", (__val)); \ + RETURN_STRINGL(ret, l, 0); \ } \ } http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8.c?r1=1.329&r2=1.330&diff_format=u Index: php-src/ext/oci8/oci8.c diff -u php-src/ext/oci8/oci8.c:1.329 php-src/ext/oci8/oci8.c:1.330 --- php-src/ext/oci8/oci8.c:1.329 Mon Feb 12 09:36:11 2007 +++ php-src/ext/oci8/oci8.c Sat Feb 24 16:25:54 2007 @@ -26,7 +26,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.329 2007/02/12 09:36:11 tony2001 Exp $ */ +/* $Id: oci8.c,v 1.330 2007/02/24 16:25:54 helly Exp $ */ /* TODO * * file://localhost/www/docs/oci10/ociaahan.htm#423823 - implement lob_empty() with OCI_ATTR_LOBEMPTY @@ -674,11 +674,11 @@ php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); php_info_print_table_row(2, "Version", "1.2.2"); - php_info_print_table_row(2, "Revision", "$Revision: 1.329 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.330 $"); - sprintf(buf, "%ld", OCI_G(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent)); php_info_print_table_row(2, "Active Persistent Connections", buf); - sprintf(buf, "%ld", OCI_G(num_links)); + snprintf(buf, sizeof(buf), "%ld", OCI_G(num_links)); php_info_print_table_row(2, "Active Connections", buf); #if !defined(PHP_WIN32) && !defined(HAVE_OCI_INSTANT_CLIENT) @@ -687,7 +687,7 @@ php_info_print_table_row(2, "Libraries Used", PHP_OCI8_SHARED_LIBADD ); #else # if defined(HAVE_OCI_INSTANT_CLIENT) && defined(OCI_MAJOR_VERSION) && defined(OCI_MINOR_VERSION) - sprintf(buf, "%d.%d", OCI_MAJOR_VERSION, OCI_MINOR_VERSION); + snprintf(buf, sizeof(buf), "%d.%d", OCI_MAJOR_VERSION, OCI_MINOR_VERSION); php_info_print_table_row(2, "Oracle Instant Client Version", buf); # endif #endif http://cvs.php.net/viewvc.cgi/php-src/ext/odbc/php_odbc.c?r1=1.200&r2=1.201&diff_format=u Index: php-src/ext/odbc/php_odbc.c diff -u php-src/ext/odbc/php_odbc.c:1.200 php-src/ext/odbc/php_odbc.c:1.201 --- php-src/ext/odbc/php_odbc.c:1.200 Mon Feb 19 20:22:29 2007 +++ php-src/ext/odbc/php_odbc.c Sat Feb 24 16:25:54 2007 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_odbc.c,v 1.200 2007/02/19 20:22:29 tony2001 Exp $ */ +/* $Id: php_odbc.c,v 1.201 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -544,9 +544,9 @@ php_info_print_table_start(); php_info_print_table_header(2, "ODBC Support", "enabled"); - sprintf(buf, "%ld", ODBCG(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", ODBCG(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", ODBCG(num_links)); + snprintf(buf, sizeof(buf), "%ld", ODBCG(num_links)); php_info_print_table_row(2, "Active Links", buf); php_info_print_table_row(2, "ODBC library", PHP_ODBC_TYPE); #ifndef PHP_WIN32 @@ -588,8 +588,8 @@ */ rc = SQLError(henv, conn, stmt, state, &error, errormsg, sizeof(errormsg)-1, &errormsgsize); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - sprintf(state, "HY000"); - sprintf(errormsg, "Failed to fetch error message"); + snprintf(state, sizeof(state), "HY000"); + snprintf(errormsg, sizeof(errormsg), "Failed to fetch error message"); } if (conn_resource) { memcpy(conn_resource->laststate, state, sizeof(state)); @@ -1155,7 +1155,7 @@ result->stmt, state, &error, errormsg, sizeof(errormsg)-1, &errormsgsize); if (!strncmp(state,"S1015",5)) { - sprintf(cursorname,"php_curs_%d", (int)result->stmt); + snprintf(cursorname, max_len+1, "php_curs_%d", (int)result->stmt); if (SQLSetCursorName(result->stmt,cursorname,SQL_NTS) != SQL_SUCCESS) { odbc_sql_error(result->conn_ptr, result->stmt, "SQLSetCursorName"); RETVAL_FALSE; @@ -2148,8 +2148,7 @@ if (strstr((char*)db, ";")) { direct = 1; if (uid && !strstr ((char*)db, "uid") && !strstr((char*)db, "UID")) { - ldb = (char*) emalloc(strlen(db) + strlen(uid) + strlen(pwd) + 12); - sprintf(ldb, "%s;UID=%s;PWD=%s", db, uid, pwd); + spprintf(&ldb, 0, "%s;UID=%s;PWD=%s", db, uid, pwd); } else { ldb_len = strlen(db)+1; ldb = (char*) emalloc(ldb_len); http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.133&r2=1.134&diff_format=u Index: php-src/ext/openssl/openssl.c diff -u php-src/ext/openssl/openssl.c:1.133 php-src/ext/openssl/openssl.c:1.134 --- php-src/ext/openssl/openssl.c:1.133 Fri Jan 19 19:23:20 2007 +++ php-src/ext/openssl/openssl.c Sat Feb 24 16:25:54 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: openssl.c,v 1.133 2007/01/19 19:23:20 rrichards Exp $ */ +/* $Id: openssl.c,v 1.134 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -302,7 +302,7 @@ /* This is how the time string is formatted: - sprintf(p,"%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100, + snprintf(p, sizeof(p), "%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100, ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); */ http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/pcrelib/pcregrep.c?r1=1.13&r2=1.14&diff_format=u Index: php-src/ext/pcre/pcrelib/pcregrep.c diff -u php-src/ext/pcre/pcrelib/pcregrep.c:1.13 php-src/ext/pcre/pcrelib/pcregrep.c:1.14 --- php-src/ext/pcre/pcrelib/pcregrep.c:1.13 Fri Feb 9 20:13:17 2007 +++ php-src/ext/pcre/pcrelib/pcregrep.c Sat Feb 24 16:25:54 2007 @@ -1188,8 +1188,7 @@ while ((nextfile = readdirectory(dir)) != NULL) { int frc, blen; - sprintf(buffer, "%.512s%c%.128s", pathname, sep, nextfile); - blen = strlen(buffer); + blen = snprintf(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) @@ -1281,7 +1280,7 @@ { int n; char s[4]; - if (op->one_char > 0) sprintf(s, "-%c,", op->one_char); else strcpy(s, " "); + if (op->one_char > 0) snprintf(s, sizeof(s), "-%c,", op->one_char); else strcpy(s, " "); printf(" %s --%s%n", s, op->long_name, &n); n = 30 - n; if (n < 1) n = 1; @@ -1355,7 +1354,7 @@ { static char buffer[8]; char *p = buffer; -sprintf(p, "%d", n); +snprintf(p, sizeof(buffer), "%d", n); while (*p != 0) p++; switch (n%10) { @@ -1401,7 +1400,7 @@ return FALSE; } -sprintf(buffer, "%s%.*s%s", prefix[process_options], MBUFTHIRD, pattern, +snprintf(buffer, sizeof(buffer), "%s%.*s%s", prefix[process_options], MBUFTHIRD, pattern, suffix[process_options]); pattern_list[pattern_count] = pcre_compile(buffer, options, &error, &errptr, pcretables); @@ -1463,7 +1462,7 @@ char *p = end_of_line(pattern, eop, &ellength); if (ellength == 0) return compile_single_pattern(pattern, options, filename, count); - sprintf(buffer, "%.*s", p - pattern - ellength, pattern); + snprintf(buffer, sizeof(buffer), "%.*s", p - pattern - ellength, pattern); pattern = p; if (!compile_single_pattern(buffer, options, filename, count)) return FALSE; @@ -1579,8 +1578,8 @@ char buff1[24]; char buff2[24]; int baselen = opbra - op->long_name; - sprintf(buff1, "%.*s", baselen, op->long_name); - sprintf(buff2, "%s%.*s", buff1, strlen(op->long_name) - baselen - 2, + snprintf(buff1, sizeof(buff1), "%.*s", baselen, op->long_name); + snprintf(buff2, sizeof(buff2), "%s%.*s", buff1, strlen(op->long_name) - baselen - 2, opbra + 1); if (strcmp(arg, buff1) == 0 || strcmp(arg, buff2) == 0) break; @@ -1935,7 +1934,7 @@ if (error != NULL) { char s[16]; - if (pattern_count == 1) s[0] = 0; else sprintf(s, " number %d", j); + if (pattern_count == 1) s[0] = 0; else snprintf(s, sizeof(s), " number %d", j); fprintf(stderr, "pcregrep: Error while studying regex%s: %s\n", s, error); return 2; } http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/pcrelib/pcreposix.c?r1=1.19&r2=1.20&diff_format=u Index: php-src/ext/pcre/pcrelib/pcreposix.c diff -u php-src/ext/pcre/pcrelib/pcreposix.c:1.19 php-src/ext/pcre/pcrelib/pcreposix.c:1.20 --- php-src/ext/pcre/pcrelib/pcreposix.c:1.19 Fri Feb 9 20:13:17 2007 +++ php-src/ext/pcre/pcrelib/pcreposix.c Sat Feb 24 16:25:54 2007 @@ -158,7 +158,7 @@ if (errbuf_size > 0) { if (addlength > 0 && errbuf_size >= length + addlength) - sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset); + snprintf(errbuf, errbuf_size, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset); else { strncpy(errbuf, message, errbuf_size - 1); http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_firebird/firebird_statement.c?r1=1.20&r2=1.21&diff_format=u Index: php-src/ext/pdo_firebird/firebird_statement.c diff -u php-src/ext/pdo_firebird/firebird_statement.c:1.20 php-src/ext/pdo_firebird/firebird_statement.c:1.21 --- php-src/ext/pdo_firebird/firebird_statement.c:1.20 Mon Jan 1 09:29:27 2007 +++ php-src/ext/pdo_firebird/firebird_statement.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: firebird_statement.c,v 1.20 2007/01/01 09:29:27 sebastian Exp $ */ +/* $Id: firebird_statement.c,v 1.21 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -211,6 +211,8 @@ #define FETCH_BUF(buf,type,len,lenvar) ((buf) = (buf) ? (buf) : \ emalloc((len) ? (len * sizeof(type)) : ((*(unsigned long*)lenvar) = sizeof(type)))) +#define CHAR_BUF_LEN 24 + /* fetch a blob into a fetch buffer */ static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */ unsigned long *len, ISC_QUAD *blob_id TSRMLS_DC) @@ -322,16 +324,16 @@ n = *(ISC_INT64*)var->sqldata; } - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); if (n >= 0) { - *len = sprintf(*ptr, "%" LL_MASK "d.%0*" LL_MASK "d", + *len = snprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -var->sqlscale, n % f); } else if (n < -f) { - *len = sprintf(*ptr, "%" LL_MASK "d.%0*" LL_MASK "d", + *len = snprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -var->sqlscale, -n % f); } else { - *len = sprintf(*ptr, "-0.%0*" LL_MASK "d", -var->sqlscale, -n % f); + *len = snprintf(*ptr, CHAR_BUF_LEN, "-0.%0*" LL_MASK "d", -var->sqlscale, -n % f); } } else { switch (var->sqltype & ~1) { @@ -353,24 +355,24 @@ break; /* --- cut here --- */ case SQL_SHORT: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%d", *(short*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%d", *(short*)var->sqldata); break; case SQL_LONG: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%ld", *(ISC_LONG*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%ld", *(ISC_LONG*)var->sqldata); break; case SQL_INT64: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%" LL_MASK "d", *(ISC_INT64*)var->sqldata); break; case SQL_FLOAT: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%f", *(float*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%f", *(float*)var->sqldata); break; case SQL_DOUBLE: - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL); - *len = sprintf(*ptr, "%f" , *(double*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN"%f" , *(double*)var->sqldata); break; /* --- cut here --- */ #if abies_0 @@ -391,8 +393,8 @@ #if SIZEOF_LONG == 8 *ptr = var->sqldata; #else - *ptr = FETCH_BUF(S->fetch_buf[colno], char, 20, NULL); - *len = sprintf(*ptr, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata); + *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); + *len = snprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata); #endif break; case SQL_FLOAT: http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_odbc/odbc_driver.c?r1=1.30&r2=1.31&diff_format=u Index: php-src/ext/pdo_odbc/odbc_driver.c diff -u php-src/ext/pdo_odbc/odbc_driver.c:1.30 php-src/ext/pdo_odbc/odbc_driver.c:1.31 --- php-src/ext/pdo_odbc/odbc_driver.c:1.30 Mon Jan 1 09:29:28 2007 +++ php-src/ext/pdo_odbc/odbc_driver.c Sat Feb 24 16:25:54 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: odbc_driver.c,v 1.30 2007/01/01 09:29:28 sebastian Exp $ */ +/* $Id: odbc_driver.c,v 1.31 2007/02/24 16:25:54 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -387,8 +387,8 @@ /* Force UID and PWD to be set in the DSN */ if (dbh->username && *dbh->username && !strstr(dbh->data_source, "uid") && !strstr(dbh->data_source, "UID")) { - char *dsn = pemalloc(strlen(dbh->data_source) + strlen(dbh->username) + strlen(dbh->password) + sizeof(";UID=;PWD="), dbh->is_persistent); - sprintf(dsn, "%s;UID=%s;PWD=%s", dbh->data_source, dbh->username, dbh->password); + char *dsn; + spprintf(&dsn, 0, "%s;UID=%s;PWD=%s", dbh->data_source, dbh->username, dbh->password); pefree((char*)dbh->data_source, dbh->is_persistent); dbh->data_source = dsn; } http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.365&r2=1.366&diff_format=u Index: php-src/ext/pgsql/pgsql.c diff -u php-src/ext/pgsql/pgsql.c:1.365 php-src/ext/pgsql/pgsql.c:1.366 --- php-src/ext/pgsql/pgsql.c:1.365 Thu Jan 11 16:45:27 2007 +++ php-src/ext/pgsql/pgsql.c Sat Feb 24 16:25:54 2007 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.365 2007/01/11 16:45:27 tony2001 Exp $ */ +/* $Id: pgsql.c,v 1.366 2007/02/24 16:25:54 helly Exp $ */ #include <stdlib.h> @@ -599,9 +599,9 @@ php_info_print_table_row(2, "SSL support", "disabled"); #endif #endif /* HAVE_PG_CONFIG_H */ - sprintf(buf, "%ld", PGG(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", PGG(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", PGG(num_links)); + snprintf(buf, sizeof(buf), "%ld", PGG(num_links)); php_info_print_table_row(2, "Active Links", buf); php_info_print_table_end(); http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/pspell.c?r1=1.57&r2=1.58&diff_format=u Index: php-src/ext/pspell/pspell.c diff -u php-src/ext/pspell/pspell.c:1.57 php-src/ext/pspell/pspell.c:1.58 --- php-src/ext/pspell/pspell.c:1.57 Sat Feb 17 01:47:26 2007 +++ php-src/ext/pspell/pspell.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pspell.c,v 1.57 2007/02/17 01:47:26 stas Exp $ */ +/* $Id: pspell.c,v 1.58 2007/02/24 16:25:55 helly Exp $ */ #define IS_EXT_MODULE @@ -778,7 +778,7 @@ convert_to_long_ex(pignore); ignore = Z_LVAL_PP(pignore); - sprintf(ignore_str, "%ld", ignore); + snprintf(ignore_str, sizeof(ignore_str), "%ld", ignore); pspell_config_replace(config, "ignore", ignore_str); RETURN_TRUE; http://cvs.php.net/viewvc.cgi/php-src/ext/session/mod_mm.c?r1=1.49&r2=1.50&diff_format=u Index: php-src/ext/session/mod_mm.c diff -u php-src/ext/session/mod_mm.c:1.49 php-src/ext/session/mod_mm.c:1.50 --- php-src/ext/session/mod_mm.c:1.49 Thu Jan 4 22:04:38 2007 +++ php-src/ext/session/mod_mm.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_mm.c,v 1.49 2007/01/04 22:04:38 pollita Exp $ */ +/* $Id: mod_mm.c,v 1.50 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" @@ -269,7 +269,7 @@ return FAILURE; } - if (!sprintf(euid,"%d", geteuid())) { + if (!snprintf(euid, sizeof(euid), "%d", geteuid())) { return FAILURE; } http://cvs.php.net/viewvc.cgi/php-src/ext/session/session.c?r1=1.465&r2=1.466&diff_format=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.465 php-src/ext/session/session.c:1.466 --- php-src/ext/session/session.c:1.465 Fri Jan 5 14:53:30 2007 +++ php-src/ext/session/session.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: session.c,v 1.465 2007/01/05 14:53:30 sebastian Exp $ */ +/* $Id: session.c,v 1.466 2007/02/24 16:25:55 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -287,10 +287,8 @@ remote_addr = Z_STRVAL_PP(token); } - buf = emalloc(PS_ID_INITIAL_SIZE); - /* maximum 15+19+19+10 bytes */ - sprintf(buf, "%.15s%ld%ld%0.8F", remote_addr ? remote_addr : "", + spprintf(&buf, 0, "%.15s%ld%ld%0.8F", remote_addr ? remote_addr : "", tv.tv_sec, (long int)tv.tv_usec, php_combined_lcg(TSRMLS_C) * 10); switch (PS(hash_func)) { @@ -936,7 +934,7 @@ php_gmtime_r(when, &tm); - n = sprintf(buf, "%s, %02d %s %d %02d:%02d:%02d GMT", /* SAFE */ + n = snprintf(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, @@ -977,7 +975,7 @@ strcpy_gmt(buf + sizeof(EXPIRES) - 1, &now); ADD_HEADER(buf); - sprintf(buf, "Cache-Control: public, max-age=%ld", PS(cache_expire) * 60); /* SAFE */ + snprintf(buf, sizeof(buf) , "Cache-Control: public, max-age=%ld", PS(cache_expire) * 60); /* SAFE */ ADD_HEADER(buf); last_modified(TSRMLS_C); @@ -987,7 +985,7 @@ { char buf[MAX_STR + 1]; - sprintf(buf, "Cache-Control: private, max-age=%ld, pre-check=%ld", PS(cache_expire) * 60, PS(cache_expire) * 60); /* SAFE */ + snprintf(buf, sizeof(buf), "Cache-Control: private, max-age=%ld, pre-check=%ld", PS(cache_expire) * 60, PS(cache_expire) * 60); /* SAFE */ ADD_HEADER(buf); last_modified(TSRMLS_C); http://cvs.php.net/viewvc.cgi/php-src/ext/skeleton/skeleton.c?r1=1.37&r2=1.38&diff_format=u Index: php-src/ext/skeleton/skeleton.c diff -u php-src/ext/skeleton/skeleton.c:1.37 php-src/ext/skeleton/skeleton.c:1.38 --- php-src/ext/skeleton/skeleton.c:1.37 Tue Jun 13 13:12:19 2006 +++ php-src/ext/skeleton/skeleton.c Sat Feb 24 16:25:55 2007 @@ -138,14 +138,14 @@ { char *arg = NULL; int arg_len, len; - char string[256]; + char *strg; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { return; } - len = sprintf(string, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "extname", arg); - RETURN_STRINGL(string, len, 1); + len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "extname", arg); + RETURN_STRINGL(strg, len, 0); } /* }}} */ /* The previous line is meant for vim and emacs, so it can correctly fold and http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_encoding.c?r1=1.152&r2=1.153&diff_format=u Index: php-src/ext/soap/php_encoding.c diff -u php-src/ext/soap/php_encoding.c:1.152 php-src/ext/soap/php_encoding.c:1.153 --- php-src/ext/soap/php_encoding.c:1.152 Thu Feb 15 14:49:13 2007 +++ php-src/ext/soap/php_encoding.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ | Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_encoding.c,v 1.152 2007/02/15 14:49:13 dmitry Exp $ */ +/* $Id: php_encoding.c,v 1.153 2007/02/24 16:25:55 helly Exp $ */ #include <time.h> @@ -904,7 +904,7 @@ if (Z_TYPE_P(data) == IS_DOUBLE) { char s[256]; - sprintf(s, "%0.0f",floor(Z_DVAL_P(data))); + snprintf(s, sizeof(s), "%0.0f",floor(Z_DVAL_P(data))); xmlNodeSetContent(ret, BAD_CAST(s)); } else { zval tmp = *data; @@ -2660,12 +2660,12 @@ /* Time zone support */ #ifdef HAVE_TM_GMTOFF - sprintf(tzbuf, "%c%02d:%02d", (ta->tm_gmtoff < 0) ? '-' : '+', abs(ta->tm_gmtoff / 3600), abs( (ta->tm_gmtoff % 3600) / 60 )); + snprintf(tzbuf, sizeof(tzbuf), "%c%02d:%02d", (ta->tm_gmtoff < 0) ? '-' : '+', abs(ta->tm_gmtoff / 3600), abs( (ta->tm_gmtoff % 3600) / 60 )); #else # ifdef __CYGWIN__ - sprintf(tzbuf, "%c%02d:%02d", ((ta->tm_isdst ? _timezone - 3600:_timezone)>0)?'-':'+', abs((ta->tm_isdst ? _timezone - 3600 : _timezone) / 3600), abs(((ta->tm_isdst ? _timezone - 3600 : _timezone) % 3600) / 60)); + snprintf(tzbuf, sizeof(tzbuf), "%c%02d:%02d", ((ta->tm_isdst ? _timezone - 3600:_timezone)>0)?'-':'+', abs((ta->tm_isdst ? _timezone - 3600 : _timezone) / 3600), abs(((ta->tm_isdst ? _timezone - 3600 : _timezone) % 3600) / 60)); # else - sprintf(tzbuf, "%c%02d:%02d", ((ta->tm_isdst ? timezone - 3600:timezone)>0)?'-':'+', abs((ta->tm_isdst ? timezone - 3600 : timezone) / 3600), abs(((ta->tm_isdst ? timezone - 3600 : timezone) % 3600) / 60)); + snprintf(tzbuf, sizeof(tzbuf), "%c%02d:%02d", ((ta->tm_isdst ? timezone - 3600:timezone)>0)?'-':'+', abs((ta->tm_isdst ? timezone - 3600 : timezone) / 3600), abs(((ta->tm_isdst ? timezone - 3600 : timezone) % 3600) / 60)); # endif #endif if (strcmp(tzbuf,"+00:00") == 0) { http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_http.c?r1=1.102&r2=1.103&diff_format=u Index: php-src/ext/soap/php_http.c diff -u php-src/ext/soap/php_http.c:1.102 php-src/ext/soap/php_http.c:1.103 --- php-src/ext/soap/php_http.c:1.102 Wed Feb 21 21:11:32 2007 +++ php-src/ext/soap/php_http.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ | Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_http.c,v 1.102 2007/02/21 21:11:32 stas Exp $ */ +/* $Id: php_http.c,v 1.103 2007/02/24 16:25:55 helly Exp $ */ #include "php_soap.h" #include "ext/standard/base64.h" @@ -468,7 +468,7 @@ unsigned int ctx; PHP_MD5Init(&md5ctx); - sprintf(cnonce, "%d", php_rand_r(&ctx)); + snprintf(cnonce, sizeof(cnonce), "%d", php_rand_r(&ctx)); PHP_MD5Update(&md5ctx, (unsigned char*)cnonce, strlen(cnonce)); PHP_MD5Final(hash, &md5ctx); make_digest(cnonce, hash); http://cvs.php.net/viewvc.cgi/php-src/ext/soap/soap.c?r1=1.218&r2=1.219&diff_format=u Index: php-src/ext/soap/soap.c diff -u php-src/ext/soap/soap.c:1.218 php-src/ext/soap/soap.c:1.219 --- php-src/ext/soap/soap.c:1.218 Thu Jan 18 16:20:59 2007 +++ php-src/ext/soap/soap.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ | Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: soap.c,v 1.218 2007/01/18 16:20:59 tony2001 Exp $ */ +/* $Id: soap.c,v 1.219 2007/02/24 16:25:55 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -464,8 +464,7 @@ if (defaultEncoding[i].details.type_str) { if (defaultEncoding[i].details.ns != NULL) { char *ns_type; - ns_type = emalloc(strlen(defaultEncoding[i].details.ns) + strlen(defaultEncoding[i].details.type_str) + 2); - sprintf(ns_type, "%s:%s", defaultEncoding[i].details.ns, defaultEncoding[i].details.type_str); + spprintf(&ns_type, 0, "%s:%s", defaultEncoding[i].details.ns, defaultEncoding[i].details.type_str); zend_hash_add(&defEnc, ns_type, strlen(ns_type) + 1, &enc, sizeof(encodePtr), NULL); efree(ns_type); } else { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dns.c?r1=1.83&r2=1.84&diff_format=u Index: php-src/ext/standard/dns.c diff -u php-src/ext/standard/dns.c:1.83 php-src/ext/standard/dns.c:1.84 --- php-src/ext/standard/dns.c:1.83 Mon Jan 1 09:29:31 2007 +++ php-src/ext/standard/dns.c Sat Feb 24 16:25:55 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dns.c,v 1.83 2007/01/01 09:29:31 sebastian Exp $ */ +/* $Id: dns.c,v 1.84 2007/02/24 16:25:55 helly Exp $ */ /* {{{ includes */ #include "php.h" @@ -409,7 +409,7 @@ switch (type) { case DNS_T_A: add_ascii_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_ascii_assoc_rt_string(*subarray, "ip", name, ZSTR_DUPLICATE); cp += dlen; break; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/head.c?r1=1.94&r2=1.95&diff_format=u Index: php-src/ext/standard/head.c diff -u php-src/ext/standard/head.c:1.94 php-src/ext/standard/head.c:1.95 --- php-src/ext/standard/head.c:1.94 Mon Jan 1 09:29:31 2007 +++ php-src/ext/standard/head.c Sat Feb 24 16:25:55 2007 @@ -15,7 +15,7 @@ | Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: head.c,v 1.94 2007/01/01 09:29:31 sebastian Exp $ */ +/* $Id: head.c,v 1.95 2007/02/24 16:25:55 helly Exp $ */ #include <stdio.h> #include "php.h" @@ -94,8 +94,6 @@ 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 @@ */ 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) { strcat(cookie, "; expires="); 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); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/image.c?r1=1.128&r2=1.129&diff_format=u Index: php-src/ext/standard/image.c diff -u php-src/ext/standard/image.c:1.128 php-src/ext/standard/image.c:1.129 --- php-src/ext/standard/image.c:1.128 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/image.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: image.c,v 1.128 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: image.c,v 1.129 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" #include <stdio.h> @@ -454,7 +454,7 @@ return 0; } - sprintf(markername, "APP%d", marker - M_APP0); + snprintf(markername, sizeof(markername), "APP%d", marker - M_APP0); if (zend_ascii_hash_find(Z_ARRVAL_P(info), markername, strlen(markername)+1, (void **) &tmp) == FAILURE) { /* XXX we onyl catch the 1st tag of it's kind! */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/pack.c?r1=1.65&r2=1.66&diff_format=u Index: php-src/ext/standard/pack.c diff -u php-src/ext/standard/pack.c:1.65 php-src/ext/standard/pack.c:1.66 --- php-src/ext/standard/pack.c:1.65 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/pack.c Sat Feb 24 16:25:55 2007 @@ -15,7 +15,7 @@ | Author: Chris Schneider <cschneid@relog.ch> | +----------------------------------------------------------------------+ */ -/* $Id: pack.c,v 1.65 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: pack.c,v 1.66 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" @@ -622,10 +622,10 @@ 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) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.53&r2=1.54&diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.53 php-src/ext/standard/proc_open.c:1.54 --- php-src/ext/standard/proc_open.c:1.53 Wed Feb 14 19:20:14 2007 +++ php-src/ext/standard/proc_open.c Sat Feb 24 16:25:55 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong <wez@thebrainroom.com> | +----------------------------------------------------------------------+ */ -/* $Id: proc_open.c,v 1.53 2007/02/14 19:20:14 nlopess Exp $ */ +/* $Id: proc_open.c,v 1.54 2007/02/24 16:25:55 helly Exp $ */ #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -740,8 +740,7 @@ 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); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/scanf.c?r1=1.37&r2=1.38&diff_format=u Index: php-src/ext/standard/scanf.c diff -u php-src/ext/standard/scanf.c:1.37 php-src/ext/standard/scanf.c:1.38 --- php-src/ext/standard/scanf.c:1.37 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/scanf.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: scanf.c,v 1.37 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: scanf.c,v 1.38 2007/02/24 16:25:55 helly Exp $ */ /* scanf.c -- @@ -1562,7 +1562,7 @@ *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) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.631&r2=1.632&diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.631 php-src/ext/standard/string.c:1.632 --- php-src/ext/standard/string.c:1.631 Sat Feb 10 00:48:17 2007 +++ php-src/ext/standard/string.c Sat Feb 24 16:25:55 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.631 2007/02/10 00:48:17 tony2001 Exp $ */ +/* $Id: string.c,v 1.632 2007/02/24 16:25:55 helly Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4641,7 +4641,7 @@ 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)); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/type.c?r1=1.49&r2=1.50&diff_format=u Index: php-src/ext/standard/type.c diff -u php-src/ext/standard/type.c:1.49 php-src/ext/standard/type.c:1.50 --- php-src/ext/standard/type.c:1.49 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/type.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: type.c,v 1.49 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: type.c,v 1.50 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" #include "php_incomplete_class.h" @@ -68,8 +68,7 @@ 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); } */ http://cvs.php.net/viewvc.cgi/php-src/ext/sybase_ct/php_sybase_ct.c?r1=1.116&r2=1.117&diff_format=u Index: php-src/ext/sybase_ct/php_sybase_ct.c diff -u php-src/ext/sybase_ct/php_sybase_ct.c:1.116 php-src/ext/sybase_ct/php_sybase_ct.c:1.117 --- php-src/ext/sybase_ct/php_sybase_ct.c:1.116 Mon Jan 1 09:29:32 2007 +++ php-src/ext/sybase_ct/php_sybase_ct.c Sat Feb 24 16:25:55 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_sybase_ct.c,v 1.116 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: php_sybase_ct.c,v 1.117 2007/02/24 16:25:55 helly Exp $ */ #ifdef HAVE_CONFIG_H @@ -1006,8 +1006,7 @@ ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, sybase_link_index, id, "Sybase-Link", le_link, le_plink); convert_to_string_ex(db); - cmdbuf = (char *) emalloc(sizeof("use ")+Z_STRLEN_PP(db)+1); - sprintf(cmdbuf, "use %s", Z_STRVAL_PP(db)); /* SAFE */ + spprintf(&cmdbuf, 0, "use %s", Z_STRVAL_PP(db)); /* SAFE */ if (exec_cmd(sybase_ptr, cmdbuf)==FAILURE) { efree(cmdbuf); @@ -2121,16 +2120,16 @@ php_info_print_table_start(); php_info_print_table_header(2, "Sybase_CT Support", "enabled" ); - sprintf(buf, "%ld", SybCtG(num_persistent)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(num_persistent)); php_info_print_table_row(2, "Active Persistent Links", buf); - sprintf(buf, "%ld", SybCtG(num_links)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(num_links)); php_info_print_table_row(2, "Active Links", buf); - sprintf(buf, "%ld", SybCtG(min_server_severity)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(min_server_severity)); php_info_print_table_row(2, "Min server severity", buf); - sprintf(buf, "%ld", SybCtG(min_client_severity)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(min_client_severity)); php_info_print_table_row(2, "Min client severity", buf); php_info_print_table_row(2, "Application Name", SybCtG(appname)); - sprintf(buf, "%ld", SybCtG(deadlock_retry_count)); + snprintf(buf, sizeof(buf), "%ld", SybCtG(deadlock_retry_count)); php_info_print_table_row(2, "Deadlock retry count", buf); php_info_print_table_end(); http://cvs.php.net/viewvc.cgi/php-src/ext/wddx/wddx.c?r1=1.143&r2=1.144&diff_format=u Index: php-src/ext/wddx/wddx.c diff -u php-src/ext/wddx/wddx.c:1.143 php-src/ext/wddx/wddx.c:1.144 --- php-src/ext/wddx/wddx.c:1.143 Thu Jan 18 16:21:00 2007 +++ php-src/ext/wddx/wddx.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: wddx.c,v 1.143 2007/01/18 16:21:00 tony2001 Exp $ */ +/* $Id: wddx.c,v 1.144 2007/02/24 16:25:55 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -285,7 +285,7 @@ switch (hash_type) { case HASH_KEY_IS_LONG: - key_length = sprintf(tmp, "%ld", idx) + 1; + key_length = snprintf(tmp, sizeof(tmp), "%ld", idx) + 1; key = tmp; /* fallthru */ case HASH_KEY_IS_STRING: @@ -410,7 +410,7 @@ { char tmp_buf[WDDX_BUF_LEN]; - sprintf(tmp_buf, WDDX_BOOLEAN, Z_LVAL_P(var) ? "true" : "false"); + snprintf(tmp_buf, sizeof(tmp_buf), WDDX_BOOLEAN, Z_LVAL_P(var) ? "true" : "false"); php_wddx_add_chunk(packet, tmp_buf); } /* }}} */ @@ -502,7 +502,7 @@ 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 = sprintf(tmp_buf, "%ld", idx); + key_len = snprintf(tmp_buf, sizeof(tmp_buf), "%ld", idx); php_wddx_serialize_var(packet, *ent, tmp_buf, key_len TSRMLS_CC); } } @@ -557,7 +557,7 @@ if (is_struct) { php_wddx_add_chunk_static(packet, WDDX_STRUCT_S); } else { - sprintf(tmp_buf, WDDX_ARRAY_S, zend_hash_num_elements(target_hash)); + snprintf(tmp_buf, sizeof(tmp_buf), WDDX_ARRAY_S, zend_hash_num_elements(target_hash)); php_wddx_add_chunk(packet, tmp_buf); } @@ -573,7 +573,7 @@ if (ent_type == HASH_KEY_IS_STRING) { php_wddx_serialize_var(packet, *ent, key, key_len TSRMLS_CC); } else { - key_len = sprintf(tmp_buf, "%ld", idx); + key_len = snprintf(tmp_buf, sizeof(tmp_buf), "%ld", idx); php_wddx_serialize_var(packet, *ent, tmp_buf, key_len TSRMLS_CC); } } else @@ -725,7 +725,7 @@ if (!strcmp(atts[i], EL_CHAR_CODE) && atts[++i] && atts[i][0]) { char tmp_buf[2]; - sprintf(tmp_buf, "%c", (char)strtol(atts[i], NULL, 16)); + snprintf(tmp_buf, sizeof(tmp_buf), "%c", (char)strtol(atts[i], NULL, 16)); php_wddx_process_data(user_data, tmp_buf, strlen(tmp_buf)); break; } http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_close.c?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/zip/lib/zip_close.c diff -u php-src/ext/zip/lib/zip_close.c:1.3 php-src/ext/zip/lib/zip_close.c:1.4 --- php-src/ext/zip/lib/zip_close.c:1.3 Mon Jan 1 09:29:34 2007 +++ php-src/ext/zip/lib/zip_close.c Sat Feb 24 16:25:55 2007 @@ -535,7 +535,7 @@ return NULL; } - sprintf(temp, "%s.XXXXXX", za->zn); + snprintf(temp, sizeof(temp), "%s.XXXXXX", za->zn); if ((tfd=mkstemp(temp)) == -1) { _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_error_strerror.c?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/zip/lib/zip_error_strerror.c diff -u php-src/ext/zip/lib/zip_error_strerror.c:1.2 php-src/ext/zip/lib/zip_error_strerror.c:1.3 --- php-src/ext/zip/lib/zip_error_strerror.c:1.2 Mon Jan 1 09:29:34 2007 +++ php-src/ext/zip/lib/zip_error_strerror.c Sat Feb 24 16:25:55 2007 @@ -54,7 +54,7 @@ _zip_error_fini(err); if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) { - sprintf(buf, "Unknown error %d", err->zip_err); + snprintf(buf, sizeof(buf), "Unknown error %d", err->zip_err); zs = NULL; ss = buf; } @@ -78,11 +78,11 @@ if (ss == NULL) return zs; else { - if ((s=(char *)malloc(strlen(ss) - + (zs ? strlen(zs)+2 : 0) + 1)) == NULL) + int l = strlen(ss) + (zs ? strlen(zs)+2 : 0) + 1; + if ((s=(char *)malloc(l)) == NULL) return _zip_err_str[ZIP_ER_MEMORY]; - sprintf(s, "%s%s%s", + snprintf(s, l, "%s%s%s", (zs ? zs : ""), (zs ? ": " : ""), ss); http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?r1=1.190&r2=1.191&diff_format=u Index: php-src/main/fopen_wrappers.c diff -u php-src/main/fopen_wrappers.c:1.190 php-src/main/fopen_wrappers.c:1.191 --- php-src/main/fopen_wrappers.c:1.190 Fri Jan 12 14:34:46 2007 +++ php-src/main/fopen_wrappers.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c,v 1.190 2007/01/12 14:34:46 bjori Exp $ */ +/* $Id: fopen_wrappers.c,v 1.191 2007/02/24 16:25:55 helly Exp $ */ /* {{{ includes */ @@ -305,13 +305,10 @@ pw = getpwnam(user); #endif if (pw && pw->pw_dir) { - filename = emalloc(strlen(PG(user_dir)) + strlen(path_info) + strlen(pw->pw_dir) + 4); - if (filename) { - sprintf(filename, "%s%c%s%c%s", pw->pw_dir, PHP_DIR_SEPARATOR, + spprintf(&filename, 0, "%s%c%s%c%s", pw->pw_dir, PHP_DIR_SEPARATOR, PG(user_dir), PHP_DIR_SEPARATOR, s+1); /* Safe */ - STR_FREE(SG(request_info).path_translated); - SG(request_info).path_translated = filename; - } + STR_FREE(SG(request_info).path_translated); + SG(request_info).path_translated = filename; } #if defined(ZTS) && defined(HAVE_GETPWNAM_R) && defined(_SC_GETPW_R_SIZE_MAX) efree(pwbuf); http://cvs.php.net/viewvc.cgi/php-src/main/php_ini.c?r1=1.147&r2=1.148&diff_format=u Index: php-src/main/php_ini.c diff -u php-src/main/php_ini.c:1.147 php-src/main/php_ini.c:1.148 --- php-src/main/php_ini.c:1.147 Mon Jan 1 09:29:35 2007 +++ php-src/main/php_ini.c Sat Feb 24 16:25:55 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ini.c,v 1.147 2007/01/01 09:29:35 sebastian Exp $ */ +/* $Id: php_ini.c,v 1.148 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" #include "ext/standard/info.h" @@ -438,8 +438,8 @@ /* Search php-%sapi-module-name%.ini file in search path */ if (!fh.handle.fp) { const char *fmt = "php-%s.ini"; - char *ini_fname = emalloc(strlen(fmt) + strlen(sapi_module.name)); - sprintf(ini_fname, fmt, sapi_module.name); + char *ini_fname; + spprintf(&ini_fname, 0, fmt, sapi_module.name); fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); efree(ini_fname); if (fh.handle.fp) { http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.189&r2=1.190&diff_format=u Index: php-src/main/rfc1867.c diff -u php-src/main/rfc1867.c:1.189 php-src/main/rfc1867.c:1.190 --- php-src/main/rfc1867.c:1.189 Mon Jan 1 09:29:35 2007 +++ php-src/main/rfc1867.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: rfc1867.c,v 1.189 2007/01/01 09:29:35 sebastian Exp $ */ +/* $Id: rfc1867.c,v 1.190 2007/02/24 16:25:55 helly Exp $ */ /* * This product includes software developed by the Apache Group @@ -475,12 +475,9 @@ self->buffer = (char *) ecalloc(1, minsize + 1); self->bufsize = minsize; - self->boundary = (char *) ecalloc(1, boundary_len + 3); - sprintf(self->boundary, "--%s", boundary); + spprintf(&self->boundary, 0, "--%s", boundary); - self->boundary_next = (char *) ecalloc(1, boundary_len + 4); - sprintf(self->boundary_next, "\n--%s", boundary); - self->boundary_next_len = boundary_len + 3; + self->boundary_next_len = spprintf(&self->boundary_next, 0, "\n--%s", boundary); self->buf_begin = self->buffer; self->bytes_in_buffer = 0; @@ -1015,6 +1012,7 @@ U_STRING_DECL(filename_key, "filename", 8); U_STRING_DECL(maxfilesize_key, "MAX_FILE_SIZE", 13); static zend_bool did_string_init = FALSE; + int llen = 0; if (SG(request_info).content_length > SG(post_max_size)) { sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size)); @@ -1322,14 +1320,15 @@ if (lbuf) { efree(lbuf); } - lbuf = eumalloc(u_strlen(param) + MAX_SIZE_OF_INDEX + 1); + llen = u_strlen(param) + MAX_SIZE_OF_INDEX + 1; + lbuf = eumalloc(llen); if (is_arr_upload) { if (abuf) efree(abuf); abuf = eustrndup(param, u_strlen(param)-array_len); - u_sprintf(lbuf, "%S_name[%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S_name[%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S_name", param); + u_snprintf(lbuf, llen, "%S_name", param); } /* The \ check should technically be needed for win32 systems only where @@ -1353,9 +1352,9 @@ /* Add $foo[name] */ if (is_arr_upload) { - u_sprintf(lbuf, "%S[name][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[name][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[name]", param); + u_snprintf(lbuf, llen, "%S[name]", param); } if (s && s > filename) { register_u_http_post_files_variable(lbuf, s+1, u_strlen(s+1), http_post_files, 0 TSRMLS_CC); @@ -1383,9 +1382,9 @@ /* Add $foo_type */ if (is_arr_upload) { - u_sprintf(lbuf, "%S_type[%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S_type[%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S_type", param); + u_snprintf(lbuf, llen, "%S_type", param); } if (!is_anonymous) { safe_u_php_register_variable(lbuf, ucd, ucd_len, NULL, 0 TSRMLS_CC); @@ -1393,9 +1392,9 @@ /* Add $foo[type] */ if (is_arr_upload) { - u_sprintf(lbuf, "%S[type][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[type][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[type]", param); + u_snprintf(lbuf, llen, "%S[type]", param); } register_u_http_post_files_variable(lbuf, ucd, ucd_len, http_post_files, 0 TSRMLS_CC); @@ -1417,9 +1416,9 @@ /* Add $foo[tmp_name] */ if (is_arr_upload) { - u_sprintf(lbuf, "%S[tmp_name][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[tmp_name][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[tmp_name]", param); + u_snprintf(lbuf, llen, "%S[tmp_name]", param); } add_u_protected_variable(lbuf TSRMLS_CC); register_u_http_post_files_variable(lbuf, temp_filename, u_strlen(temp_filename), http_post_files, 1 TSRMLS_CC); @@ -1440,17 +1439,17 @@ } if (is_arr_upload) { - u_sprintf(lbuf, "%S[error][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[error][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[error]", param); + u_snprintf(lbuf, llen, "%S[error]", param); } register_u_http_post_files_variable_ex(lbuf, &error_type, http_post_files, 0 TSRMLS_CC); /* Add $foo_size */ if (is_arr_upload) { - u_sprintf(lbuf, "%S_size[%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S_size[%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S_size", param); + u_snprintf(lbuf, llen, "%S_size", param); } if (!is_anonymous) { safe_u_php_register_variable_ex(lbuf, &file_size, NULL, 0 TSRMLS_CC); @@ -1458,9 +1457,9 @@ /* Add $foo[size] */ if (is_arr_upload) { - u_sprintf(lbuf, "%S[size][%S]", abuf, array_index); + u_snprintf(lbuf, llen, "%S[size][%S]", abuf, array_index); } else { - u_sprintf(lbuf, "%S[size]", param); + u_snprintf(lbuf, llen, "%S[size]", param); } register_u_http_post_files_variable_ex(lbuf, &file_size, http_post_files, 0 TSRMLS_CC); } @@ -1487,6 +1486,7 @@ zval *array_ptr = (zval *) arg; int fd=-1; zend_llist header; + int llen = 0; if (SG(request_info).content_length > SG(post_max_size)) { sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size)); @@ -1768,14 +1768,15 @@ if (lbuf) { efree(lbuf); } - lbuf = (char *) emalloc(strlen(param) + MAX_SIZE_OF_INDEX + 1); + llen = strlen(param) + MAX_SIZE_OF_INDEX + 1; + lbuf = (char *) emalloc(llen); if (is_arr_upload) { if (abuf) efree(abuf); abuf = estrndup(param, strlen(param)-array_len); - sprintf(lbuf, "%s_name[%s]", abuf, array_index); + snprintf(lbuf, llen, "%s_name[%s]", abuf, array_index); } else { - sprintf(lbuf, "%s_name", param); + snprintf(lbuf, llen, "%s_name", param); } #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING) @@ -1824,9 +1825,9 @@ /* Add $foo[name] */ if (is_arr_upload) { - sprintf(lbuf, "%s[name][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[name][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[name]", param); + snprintf(lbuf, llen, "%s[name]", param); } if (s && s > filename) { register_http_post_files_variable(lbuf, s+1, http_post_files, 0 TSRMLS_CC); @@ -1849,9 +1850,9 @@ /* Add $foo_type */ if (is_arr_upload) { - sprintf(lbuf, "%s_type[%s]", abuf, array_index); + snprintf(lbuf, llen, "%s_type[%s]", abuf, array_index); } else { - sprintf(lbuf, "%s_type", param); + snprintf(lbuf, llen, "%s_type", param); } if (!is_anonymous) { safe_php_register_variable(lbuf, cd, strlen(cd), NULL, 0 TSRMLS_CC); @@ -1859,9 +1860,9 @@ /* Add $foo[type] */ if (is_arr_upload) { - sprintf(lbuf, "%s[type][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[type][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[type]", param); + snprintf(lbuf, llen, "%s[type]", param); } register_http_post_files_variable(lbuf, cd, http_post_files, 0 TSRMLS_CC); @@ -1881,9 +1882,9 @@ /* Add $foo[tmp_name] */ if (is_arr_upload) { - sprintf(lbuf, "%s[tmp_name][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[tmp_name][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[tmp_name]", param); + snprintf(lbuf, llen, "%s[tmp_name]", param); } add_protected_variable(lbuf TSRMLS_CC); register_http_post_files_variable(lbuf, temp_filename, http_post_files, 1 TSRMLS_CC); @@ -1904,17 +1905,17 @@ } if (is_arr_upload) { - sprintf(lbuf, "%s[error][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[error][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[error]", param); + snprintf(lbuf, llen, "%s[error]", param); } register_http_post_files_variable_ex(lbuf, &error_type, http_post_files, 0 TSRMLS_CC); /* Add $foo_size */ if (is_arr_upload) { - sprintf(lbuf, "%s_size[%s]", abuf, array_index); + snprintf(lbuf, llen, "%s_size[%s]", abuf, array_index); } else { - sprintf(lbuf, "%s_size", param); + snprintf(lbuf, llen, "%s_size", param); } if (!is_anonymous) { safe_php_register_variable_ex(lbuf, &file_size, NULL, 0 TSRMLS_CC); @@ -1922,9 +1923,9 @@ /* Add $foo[size] */ if (is_arr_upload) { - sprintf(lbuf, "%s[size][%s]", abuf, array_index); + snprintf(lbuf, llen, "%s[size][%s]", abuf, array_index); } else { - sprintf(lbuf, "%s[size]", param); + snprintf(lbuf, llen, "%s[size]", param); } register_http_post_files_variable_ex(lbuf, &file_size, http_post_files, 0 TSRMLS_CC); } http://cvs.php.net/viewvc.cgi/php-src/sapi/nsapi/nsapi.c?r1=1.77&r2=1.78&diff_format=u Index: php-src/sapi/nsapi/nsapi.c diff -u php-src/sapi/nsapi/nsapi.c:1.77 php-src/sapi/nsapi/nsapi.c:1.78 --- php-src/sapi/nsapi/nsapi.c:1.77 Mon Jan 1 09:29:36 2007 +++ php-src/sapi/nsapi/nsapi.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: nsapi.c,v 1.77 2007/01/01 09:29:36 sebastian Exp $ */ +/* $Id: nsapi.c,v 1.78 2007/02/24 16:25:55 helly Exp $ */ /* * PHP includes @@ -310,7 +310,7 @@ PHP_MINFO_FUNCTION(nsapi) { php_info_print_table_start(); - php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.77 $"); + php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.78 $"); php_info_print_table_row(2, "Server Software", system_version()); php_info_print_table_row(2, "Sub-requests with nsapi_virtual()", (nsapi_servact_service)?((zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0))?"not supported with zlib.output_compression":"enabled"):"not supported on this platform" ); @@ -638,7 +638,7 @@ nsapi_free(value); } - sprintf(buf, "%d", conf_getglobals()->Vport); + snprintf(buf, sizeof(buf), "%d", conf_getglobals()->Vport); php_register_variable("SERVER_PORT", buf, track_vars_array TSRMLS_CC); php_register_variable("SERVER_NAME", conf_getglobals()->Vserver_hostname, track_vars_array TSRMLS_CC); @@ -691,7 +691,7 @@ /* special variables in error mode */ if (rc->http_error) { - sprintf(buf, "%d", rc->http_error); + snprintf(buf, sizeof(buf), "%d", rc->http_error); php_register_variable("ERROR_TYPE", buf, track_vars_array TSRMLS_CC); } } http://cvs.php.net/viewvc.cgi/php-src/sapi/tux/php_tux.c?r1=1.28&r2=1.29&diff_format=u Index: php-src/sapi/tux/php_tux.c diff -u php-src/sapi/tux/php_tux.c:1.28 php-src/sapi/tux/php_tux.c:1.29 --- php-src/sapi/tux/php_tux.c:1.28 Mon Jan 1 09:29:37 2007 +++ php-src/sapi/tux/php_tux.c Sat Feb 24 16:25:55 2007 @@ -116,7 +116,7 @@ status_line = malloc(30); /* safe sprintf use */ - len = sprintf(status_line, "HTTP/1.1 %d NA\r\n", SG(sapi_headers).http_response_code); + len = snprintf(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 @@ sapi_header_line ctr = {0}; ctr.line = buf; - ctr.line_len = sprintf(buf, "Server: %s", TUXAPI_version); + ctr.line_len = snprintf(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); @@ -215,7 +215,7 @@ ADD_STRING("REMOTE_HOST"); } - sprintf(buf, "%d", CGI_SERVER_PORT(TG(req))); + snprintf(buf, sizeof(buf), "%d", CGI_SERVER_PORT(TG(req))); ADD_STRING("SERVER_PORT"); #if 0 @@ -241,7 +241,7 @@ #if 0 if (TG(hc)->contentlength != -1) { - sprintf(buf, "%ld", (long) TG(hc)->contentlength); + snprintf(buf, sizeof(buf), "%ld", (long) TG(hc)->contentlength); ADD_STRING("CONTENT_LENGTH"); } #endif http://cvs.php.net/viewvc.cgi/php-src/win32/registry.c?r1=1.18&r2=1.19&diff_format=u Index: php-src/win32/registry.c diff -u php-src/win32/registry.c:1.18 php-src/win32/registry.c:1.19 --- php-src/win32/registry.c:1.18 Fri Nov 10 11:42:40 2006 +++ php-src/win32/registry.c Sat Feb 24 16:25:55 2007 @@ -217,8 +217,7 @@ while (*cwd == '\\' || *cwd == '/') { cwd++; } - path = (char *) emalloc(2+strlen(cwd)+1+strlen(orig_path)+1); - sprintf(path, "%c\\%s\\%s", drive_letter, cwd, orig_path); + spprintf(&path, 0, "%c\\%s\\%s", drive_letter, cwd, orig_path); efree(orig_path); orig_path = path; } http://cvs.php.net/viewvc.cgi/php-src/win32/sendmail.c?r1=1.68&r2=1.69&diff_format=u Index: php-src/win32/sendmail.c diff -u php-src/win32/sendmail.c:1.68 php-src/win32/sendmail.c:1.69 --- php-src/win32/sendmail.c:1.68 Mon Jan 1 09:29:37 2007 +++ php-src/win32/sendmail.c Sat Feb 24 16:25:55 2007 @@ -17,7 +17,7 @@ * */ -/* $Id: sendmail.c,v 1.68 2007/01/01 09:29:37 sebastian Exp $ */ +/* $Id: sendmail.c,v 1.69 2007/02/24 16:25:55 helly Exp $ */ #include "php.h" /*php specific */ #include <stdio.h> @@ -405,7 +405,7 @@ return (BAD_MSG_DESTINATION); */ - sprintf(Buffer, "HELO %s\r\n", LocalHost); + snprintf(Buffer, sizeof(Buffer), "HELO %s\r\n", LocalHost); /* in the beggining of the dialog */ /* attempt reconnect if the first Post fail */ @@ -699,16 +699,13 @@ } } - if (NULL == (header_buffer = ecalloc(1, MAIL_BUFFER_SIZE))) { - efree(headers_lc); - return OUT_OF_MEMORY; - } + header_buffer = ecalloc(1, MAIL_BUFFER_SIZE); if (!xheaders || !strstr(headers_lc, "date:")) { time_t tNow = time(NULL); char *dt = php_format_date("r", 1, tNow, 1 TSRMLS_CC); - sprintf(header_buffer, "Date: %s\r\n", dt); + snprintf(header_buffer, MAIL_BUFFER_SIZE, "Date: %s\r\n", dt); efree(dt); }