iliaa           Thu Feb 22 00:25:38 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/standard       url_scanner.c 
  Log:
  
  strcpy() elimination
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url_scanner.c?r1=1.44.2.1.2.1&r2=1.44.2.1.2.2&diff_format=u
Index: php-src/ext/standard/url_scanner.c
diff -u php-src/ext/standard/url_scanner.c:1.44.2.1.2.1 
php-src/ext/standard/url_scanner.c:1.44.2.1.2.2
--- php-src/ext/standard/url_scanner.c:1.44.2.1.2.1     Mon Jan  1 09:36:09 2007
+++ php-src/ext/standard/url_scanner.c  Thu Feb 22 00:25:38 2007
@@ -15,7 +15,7 @@
    | Author: Hartmut Holzgraefe <[EMAIL PROTECTED]>                        |
    +----------------------------------------------------------------------+
  */
-/* $Id: url_scanner.c,v 1.44.2.1.2.1 2007/01/01 09:36:09 sebastian Exp $ */
+/* $Id: url_scanner.c,v 1.44.2.1.2.2 2007/02/22 00:25:38 iliaa Exp $ */
 
 #include "php.h"
 
@@ -50,35 +50,24 @@
 static char *url_attr_addon(const char *tag,const char *attr,const char 
*val,const char *buf)
 {
        int flag = 0;
-       TSRMLS_FETCH();
 
-       if(!strcasecmp(tag,"a") && !strcasecmp(attr,"href")) {
+       if (!strcasecmp(tag,"a") && !strcasecmp(attr,"href")) {
                flag = 1;
-       } else if(!strcasecmp(tag,"area" ) && !strcasecmp(attr,"href"   )) {
+       } else if (!strcasecmp(tag,"area" ) && !strcasecmp(attr,"href"   )) {
                flag = 1;
-       } else if(!strcasecmp(tag,"form" ) && !strcasecmp(attr,"action" )) {
+       } else if (!strcasecmp(tag,"form" ) && !strcasecmp(attr,"action" )) {
                flag = 1;
-       } else if(!strcasecmp(tag,"frame") && !strcasecmp(attr,"source" )) {
+       } else if (!strcasecmp(tag,"frame") && !strcasecmp(attr,"source" )) {
                flag = 1;
-       } else if(!strcasecmp(tag,"img"  ) && !strcasecmp(attr,"action" )) {
+       } else if (!strcasecmp(tag,"img"  ) && !strcasecmp(attr,"action" )) {
                flag = 1;
        }
-       if(flag) {              
-               if(!strstr(val,buf)&&!strchr(val,':'))
-                       {
-                               char *result = (char 
*)emalloc(strlen(buf)+strlen(PG(arg_separator).output)+1);
-                               int n;
-
-                               if(strchr(val,'?')) {
-                                       strcpy(result,PG(arg_separator).output);
-                                       n=strlen(PG(arg_separator).output);
-                               } else {
-                                       *result='?';
-                                       n=1;
-                               }
-                               strcpy(result+n,buf);
-                               return result;
-                       }
+       if(flag && !strstr(val,buf) && !strchr(val,':')) {
+               char *result;
+               TSRMLS_FETCH();
+
+               spprintf(&result, 0, "%s%s", (strchr(val,'?') ? 
PG(arg_separator).output : "?"), buf);
+               return result;
        } 
        return NULL;
 }
@@ -230,7 +219,7 @@
                                                maxl+=l;
                                                out=realloc(out,maxl);
                                                outp=out+*newlen;
-                                               strcpy(outp,p);
+                                               strlcpy(outp, p, maxl);
                                                outp+=l;
                                                *newlen+=l;
                                                efree(p);
@@ -265,7 +254,7 @@
                                                maxl+=l;
                                                out=realloc(out,maxl);
                                                outp=out+*newlen;
-                                               strcpy(outp,p);
+                                               strlcpy(outp,p,maxl);
                                                outp+=l;
                                                *newlen+=l;
                                                efree(p);
@@ -282,7 +271,7 @@
                                                maxl+=l;
                                                out=realloc(out,maxl);
                                                outp=out+*newlen;
-                                               strcpy(outp,p);
+                                               strlcpy(outp,p,maxl);
                                                outp+=l;
                                                *newlen+=l;
                                                efree(p);
@@ -329,7 +318,7 @@
                                                maxl+=l;
                                                out=realloc(out,maxl);
                                                outp=out+*newlen;
-                                               strcpy(outp,p);
+                                               strlcpy(outp,p,maxl);
                                                outp+=l;
                                                *newlen+=l;
                                                efree(p);
@@ -346,7 +335,7 @@
                                                maxl+=l;
                                                out=realloc(out,maxl);
                                                outp=out+*newlen;
-                                               strcpy(outp,p);
+                                               strlcpy(outp,p,maxl);
                                                outp+=l;
                                                *newlen+=l;
                                                efree(p);

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

Reply via email to