pierrick                                 Mon, 08 Aug 2011 03:08:59 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=314457

Log:
Use snprintf and strncat to make the static analyzers happy

Changed paths:
    U   php/php-src/branches/PHP_5_3/Zend/zend.c
    U   php/php-src/branches/PHP_5_4/Zend/zend.c
    U   php/php-src/trunk/Zend/zend.c

Modified: php/php-src/branches/PHP_5_3/Zend/zend.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend.c    2011-08-08 02:33:03 UTC (rev 
314456)
+++ php/php-src/branches/PHP_5_3/Zend/zend.c    2011-08-08 03:08:59 UTC (rev 
314457)
@@ -821,7 +821,7 @@
        char *new_info;
        uint new_info_length;

-       new_info_length = sizeof("    with  v,  by \n")
+       new_info_length = sizeof("    with  v, , by \n")
                                                + strlen(extension->name)
                                                + strlen(extension->version)
                                                + strlen(extension->copyright)
@@ -829,10 +829,10 @@

        new_info = (char *) malloc(new_info_length + 1);

-       sprintf(new_info, "    with %s v%s, %s, by %s\n", extension->name, 
extension->version, extension->copyright, extension->author);
+       snprintf(new_info, new_info_length, "    with %s v%s, %s, by %s\n", 
extension->name, extension->version, extension->copyright, extension->author);

        zend_version_info = (char *) realloc(zend_version_info, 
zend_version_info_length+new_info_length + 1);
-       strcat(zend_version_info, new_info);
+       strncat(zend_version_info, new_info, new_info_length);
        zend_version_info_length += new_info_length;
        free(new_info);
 }

Modified: php/php-src/branches/PHP_5_4/Zend/zend.c
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/zend.c    2011-08-08 02:33:03 UTC (rev 
314456)
+++ php/php-src/branches/PHP_5_4/Zend/zend.c    2011-08-08 03:08:59 UTC (rev 
314457)
@@ -870,7 +870,7 @@
        char *new_info;
        uint new_info_length;

-       new_info_length = sizeof("    with  v,  by \n")
+       new_info_length = sizeof("    with  v, , by \n")
                                                + strlen(extension->name)
                                                + strlen(extension->version)
                                                + strlen(extension->copyright)
@@ -878,10 +878,10 @@

        new_info = (char *) malloc(new_info_length + 1);

-       sprintf(new_info, "    with %s v%s, %s, by %s\n", extension->name, 
extension->version, extension->copyright, extension->author);
+       snprintf(new_info, new_info_length, "    with %s v%s, %s, by %s\n", 
extension->name, extension->version, extension->copyright, extension->author);

        zend_version_info = (char *) realloc(zend_version_info, 
zend_version_info_length+new_info_length + 1);
-       strcat(zend_version_info, new_info);
+       strncat(zend_version_info, new_info, new_info_length);
        zend_version_info_length += new_info_length;
        free(new_info);
 }

Modified: php/php-src/trunk/Zend/zend.c
===================================================================
--- php/php-src/trunk/Zend/zend.c       2011-08-08 02:33:03 UTC (rev 314456)
+++ php/php-src/trunk/Zend/zend.c       2011-08-08 03:08:59 UTC (rev 314457)
@@ -870,7 +870,7 @@
        char *new_info;
        uint new_info_length;

-       new_info_length = sizeof("    with  v,  by \n")
+       new_info_length = sizeof("    with  v, , by \n")
                                                + strlen(extension->name)
                                                + strlen(extension->version)
                                                + strlen(extension->copyright)
@@ -878,10 +878,10 @@

        new_info = (char *) malloc(new_info_length + 1);

-       sprintf(new_info, "    with %s v%s, %s, by %s\n", extension->name, 
extension->version, extension->copyright, extension->author);
+       snprintf(new_info, new_info_length, "    with %s v%s, %s, by %s\n", 
extension->name, extension->version, extension->copyright, extension->author);

        zend_version_info = (char *) realloc(zend_version_info, 
zend_version_info_length+new_info_length + 1);
-       strcat(zend_version_info, new_info);
+       strncat(zend_version_info, new_info, new_info_length);
        zend_version_info_length += new_info_length;
        free(new_info);
 }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to