1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-05 13:16:13 +03:00

fixes to axhttpd from Joe Pruett

git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@170 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
cameronrich
2010-05-07 10:39:58 +00:00
parent e674d076d4
commit 8b2e5bba82
3 changed files with 24 additions and 15 deletions

View File

@@ -131,12 +131,12 @@ EXP_FUNC void STDCALL RNG_initialize(const uint8_t *seed_buf, int size)
a number that should be hard to find, due to the fact that it a number that should be hard to find, due to the fact that it
relies on knowing the private key */ relies on knowing the private key */
memcpy(entropy_pool, seed_buf, ENTROPY_POOL_SIZE); memcpy(entropy_pool, seed_buf, ENTROPY_POOL_SIZE);
srand((long)entropy_pool);
/* mix it up a little with a stack address */ /* mix it up a little with a stack address */
for (i = 0; i < ENTROPY_POOL_SIZE/4; i++) for (i = 0; i < ENTROPY_POOL_SIZE/4; i++)
ep[i] ^= seed_addr_val; ep[i] ^= seed_addr_val;
srand((long)entropy_pool);
#endif #endif
} }

View File

@@ -55,7 +55,8 @@ static void addcgiext(const char *tp);
#if !defined(WIN32) #if !defined(WIN32)
static void reaper(int sigtype) static void reaper(int sigtype)
{ {
wait3(NULL, WNOHANG, NULL); while (wait3(NULL, WNOHANG, NULL) > 0)
continue;
} }
#endif #endif
#endif #endif
@@ -446,7 +447,8 @@ static void handlenewconnection(int listenfd, int is_ssl)
else else
*ipbuf = '\0'; *ipbuf = '\0';
addconnection(connfd, ipbuf, is_ssl); if (connfd != -1) /* check for error condition */
addconnection(connfd, ipbuf, is_ssl);
} }
#else #else

View File

@@ -119,7 +119,7 @@ static int procheadelem(struct connstruct *cn, char *buf)
#endif #endif
cn->if_modified_since = -1; cn->if_modified_since = -1;
} }
else if (strcmp(buf, "Host:") == 0) else if (strcasecmp(buf, "Host:") == 0)
{ {
if (sanitizehost(value) == 0) if (sanitizehost(value) == 0)
{ {
@@ -129,21 +129,24 @@ static int procheadelem(struct connstruct *cn, char *buf)
my_strncpy(cn->server_name, value, MAXREQUESTLENGTH); my_strncpy(cn->server_name, value, MAXREQUESTLENGTH);
} }
else if (strcmp(buf, "Connection:") == 0 && strcmp(value, "close") == 0) else if (strcasecmp(buf, "Connection:") == 0 && strcmp(value, "close") == 0)
{ {
cn->close_when_done = 1; cn->close_when_done = 1;
} }
else if (strcmp(buf, "If-Modified-Since:") == 0) else if (strcasecmp(buf, "If-Modified-Since:") == 0)
{ {
cn->if_modified_since = tdate_parse(value); cn->if_modified_since = tdate_parse(value);
} }
else if (strcmp(buf, "Expect:") == 0) else if (strcasecmp(buf, "Expect:") == 0)
{ {
send_error(cn, 417); /* expectation failed */ /* supposed to be safe to ignore 100-continue */
return 0; if (strcasecmp(value, "100-continue") != 0) {
send_error(cn, 417); /* expectation failed */
return 0;
}
} }
#ifdef CONFIG_HTTP_HAS_AUTHORIZATION #ifdef CONFIG_HTTP_HAS_AUTHORIZATION
else if (strcmp(buf, "Authorization:") == 0 && else if (strcasecmp(buf, "Authorization:") == 0 &&
strncmp(value, "Basic ", 6) == 0) strncmp(value, "Basic ", 6) == 0)
{ {
int size; int size;
@@ -155,15 +158,15 @@ static int procheadelem(struct connstruct *cn, char *buf)
} }
#endif #endif
#if defined(CONFIG_HTTP_HAS_CGI) #if defined(CONFIG_HTTP_HAS_CGI)
else if (strcmp(buf, "Content-Length:") == 0) else if (strcasecmp(buf, "Content-Length:") == 0)
{ {
sscanf(value, "%d", &cn->content_length); sscanf(value, "%d", &cn->content_length);
} }
else if (strcmp(buf, "Content-Type:") == 0) else if (strcasecmp(buf, "Content-Type:") == 0)
{ {
my_strncpy(cn->cgicontenttype, value, MAXREQUESTLENGTH); my_strncpy(cn->cgicontenttype, value, MAXREQUESTLENGTH);
} }
else if (strcmp(buf, "Cookie:") == 0) else if (strcasecmp(buf, "Cookie:") == 0)
{ {
my_strncpy(cn->cookie, value, MAXREQUESTLENGTH); my_strncpy(cn->cookie, value, MAXREQUESTLENGTH);
} }
@@ -628,11 +631,15 @@ static void proccgi(struct connstruct *cn)
/* Our stdout/stderr goes to the socket */ /* Our stdout/stderr goes to the socket */
dup2(tpipe[1], 1); dup2(tpipe[1], 1);
dup2(tpipe[1], 2); dup2(tpipe[1], 2);
close(tpipe[0]);
close(tpipe[1]);
/* If it was a POST request, send the socket data to our stdin */ /* If it was a POST request, send the socket data to our stdin */
if (cn->reqtype == TYPE_POST) if (cn->reqtype == TYPE_POST) {
dup2(spipe[0], 0); dup2(spipe[0], 0);
else /* Otherwise we can shutdown the read side of the sock */ close(spipe[0]);
close(spipe[1]);
} else /* Otherwise we can shutdown the read side of the sock */
shutdown(cn->networkdesc, 0); shutdown(cn->networkdesc, 0);
myargs[0] = cn->actualfile; myargs[0] = cn->actualfile;