diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-07 18:38:38 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-07 18:38:38 +0200 |
commit | e16d7dddf1ef1df0c8a00f01fede497521134b74 (patch) | |
tree | 00463bb8d046e99c9d4f4b87c189c347a4bb96c0 /src/input/input_http.c | |
parent | 657a953d5d2807ed99eddf7b45a4dc46cef626d5 (diff) | |
download | xine-lib-e16d7dddf1ef1df0c8a00f01fede497521134b74.tar.gz xine-lib-e16d7dddf1ef1df0c8a00f01fede497521134b74.tar.bz2 |
Replace strn?cpy() + strn?cat() calls with a?sprintf().
Instead of creating strings through a series os string copy and
concatenations, use directly the appropriate printf-like function.
Diffstat (limited to 'src/input/input_http.c')
-rw-r--r-- | src/input/input_http.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/input/input_http.c b/src/input/input_http.c index 0e9345731..3b091e7cb 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -235,26 +235,16 @@ static int http_plugin_basicauth (const char *user, const char *password, char* char *tmp; char *sptr; char *dptr; - int totlen; + size_t count; int enclen; - int count; - totlen = strlen (user) + 1; - if(password != NULL) - totlen += strlen (password); - - enclen = ((totlen + 2) / 3 ) * 4 + 1; + count = asprintf(&tmp, "%s:%s", user, (password != NULL) ? password : ""); + + enclen = ((count + 2) / 3 ) * 4 + 1; if (len < enclen) return -1; - - tmp = malloc (sizeof(char) * (totlen + 1)); - strcpy (tmp, user); - strcat (tmp, ":"); - if (password != NULL) - strcat (tmp, password); - - count = strlen(tmp); + sptr = tmp; dptr = dest; while (count >= 3) { |