]> code.citadel.org Git - citadel.git/commitdiff
* Better validation of incoming network messages.
authorArt Cancro <ajc@citadel.org>
Tue, 24 Feb 2004 05:09:07 +0000 (05:09 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 24 Feb 2004 05:09:07 +0000 (05:09 +0000)
citadel/ChangeLog
citadel/msgbase.c
citadel/serv_network.c

index 583b0dc52ff17b7237f25a92d6f3bc6497d37066..d695de43cacafb0a0bd706eae04371870e1ff6f1 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 614.49  2004/02/24 05:09:06  ajc
+ * Better validation of incoming network messages.
+
  Revision 614.48  2004/02/23 16:10:47  nbryant
  --disable-pie by default.
 
@@ -5395,4 +5398,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 2091f0e3331b316ec895d5e1ab3dc79eb1d8eac6..f1c3f773cc03cb4019cd4bbc1ecebc24278005dd 100644 (file)
@@ -1922,6 +1922,20 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,      /* message to save */
                msg->cm_fields['T'] = strdoop(aaa);
        }
 
+       /*
+        * If no Author, set it to ME ME ME
+        */
+       if (msg->cm_fields['A'] == NULL) {
+               msg->cm_fields['A'] = strdoop(CC->user.fullname);
+       }
+
+       /*
+        * If no Node, set it to the local node
+        */
+       if (msg->cm_fields['N'] == NULL) {
+               msg->cm_fields['N'] = strdoop(config.c_nodename);
+       }
+
        /* If this message has no path, we generate one.
         */
        if (msg->cm_fields['P'] == NULL) {
@@ -1950,6 +1964,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        lprintf(9, "Learning what's inside\n");
        if (msg->cm_fields['M'] == NULL) {
                lprintf(1, "ERROR: attempt to save message with NULL body\n");
+               return(-1);
        }
 
        switch (msg->cm_format_type) {
index 163499caa3c5f69b548a495b2909738939435cb5..9bea369ffd05ba807edfc608bc21fa5d1b200910 100644 (file)
@@ -1059,6 +1059,18 @@ void network_process_buffer(char *buffer, long size) {
        char filename[SIZ];
        FILE *fp;
        char nexthop[SIZ];
+       unsigned char firstbyte;
+       unsigned char lastbyte;
+
+       /* Validate just a little bit.  First byte should be FF and
+        * last byte should be 00.
+        */
+       memcpy(&firstbyte, &buffer[0], 1);
+       memcpy(&lastbyte, &buffer[size-1], 1);
+       if ( (firstbyte != 255) || (lastbyte != 0) ) {
+               lprintf(7, "Corrupt message!  Ignoring.\n");
+               return;
+       }
 
        /* Set default target room to trash */
        strcpy(target_room, TWITROOM);