From 1ab2bba7b80b9ec8cd3f1775d3453e9e45881c31 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Wed, 20 Sep 2006 19:18:56 +0000 Subject: [PATCH] Fix for bug when script goes past the end of a file (thanks to Till Harbaum) --- apps/webserver/httpd.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/webserver/httpd.c b/apps/webserver/httpd.c index 34d4e8692..64619b6f8 100644 --- a/apps/webserver/httpd.c +++ b/apps/webserver/httpd.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: httpd.c,v 1.3 2006/08/16 22:09:51 oliverschmidt Exp $ + * $Id: httpd.c,v 1.4 2006/09/20 19:18:56 adamdunkels Exp $ */ #include "contiki-net.h" @@ -45,7 +45,7 @@ #define STATE_OUTPUT 1 #define SEND_STRING(s, str) PSOCK_SEND(s, str, (unsigned int)strlen(str)) -MEMB(conns, struct httpd_state, 8); +MEMB(conns, struct httpd_state, 4); #define ISO_nl 0x0a #define ISO_space 0x20 @@ -100,9 +100,18 @@ static void next_scriptstate(struct httpd_state *s) { char *p; + + if((p = strchr(s->scriptptr, ISO_nl)) != NULL) { + p += 1; + s->scriptlen -= (unsigned short)(p - s->scriptptr); + s->scriptptr = p; + } else { + s->scriptlen = 0; + } + /* char *p; p = strchr(s->scriptptr, ISO_nl) + 1; s->scriptlen -= (unsigned short)(p - s->scriptptr); - s->scriptptr = p; + s->scriptptr = p;*/ } /*---------------------------------------------------------------------------*/ static