diff options
author | Denis Vlasenko | 2008-03-28 02:24:59 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-03-28 02:24:59 +0000 |
commit | c4523c2b3da206312ed0b007a46eace58659ec31 (patch) | |
tree | 5d4f169b7de1d73e7948f2bf8ecad79df2f18c6b /networking | |
parent | 2570b2e5759e8ac32b0922d71056bd426caae9f1 (diff) | |
download | busybox-c4523c2b3da206312ed0b007a46eace58659ec31.zip busybox-c4523c2b3da206312ed0b007a46eace58659ec31.tar.gz |
fix a few stray unguarded strdup's
Diffstat (limited to 'networking')
-rw-r--r-- | networking/httpd.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 5e6037c..b4a8d27 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -800,7 +800,7 @@ static char *encodeString(const char *string) /* * Given a URL encoded string, convert it to plain ascii. * Since decoding always makes strings smaller, the decode is done in-place. - * Thus, callers should strdup() the argument if they do not want the + * Thus, callers should xstrdup() the argument if they do not want the * argument modified. The return is the original pointer, allowing this * function to be easily used as arguments to other functions. * @@ -1725,9 +1725,7 @@ static int checkPerm(const char *path, const char *request) if (strcmp(p, request) == 0) { set_remoteuser_var: - remoteuser = strdup(request); - if (remoteuser) - remoteuser[u - request] = '\0'; + remoteuser = xstrndup(request, u - request); return 1; /* Ok */ } /* unauthorized */ @@ -1990,13 +1988,13 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) #endif #if ENABLE_FEATURE_HTTPD_CGI else if (STRNCASECMP(iobuf, "Cookie:") == 0) { - cookie = strdup(skip_whitespace(iobuf + sizeof("Cookie:")-1)); + cookie = xstrdup(skip_whitespace(iobuf + sizeof("Cookie:")-1)); } else if (STRNCASECMP(iobuf, "Content-Type:") == 0) { - content_type = strdup(skip_whitespace(iobuf + sizeof("Content-Type:")-1)); + content_type = xstrdup(skip_whitespace(iobuf + sizeof("Content-Type:")-1)); } else if (STRNCASECMP(iobuf, "Referer:") == 0) { - referer = strdup(skip_whitespace(iobuf + sizeof("Referer:")-1)); + referer = xstrdup(skip_whitespace(iobuf + sizeof("Referer:")-1)); } else if (STRNCASECMP(iobuf, "User-Agent:") == 0) { - user_agent = strdup(skip_whitespace(iobuf + sizeof("User-Agent:")-1)); + user_agent = xstrdup(skip_whitespace(iobuf + sizeof("User-Agent:")-1)); } #endif #if ENABLE_FEATURE_HTTPD_BASIC_AUTH @@ -2377,7 +2375,7 @@ int httpd_main(int argc ATTRIBUTE_UNUSED, char **argv) * Besides, it is also smaller. */ { char *p = getenv("PATH"); - /* env strings themself are not freed, no need to strdup(p): */ + /* env strings themself are not freed, no need to xstrdup(p): */ clearenv(); if (p) putenv(p - 5); |