mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
fixed memory leak
git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@63 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
@ -33,7 +33,7 @@ normal http access for a directory needs to be disabled, then put
|
||||
|
||||
Conversely, use "SSLDenySSL" to deny access to directories via SSL.
|
||||
|
||||
An example is in /test_dir/ssl_only and /test_dir/no_ssl.
|
||||
An example is in /test_dir/no_http and /test_dir/no_ssl.
|
||||
|
||||
Entire directories can be denied access with a "Deny all" directive
|
||||
(regardless of SSL or authentication).
|
||||
|
@ -53,8 +53,6 @@ static void sigint_cleanup(int sig)
|
||||
{
|
||||
struct serverstruct *sp;
|
||||
struct connstruct *tp;
|
||||
int i;
|
||||
|
||||
|
||||
while (servers != NULL)
|
||||
{
|
||||
@ -66,16 +64,20 @@ static void sigint_cleanup(int sig)
|
||||
servers = sp;
|
||||
}
|
||||
|
||||
for (i = 0; i < INITIAL_CONNECTION_SLOTS; i++)
|
||||
while (freeconns != NULL)
|
||||
{
|
||||
if (freeconns == NULL)
|
||||
break;
|
||||
|
||||
tp = freeconns->next;
|
||||
free(freeconns);
|
||||
freeconns = tp;
|
||||
}
|
||||
|
||||
while (usedconns != NULL)
|
||||
{
|
||||
tp = usedconns->next;
|
||||
free(usedconns);
|
||||
usedconns = tp;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_HTTP_HAS_CGI)
|
||||
while (cgiexts)
|
||||
{
|
||||
@ -129,20 +131,6 @@ int main(int argc, char *argv[])
|
||||
freeconns->next = tp;
|
||||
}
|
||||
|
||||
/* change to webroot for better security */
|
||||
if (chroot(webroot))
|
||||
{
|
||||
#ifdef CONFIG_HTTP_VERBOSE
|
||||
fprintf(stderr, "'%s' is not a directory\n", webroot);
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
setgid(32767);
|
||||
setuid(32767);
|
||||
#endif
|
||||
|
||||
if ((active = openlistener(CONFIG_HTTP_PORT)) == -1)
|
||||
{
|
||||
#ifdef CONFIG_HTTP_VERBOSE
|
||||
@ -179,6 +167,21 @@ int main(int argc, char *argv[])
|
||||
ssl_version(), CONFIG_HTTP_PORT, CONFIG_HTTP_HTTPS_PORT);
|
||||
TTY_FLUSH();
|
||||
#endif
|
||||
|
||||
/* change to webroot for better security */
|
||||
if (chroot(webroot))
|
||||
{
|
||||
#ifdef CONFIG_HTTP_VERBOSE
|
||||
fprintf(stderr, "'%s' is not a directory\n", webroot);
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
setgid(32767);
|
||||
setuid(32767);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_HTTP_IS_DAEMON)
|
||||
if (fork() > 0) /* parent will die */
|
||||
exit(0);
|
||||
@ -560,7 +563,7 @@ static void addconnection(int sd, char *ip, int is_ssl)
|
||||
|
||||
/* Get ourselves a connstruct */
|
||||
if (freeconns == NULL)
|
||||
tp = (struct connstruct *)malloc(sizeof(struct connstruct));
|
||||
tp = (struct connstruct *)calloc(1, sizeof(struct connstruct));
|
||||
else
|
||||
{
|
||||
tp = freeconns;
|
||||
|
13
httpd/proc.c
13
httpd/proc.c
@ -163,9 +163,6 @@ static void procdirlisting(struct connstruct *cn)
|
||||
send_error(cn, 404);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get rid of the "." */
|
||||
readdir(cn->dirp);
|
||||
#endif
|
||||
|
||||
snprintf(buf, sizeof(buf), "HTTP/1.1 200 OK\nContent-Type: text/html\n\n"
|
||||
@ -198,6 +195,9 @@ void procdodir(struct connstruct *cn)
|
||||
snprintf(buf, sizeof(buf), "</body></html>\n");
|
||||
special_write(cn, buf, strlen(buf));
|
||||
removeconnection(cn);
|
||||
#ifndef WIN32
|
||||
closedir(cn->dirp);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ void procsendhead(struct connstruct *cn)
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
|
||||
cn->filedesc = open(cn->actualfile, flags);
|
||||
cn->filedesc = ax_open(cn->actualfile, flags);
|
||||
if (cn->filedesc == -1)
|
||||
{
|
||||
send_error(cn, 404);
|
||||
@ -1011,6 +1011,11 @@ static void send_error(struct connstruct *cn, int err)
|
||||
title = "Not Found";
|
||||
text = title;
|
||||
break;
|
||||
|
||||
default:
|
||||
title = "Unknown";
|
||||
text = "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
snprintf(buf, MAXREQUESTLENGTH, "HTTP/1.1 %d %s\n"
|
||||
|
Reference in New Issue
Block a user