/*
* 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.
*
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 */
/* Try and do our best to parse more lines */
if ((STRNCASECMP(iobuf, "Content-length:") == 0)) {
/* extra read only for POST */
- if (prequest != request_GET && prequest != request_HEAD) {
- tptr = iobuf + sizeof("Content-length:") - 1;
+ if (prequest != request_GET
+#if ENABLE_FEATURE_HTTPD_CGI
+ && prequest != request_HEAD
+#endif
+ ) {
+ tptr = skip_whitespace(iobuf + sizeof("Content-length:") - 1);
if (!tptr[0])
send_headers_and_exit(HTTP_BAD_REQUEST);
/* not using strtoul: it ignores leading minus! */
#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
*/
send_file_and_exit(tptr,
- (prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS));
+#if ENABLE_FEATURE_HTTPD_CGI
+ (prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS)
+#else
+ SEND_HEADERS_AND_BODY
+#endif
+ );
}
/*
#if ENABLE_FEATURE_HTTPD_SETUID
if (opt & OPT_SETUID) {
if (!get_uidgid(&ugid, s_ugid, 1))
- bb_error_msg_and_die("unrecognized user[:group] "
+ bb_error_msg_and_die("unknown user[:group] "
"name '%s'", s_ugid);
}
#endif
* 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);
#if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
if (!(opt & OPT_INETD))
sighup_handler(0);
- else /* do not install HUP handler in inetd mode */
#endif
- index_page = "index.html";
- parse_conf(default_path_httpd_conf, FIRST_PARSE);
+ parse_conf(default_path_httpd_conf, FIRST_PARSE);
xfunc_error_retval = 0;
if (opt & OPT_INETD)