* More extermination of the dreaded SIZ moby-buffers.
authorArt Cancro <ajc@citadel.org>
Thu, 24 Mar 2005 22:52:41 +0000 (22:52 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 24 Mar 2005 22:52:41 +0000 (22:52 +0000)
citadel/ChangeLog
citadel/citserver.c
citadel/msgbase.c
citadel/room_ops.c
citadel/sysdep.c

index 0ca147a532f1987300c50039782c63aa37f8559d..3d5033e6167c5936de7726f6919be8d8852d0f0a 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 641.33  2005/03/24 22:52:40  ajc
+ * More extermination of the dreaded SIZ moby-buffers.
+
  Revision 641.32  2005/03/24 22:13:56  ajc
  * extract_token() now expects to be supplied with the size of the
    destination string buffer.  This, along with the elimination of other
@@ -6566,4 +6569,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 1fec901a42f609a30c849794fe0c70aab15f3b46..9240f4ac416d880513e944bf2841ea493169b5fb 100644 (file)
@@ -299,7 +299,7 @@ int is_public_client(void)
                begin_critical_section(S_PUBLIC_CLIENTS);
                lprintf(CTDL_INFO, "Loading %s\n", PUBLIC_CLIENTS);
 
-               strcpy(public_clients, "127.0.0.1");
+               safestrncpy(public_clients, "127.0.0.1", sizeof public_clients);
                if (hostname_to_dotted_quad(addrbuf, config.c_fqdn) == 0) {
                        strcat(public_clients, "|");
                        strcat(public_clients, addrbuf);
@@ -417,10 +417,8 @@ void cmd_mesg(char *mname)
 
        extract_token(buf, mname, 0, '|', sizeof buf);
 
-       dirs[0]=malloc(64);
-       dirs[1]=malloc(64);
-       strcpy(dirs[0],"messages");
-       strcpy(dirs[1],"help");
+       dirs[0] = strdup("messages");
+       dirs[1] = strdup("help");
        snprintf(buf2, sizeof buf2, "%s.%d.%d", buf, CC->cs_clientdev, CC->cs_clienttyp);
        mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs);
        if (strlen(targ) == 0) {
index 9ddf52142b7d0445f97a498523c50dc2ed60ec2c..1661146c349aa20f39751e6947f62672a5d7be9f 100644 (file)
@@ -527,10 +527,10 @@ int CtdlForEachMessage(int mode, long ref,
 void cmd_msgs(char *cmdbuf)
 {
        int mode = 0;
-       char which[SIZ];
-       char buf[SIZ];
-       char tfield[SIZ];
-       char tvalue[SIZ];
+       char which[16];
+       char buf[256];
+       char tfield[256];
+       char tvalue[256];
        int cm_ref = 0;
        int i;
        int with_template = 0;
@@ -1025,7 +1025,7 @@ void output_preferred(char *name, char *filename, char *partnum, char *disp,
                void *cbuserdata)
 {
        int i;
-       char buf[SIZ];
+       char buf[128];
        int add_newline = 0;
        char *text_content;
        struct ma_info *ma;
index b49d7ed179d73127037f245b4ed09eb2b8b0ce3e..e21b7330a7a0679020ec267183edeebdcc3e2294 100644 (file)
@@ -514,8 +514,8 @@ void list_roomname(struct ctdlroom *qrbuf, int ra, int view)
        /* For my own mailbox rooms, chop off the owner prefix */
        if ( (qrbuf->QRflags & QR_MAILBOX)
             && (atol(qrbuf->QRname) == CC->user.usernum) ) {
-               strcpy(truncated_roomname, qrbuf->QRname);
-               strcpy(truncated_roomname, &truncated_roomname[11]);
+               safestrncpy(truncated_roomname, qrbuf->QRname, sizeof truncated_roomname);
+               safestrncpy(truncated_roomname, &truncated_roomname[11], sizeof truncated_roomname);
                cprintf("%s", truncated_roomname);
        }
        /* For all other rooms, just display the name in its entirety */
@@ -848,10 +848,10 @@ void usergoto(char *where, int display_result, int transiently,
        else
                raideflag = 0;
 
-       strcpy(truncated_roomname, CC->room.QRname);
+       safestrncpy(truncated_roomname, CC->room.QRname, sizeof truncated_roomname);
        if ( (CC->room.QRflags & QR_MAILBOX)
           && (atol(CC->room.QRname) == CC->user.usernum) ) {
-               strcpy(truncated_roomname, &truncated_roomname[11]);
+               safestrncpy(truncated_roomname, &truncated_roomname[11], sizeof truncated_roomname);
        }
 
        if (retmsgs != NULL) *retmsgs = total_messages;
@@ -1027,9 +1027,9 @@ void cmd_whok(void)
  */
 void cmd_rdir(void)
 {
-       char buf[SIZ];
-       char flnm[SIZ];
-       char comment[SIZ];
+       char buf[256];
+       char flnm[256];
+       char comment[256];
        FILE *ls, *fd;
        struct stat statbuf;
 
@@ -1067,7 +1067,7 @@ void cmd_rdir(void)
                        snprintf(buf, sizeof buf, "%s/files/%s/%s",
                                BBSDIR, CC->room.QRdirname, flnm);
                        stat(buf, &statbuf);
-                       strcpy(comment, "");
+                       safestrncpy(comment, "", sizeof comment);
                        fseek(fd, 0L, 0);
                        while ((fgets(buf, sizeof buf, fd) != NULL)
                               && (strlen(comment) == 0)) {
@@ -1135,7 +1135,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
        struct floor *fl;
        struct floor flbuf;
        long owner = 0L;
-       char actual_old_name[SIZ];
+       char actual_old_name[ROOMNAMELEN];
 
        lprintf(CTDL_DEBUG, "CtdlRenameRoom(%s, %s, %d)\n",
                old_name, new_name, new_floor);
@@ -1170,7 +1170,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
 
        else {
                /* Rename it */
-               strcpy(actual_old_name, qrbuf.QRname);
+               safestrncpy(actual_old_name, qrbuf.QRname, sizeof actual_old_name);
                if (qrbuf.QRflags & QR_MAILBOX) {
                        owner = atol(qrbuf.QRname);
                }
@@ -1265,7 +1265,7 @@ void cmd_setr(char *args)
        if (CC->room.QRflags & QR_MAILBOX) {
                sprintf(new_name, "%010ld.", atol(CC->room.QRname) );
        } else {
-               strcpy(new_name, "");
+               safestrncpy(new_name, "", sizeof new_name);
        }
        extract_token(&new_name[strlen(new_name)], args, 0, '|', (sizeof new_name - strlen(new_name)));
 
@@ -1574,10 +1574,10 @@ void cmd_kill(char *argbuf)
        }
        if (kill_ok) {
                if (CC->room.QRflags & QR_MAILBOX) {
-                       strcpy(deleted_room_name, &CC->room.QRname[11]);
+                       safestrncpy(deleted_room_name, &CC->room.QRname[11], sizeof deleted_room_name);
                }
                else {
-                       strcpy(deleted_room_name, CC->room.QRname);
+                       safestrncpy(deleted_room_name, CC->room.QRname, sizeof deleted_room_name);
                }
 
                /* Do the dirty work */
index c6c96ac09a6f74554a56d8ac275f94f2550d8a80..4783f7e1d89339fd651907433b6fb4d37be945ca 100644 (file)
@@ -676,7 +676,7 @@ int client_getln(char *buf, int bufsize)
        buf[i] = 0;
        while ((strlen(buf)>0)&&(!isprint(buf[strlen(buf)-1])))
                buf[strlen(buf)-1] = 0;
-       if (retval < 0) strcpy(buf, "000");
+       if (retval < 0) safestrncpy(buf, "000", bufsize);
        return(retval);
 }