* Final cleanup of changes (finally located and fixed the bug)
authorArt Cancro <ajc@citadel.org>
Thu, 25 Jul 2002 04:01:58 +0000 (04:01 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 25 Jul 2002 04:01:58 +0000 (04:01 +0000)
webcit/ChangeLog
webcit/Makefile.in
webcit/html2html.c
webcit/webserver.c

index c71e97cb2282474ae55db4014b83b100ad63846b..be16c77278e3d9a1300ad913ea89efb945794b3f 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 323.52  2002/07/25 04:01:58  ajc
+* Final cleanup of changes (finally located and fixed the bug)
+
 Revision 323.51  2002/07/24 04:14:23  ajc
 * Minor code cleanup of last night's changes
 
@@ -878,4 +881,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index 2e488331287a7a2e7caab2846522ae51aacc3f11..f9b04c1c2070ed4c7f14700425d82929a2ded1c5 100644 (file)
@@ -34,7 +34,6 @@ webserver: webserver.o context_loop.o tools.o \
        locate_host.o siteconfig.o subst.o vcard.o vcard_edit.o \
        mime_parser.o graphics.o netconf.o preferences.o html2html.o \
        $(LIBOBJS) $(LIBS) -o webserver
-       strip webserver
 
 .c.o:
        $(CC) $(CFLAGS) $(DEFS) -c $(PTHREAD_DEFS) -DWEBCITDIR=\"`pwd`\" $<
index 4ac9a8fec9ecc9afc0ae9639dabd836c734e6b03..903e9696152cb7b5b8a235770246337948111381 100644 (file)
@@ -37,31 +37,38 @@ void output_html(void) {
        char *ptr;
        char *msgstart;
        char *msgend;
-       int total_length = 1;
+       int buffer_length = 1;
        int line_length = 0;
+       int content_length = 0;
 
        msg = strdup("");
-       msgstart = msg;
-       msgend = msg;
 
        while (serv_gets(buf), strcmp(buf, "000")) {
                line_length = strlen(buf);
-               total_length = total_length + line_length + 1;
-               msg = realloc(msg, total_length + 1);
-               strcpy(msgend, buf);
-               msgend[line_length++] = '\n' ;
-               msgend[line_length] = 0;
-               msgend = &msgend[line_length];
+               buffer_length = content_length + line_length + 2;
+               msg = realloc(msg, buffer_length);
+               if (msg == NULL) {
+                       wprintf("<B>realloc() error!  "
+                               "couldn't get %d bytes: %s</B><BR><BR>\n",
+                               buffer_length + 1,
+                               strerror(errno));
+                       return;
+               }
+               strcpy(&msg[content_length], buf);
+               content_length += line_length;
+               strcpy(&msg[content_length], "\n");
+               content_length += 1;
        }
 
        ptr = msg;
        msgstart = msg;
-       /* msgend is already set correctly */
+       msgend = &msg[content_length];
 
        while (ptr < msgend) {
 
                /* Advance to next tag */
                ptr = strchr(ptr, '<');
+               if ((ptr == NULL) || (ptr >= msgend)) break;
                ++ptr;
                if ((ptr == NULL) || (ptr >= msgend)) break;
 
@@ -100,5 +107,6 @@ void output_html(void) {
 
        /* Now give back the memory */
        free(msg);
+
 }
 
index da0282b00d8f3891561e82d81ff7d946b37cf3ed..a39dc6e88e55ff072c076227d79de058eda3c01b 100644 (file)
@@ -395,6 +395,7 @@ int lprintf(int loglevel, const char *format, ...)
                                tim->tm_sec, (long)tv.tv_usec / 1000,
                                pthread_self(), buf);
                }
+               fflush(stderr);
        }
        return 1;
 }