wget: -O FILE is allowed to overwrite existing file (compat)
[oweals/busybox.git] / networking / httpd.c
index 33f083189015c3d84570a53ef57f375c369aee79..92a07107dc12742de776bb7f72141780e43a4285 100644 (file)
@@ -628,7 +628,7 @@ static void parse_conf(const char *path, int flag)
                                ++p;                             /* so keep last character */
                        }
                        *p = '\0';
-                       sprintf(p0, "%s:%s", p0, c);
+                       sprintf(p0 + strlen(p0), ":%s", c);
                }
 #endif
 
@@ -1073,12 +1073,8 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
                }
 
                /* Now wait on the set of sockets */
-               count = poll(pfd, 3, -1);
+               count = safe_poll(pfd, 3, -1);
                if (count <= 0) {
-#if 0
-                       if (errno == EINTR)
-                               continue;
-#endif
 #if 0
                        if (waitpid(pid, &status, WNOHANG) <= 0) {
                                /* Weird. CGI didn't exit and no fd's
@@ -1688,6 +1684,13 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
        if (fromAddr->sa.sa_family == AF_INET) {
                rmt_ip = ntohl(fromAddr->sin.sin_addr.s_addr);
        }
+#if ENABLE_FEATURE_IPV6
+       if (fromAddr->sa.sa_family == AF_INET6
+        && fromAddr->sin6.sin6_addr.s6_addr32[0] == 0
+        && fromAddr->sin6.sin6_addr.s6_addr32[1] == 0
+        && ntohl(fromAddr->sin6.sin6_addr.s6_addr32[2]) == 0xffff)
+               rmt_ip = ntohl(fromAddr->sin6.sin6_addr.s6_addr32[3]);
+#endif
        if (ENABLE_FEATURE_HTTPD_CGI || DEBUG || verbose) {
                rmt_ip_str = xmalloc_sockaddr2dotted(&fromAddr->sa);
        }