summaryrefslogtreecommitdiff
path: root/ext/standard/url_scanner.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-02-22 00:25:38 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-02-22 00:25:38 +0000
commit06e5bc9ea28968876cf84e0992b71b4b35e4820b (patch)
tree9aa6e423779fbb7fc5bb651321ab597893c9fe49 /ext/standard/url_scanner.c
parente1fe2c9165dd064eeba4cc27abd9f6f46abae734 (diff)
downloadphp-git-06e5bc9ea28968876cf84e0992b71b4b35e4820b.tar.gz
strcpy() elimination
Diffstat (limited to 'ext/standard/url_scanner.c')
-rw-r--r--ext/standard/url_scanner.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/ext/standard/url_scanner.c b/ext/standard/url_scanner.c
index 29b37e3ee6..8c4d425c92 100644
--- a/ext/standard/url_scanner.c
+++ b/ext/standard/url_scanner.c
@@ -50,35 +50,24 @@ int php_url_scanner_deactivate(TSRMLS_D)
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(flag && !strstr(val,buf) && !strchr(val,':')) {
+ char *result;
+ TSRMLS_FETCH();
- 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;
- }
+ spprintf(&result, 0, "%s%s", (strchr(val,'?') ? PG(arg_separator).output : "?"), buf);
+ return result;
}
return NULL;
}
@@ -230,7 +219,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
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 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
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 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
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 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
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 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
maxl+=l;
out=realloc(out,maxl);
outp=out+*newlen;
- strcpy(outp,p);
+ strlcpy(outp,p,maxl);
outp+=l;
*newlen+=l;
efree(p);