]> code.citadel.org Git - citadel.git/commitdiff
* client_chat.c: use memfmout(), *not* cprintf() to transmit express
authorArt Cancro <ajc@citadel.org>
Sat, 6 Mar 1999 06:57:14 +0000 (06:57 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 6 Mar 1999 06:57:14 +0000 (06:57 +0000)
          messages.  Calling cprintf() on strings >256 bytes crashes the server
        * msgbase.c: minor logging fix in save_message()

citadel/ChangeLog
citadel/msgbase.c
citadel/serv_chat.c

index 85ce83b8d86f4c5c0e11f38e86d5f77e6f4a2033..69dc8f9d8ac768a597c2bc0415a327d4949cf178 100644 (file)
@@ -1,3 +1,8 @@
+Sat Mar  6 01:55:55 EST 1999 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * client_chat.c: use memfmout(), *not* cprintf() to transmit express
+         messages.  Calling cprintf() on strings >256 bytes crashes the server
+       * msgbase.c: minor logging fix in save_message()
+
 1999-03-05 Nathan Bryant <bryant@cs.usm.maine.edu>
        * sysdep.c: add undocumented -r flag to citserver to prevent it from
          dropping root permissions.
index 4f0ed4cad6246780b80e0b000c58c8d517566f7e..ace98ecdf23df0bf905cb3733ff44f424407c350 100644 (file)
@@ -882,7 +882,7 @@ void save_message(char *mtmp,       /* file containing proper message */
        static int seqnum = 0;
 
        lprintf(9, "save_message(%s,%s,%s,%d,%d)\n",
-               mtmp, rec, force_room, mailtype, generate_id);
+               mtmp, rec, force, mailtype, generate_id);
 
        strcpy(force_room, force);
 
index 7a9843cc1c2b8bdd01f1608c9d2f0804bf21ef46..000cc7ade7d49e6561528513d9303829920e9ae4 100644 (file)
@@ -391,7 +391,7 @@ void cmd_pexp(char *argbuf)
                        cprintf("Message ");
                cprintf("from %s:\n", ptr->sender);
                if (ptr->text != NULL)
-                       cprintf("%s\n\n", ptr->text);
+                       memfmout(80, ptr->text, 0);
 
                holdptr = ptr->next;
                if (ptr->text != NULL) phree(ptr->text);
@@ -426,7 +426,7 @@ void cmd_gexp(char *argbuf) {
                ptr->sender,                            /* sender of msg */
                config.c_nodename);                     /* static for now */
        if (ptr->text != NULL) {
-               cprintf("%s", ptr->text);
+               memfmout(80, ptr->text, 0);
                if (ptr->text[strlen(ptr->text)-1] != '\n') cprintf("\n");
                phree(ptr->text);
                }
@@ -448,6 +448,13 @@ int send_express_message(char *lun, char *x_user, char *x_msg)
        struct ExpressMessage *newmsg, *findend;
        char *un;
        FILE *fp;
+       size_t msglen = 0;
+       int do_send = 0;
+
+       if (strlen(x_msg) > 0) {
+               msglen = strlen(x_msg) + 4;
+               do_send = 1;
+               }
 
        /* find the target user's context and append the message */
        begin_critical_section(S_SESSION_TABLE);
@@ -460,7 +467,7 @@ int send_express_message(char *lun, char *x_user, char *x_msg)
 
                if ((!strcasecmp(un, x_user))
                    || (!strcasecmp(x_user, "broadcast"))) {
-                       if (strlen(x_msg) > 0) {
+                       if (do_send) {
                                newmsg = (struct ExpressMessage *)
                                        mallok(sizeof (struct ExpressMessage));
                                memset(newmsg, 0,
@@ -468,8 +475,8 @@ int send_express_message(char *lun, char *x_user, char *x_msg)
                                strcpy(newmsg->sender, lun);
                                if (!strcasecmp(x_user, "broadcast"))
                                        newmsg->flags |= EM_BROADCAST;
-                               newmsg->text = mallok(strlen(x_msg)+2);
-                               strcpy(newmsg->text, x_msg);
+                               newmsg->text = mallok(msglen);
+                               safestrncpy(newmsg->text, x_msg, msglen);
 
                                if (ccptr->FirstExpressMessage == NULL)
                                        ccptr->FirstExpressMessage = newmsg;
@@ -486,7 +493,7 @@ int send_express_message(char *lun, char *x_user, char *x_msg)
        end_critical_section(S_SESSION_TABLE);
 
        /* Log the page to disk if configured to do so */
-       if ((strlen(config.c_logpages) > 0) && (strlen(x_msg) > 0)) {
+       if ((strlen(config.c_logpages) > 0) && (do_send) ) {
                fp = fopen(CC->temp, "wb");
                fprintf(fp, "%c%c%c", 255, MES_NORMAL, 0);
                fprintf(fp, "Psysop%c", 0);