add some error checking to switch_url_encode function

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4188 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-02-09 22:56:42 +00:00
parent 712976653d
commit c1cf282d39
1 changed files with 9 additions and 0 deletions

View File

@ -599,7 +599,16 @@ SWITCH_DECLARE(size_t) switch_url_encode(char *url, char *buf, size_t len)
const char urlunsafe[] = "\r\n \"#%&+:;<=>?@[\\]^`{|}";
const char hex[] = "0123456789ABCDEF";
if (!buf) {
return 0;
}
memset(buf, 0, len);
if (!url) {
return 0;
}
for( p = url ; *p ; p++) {
if (*p < ' ' || *p > '~' || strchr(urlunsafe, *p)) {
if ((x + 3) > len) {