* extract_token() now expects to be supplied with the size of the
authorArt Cancro <ajc@citadel.org>
Thu, 24 Mar 2005 22:13:58 +0000 (22:13 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 24 Mar 2005 22:13:58 +0000 (22:13 +0000)
  destination string buffer.  This, along with the elimination of other
  unbounded functions like strcpy(), will allow the removal of the
  "all string buffers are of size SIZ" assumption (a process which I have
  already begun), which will hopefully reduce stack consumption.

43 files changed:
citadel/ChangeLog
citadel/citadel.c
citadel/citadel_ipc.c
citadel/citserver.c
citadel/client_chat.c
citadel/client_passwords.c
citadel/commands.c
citadel/control.c
citadel/domain.c
citadel/file_ops.c
citadel/imap_fetch.c
citadel/imap_misc.c
citadel/imap_store.c
citadel/imap_tools.c
citadel/internet_addressing.c
citadel/locate_host.c
citadel/messages.c
citadel/msgbase.c
citadel/msgbase.h
citadel/policy.c
citadel/room_ops.c
citadel/rooms.c
citadel/routines2.c
citadel/serv_bio.c
citadel/serv_calendar.c
citadel/serv_chat.c
citadel/serv_inetcfg.c
citadel/serv_ldap.c
citadel/serv_listsub.c
citadel/serv_mrtg.c
citadel/serv_network.c
citadel/serv_pas2.c
citadel/serv_rwho.c
citadel/serv_smtp.c
citadel/serv_spam.c
citadel/serv_vandelay.c
citadel/serv_vcard.c
citadel/setup.c
citadel/tools.c
citadel/tools.h
citadel/user_ops.c
citadel/userlist.c
citadel/whobbs.c

index 71eb6333bac3c76c0030276a1c2ad7e489fc61a2..0ca147a532f1987300c50039782c63aa37f8559d 100644 (file)
@@ -1,4 +1,11 @@
  $Log$
+ 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
+   unbounded functions like strcpy(), will allow the removal of the
+   "all string buffers are of size SIZ" assumption (a process which I have
+   already begun), which will hopefully reduce stack consumption.
+
  Revision 641.31  2005/03/22 21:53:48  ajc
  * Oops, forgot to initialize some data structures...
 
@@ -6559,3 +6566,4 @@ 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 b08346f9369085f8adc695f798decd6c0cbd3d49..ec5cdc574d83085c6c768783a18c6232c13d0812 100644 (file)
@@ -220,11 +220,11 @@ void userlist(CtdlIPC *ipc, char *patn)
        pprintf("       User Name           Num  L  LastCall  Calls Posts\n");
        pprintf("------------------------- ----- - ---------- ----- -----\n");
        while (strlen(listing) > 0) {
-               extract_token(buf, listing, 0, '\n');
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
 
                if (sigcaught == 0) {
-                   extract(fl, buf, 0);
+                   extract_token(fl, buf, 0, '|', sizeof fl);
                    if (pattern(fl, patn) >= 0) {
                        pprintf("%-25s ", fl);
                        pprintf("%5ld %d ", extract_long(buf, 2),
@@ -250,7 +250,7 @@ void userlist(CtdlIPC *ipc, char *patn)
  */
 void load_user_info(char *params)
 {
-       extract(fullname, params, 0);
+       extract_token(fullname, params, 0, '|', sizeof fullname);
        axlevel = extract_int(params, 1);
        timescalled = extract_int(params, 2);
        posted = extract_int(params, 3);
@@ -848,7 +848,7 @@ char *SortOnlineUsers(char *listing) {
        /* Copy the list into a fixed-record-size array for sorting */
        for (i=0; i<rows; ++i) {
                memset(buf, 0, SIZ);
-               extract_token(buf, listing, i, '\n');
+               extract_token(buf, listing, i, '\n', sizeof buf);
                memcpy(&sortbuf[i*SIZ], buf, (size_t)SIZ);
        }
 
@@ -900,14 +900,14 @@ void who_is_online(CtdlIPC *ipc, int longlist)
                        int isidle = 0;
                        
                        /* Get another line */
-                       extract_token(buf, listing, 0, '\n');
+                       extract_token(buf, listing, 0, '\n', sizeof buf);
                        remove_token(listing, 0, '\n');
 
-                       extract(username, buf, 1);
-                       extract(roomname, buf, 2);
-                       extract(fromhost, buf, 3);
-                       extract(clientsoft, buf, 4);
-                       extract(flags, buf, 7);
+                       extract_token(username, buf, 1, '|', sizeof username);
+                       extract_token(roomname, buf, 2, '|', sizeof roomname);
+                       extract_token(fromhost, buf, 3, '|', sizeof fromhost);
+                       extract_token(clientsoft, buf, 4, '|', sizeof clientsoft);
+                       extract_token(flags, buf, 7, '|', sizeof flags);
 
                        idletime = timenow - extract_long(buf, 5);
                        idlehours = idletime / 3600;
@@ -926,9 +926,9 @@ void who_is_online(CtdlIPC *ipc, int longlist)
                        }
 
                        if (longlist) {
-                               extract(actual_user, buf, 8);
-                               extract(actual_room, buf, 9);
-                               extract(actual_host, buf, 10);
+                               extract_token(actual_user, buf, 8, '|', sizeof actual_user);
+                               extract_token(actual_room, buf, 9, '|', sizeof actual_room);
+                               extract_token(actual_host, buf, 10, '|', sizeof actual_host);
 
                                pprintf("  Flags: %s\n", flags);
                                pprintf("Session: %d\n", extract_int(buf, 0));
index 3dff0505e798a78f9fd80c974864e5d4f1a06ffc..bfcc416d5332de65c8c7aadd05acb62e38581a8b 100644 (file)
@@ -301,13 +301,13 @@ int CtdlIPCKnownRooms(CtdlIPC *ipc, enum RoomList which, int floor, struct march
                while (bbb && strlen(bbb)) {
                        int a;
 
-                       extract_token(aaa, bbb, 0, '\n');
+                       extract_token(aaa, bbb, 0, '\n', sizeof aaa);
                        a = strlen(aaa);
                        memmove(bbb, bbb + a + 1, strlen(bbb) - a);
                        mptr = (struct march *) malloc(sizeof (struct march));
                        if (mptr) {
                                mptr->next = NULL;
-                               extract(mptr->march_name, aaa, 0);
+                               extract_token(mptr->march_name, aaa, 0, '|', sizeof mptr->march_name);
                                mptr->march_flags = (unsigned int) extract_int(aaa, 1);
                                mptr->march_floor = (char) extract_int(aaa, 2);
                                mptr->march_order = (char) extract_int(aaa, 3);
@@ -396,7 +396,7 @@ int CtdlIPCGotoRoom(CtdlIPC *ipc, const char *room, const char *passwd,
        }
        ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
        if (ret / 100 == 2) {
-               extract(rret[0]->RRname, cret, 0);
+               extract_token(rret[0]->RRname, cret, 0, '|', sizeof rret[0]->RRname);
                rret[0]->RRunread = extract_long(cret, 1);
                rret[0]->RRtotal = extract_long(cret, 2);
                rret[0]->RRinfoupdated = extract_int(cret, 3);
@@ -448,7 +448,7 @@ int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg,
        if (!*mret)
                return -1;
        while (bbb && strlen(bbb)) {
-               extract_token(aaa, bbb, 0, '\n');
+               extract_token(aaa, bbb, 0, '\n', sizeof aaa);
                remove_token(bbb, 0, '\n');
                *mret = (unsigned long *)realloc(*mret, (size_t)((count + 2) *
                                        sizeof (unsigned long)));
@@ -473,7 +473,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
        char *bbb = NULL;
        size_t bbbsize;
        int multipart_hunting = 0;
-       char multipart_prefix[SIZ];
+       char multipart_prefix[128];
 
        if (!cret) return -1;
        if (!mret) return -1;
@@ -488,7 +488,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                if (as_mime != 2) {
                        strcpy(mret[0]->mime_chosen, "1");      /* Default chosen-part is "1" */
                        while (strlen(bbb) > 4 && bbb[4] == '=') {
-                               extract_token(aaa, bbb, 0, '\n');
+                               extract_token(aaa, bbb, 0, '\n', sizeof aaa);
                                remove_token(bbb, 0, '\n');
 
                                if (!strncasecmp(aaa, "nhdr=yes", 8))
@@ -518,14 +518,14 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                                 * us to determine which part we want to download.
                                 */
                                else if (!strncasecmp(aaa, "pref=", 5)) {
-                                       extract(multipart_prefix, &aaa[5], 1);
+                                       extract_token(multipart_prefix, &aaa[5], 1, '|', sizeof multipart_prefix);
                                        if (!strcasecmp(multipart_prefix,
                                           "multipart/alternative")) {
                                                ++multipart_hunting;
                                        }
                                }
                                else if (!strncasecmp(aaa, "suff=", 5)) {
-                                       extract(multipart_prefix, &aaa[5], 1);
+                                       extract_token(multipart_prefix, &aaa[5], 1, '|', sizeof multipart_prefix);
                                        if (!strcasecmp(multipart_prefix,
                                           "multipart/alternative")) {
                                                ++multipart_hunting;
@@ -539,11 +539,11 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                                        if (ptr) {
 
                                                /* Fill the buffers for the caller */
-                                               extract(ptr->name, &aaa[5], 0);
-                                               extract(ptr->filename, &aaa[5], 1);
-                                               extract(ptr->number, &aaa[5], 2);
-                                               extract(ptr->disposition, &aaa[5], 3);
-                                               extract(ptr->mimetype, &aaa[5], 4);
+                                               extract_token(ptr->name, &aaa[5], 0, '|', sizeof ptr->name);
+                                               extract_token(ptr->filename, &aaa[5], 1, '|', sizeof ptr->filename);
+                                               extract_token(ptr->number, &aaa[5], 2, '|', sizeof ptr->number);
+                                               extract_token(ptr->disposition, &aaa[5], 3, '|', sizeof ptr->disposition);
+                                               extract_token(ptr->mimetype, &aaa[5], 4, '|', sizeof ptr->mimetype);
                                                ptr->length = extract_long(&aaa[5], 5);
                                                if (!mret[0]->attachments)
                                                        mret[0]->attachments = ptr;
@@ -575,7 +575,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                        if (as_mime == 4) {
                                do {
                                        if (!strncasecmp(bbb, "Content-type: ", 14)) {
-                                               extract_token(mret[0]->content_type, bbb, 0, '\n');
+                                               extract_token(mret[0]->content_type, bbb, 0, '\n', sizeof mret[0]->content_type);
                                                strcpy(mret[0]->content_type,
                                                        &mret[0]->content_type[14]);
                                                striplt(mret[0]->content_type);
@@ -630,7 +630,7 @@ int CtdlIPCServerInfo(CtdlIPC *ipc, char *cret)
                int line = 0;
 
                while (*listing && strlen(listing)) {
-                       extract_token(buf, listing, 0, '\n');
+                       extract_token(buf, listing, 0, '\n', sizeof buf);
                        remove_token(listing, 0, '\n');
                        switch (line++) {
                        case 0:         ipc->ServInfo.pid = atoi(buf);
@@ -752,9 +752,9 @@ int CtdlIPCGetRoomAttributes(CtdlIPC *ipc, struct ctdlroom **qret, char *cret)
 
        ret = CtdlIPCGenericCommand(ipc, "GETR", NULL, 0, NULL, NULL, cret);
        if (ret / 100 == 2) {
-               extract(qret[0]->QRname, cret, 0);
-               extract(qret[0]->QRpasswd, cret, 1);
-               extract(qret[0]->QRdirname, cret, 2);
+               extract_token(qret[0]->QRname, cret, 0, '|', sizeof qret[0]->QRname);
+               extract_token(qret[0]->QRpasswd, cret, 1, '|', sizeof qret[0]->QRpasswd);
+               extract_token(qret[0]->QRdirname, cret, 2, '|', sizeof qret[0]->QRdirname);
                qret[0]->QRflags = extract_int(cret, 3);
                qret[0]->QRfloor = extract_int(cret, 4);
                qret[0]->QRorder = extract_int(cret, 5);
@@ -1168,7 +1168,7 @@ int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf,
                ipc->downloading = 1;
                bytes = extract_long(cret, 0);
                last_mod = extract_int(cret, 1);
-               extract(mimetype, cret, 2);
+               extract_token(mimetype, cret, 2, '|', sizeof mimetype);
 
                ret = CtdlIPCReadDownload(ipc, buf, bytes, resume,
                                        progress_gauge_callback, cret);
@@ -1213,8 +1213,8 @@ int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part,
                ipc->downloading = 1;
                bytes = extract_long(cret, 0);
                last_mod = extract_int(cret, 1);
-               extract(filename, cret, 2);
-               extract(mimetype, cret, 3);
+               extract_token(filename, cret, 2, '|', sizeof filename);
+               extract_token(mimetype, cret, 3, '|', sizeof mimetype);
                /* ret = CtdlIPCReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret); */
                ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret);
                ret = CtdlIPCEndDownload(ipc, cret);
@@ -1254,7 +1254,7 @@ int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf,
                ipc->downloading = 1;
                bytes = extract_long(cret, 0);
                last_mod = extract_int(cret, 1);
-               extract(mimetype, cret, 2);
+               extract_token(mimetype, cret, 2, '|', sizeof mimetype);
 /*             ret = CtdlIPCReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret); */
                ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret);
                ret = CtdlIPCEndDownload(ipc, cret);
@@ -1694,8 +1694,8 @@ int CtdlIPCAideGetUserParameters(CtdlIPC *ipc, const char *who,
        ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
 
        if (ret / 100 == 2) {
-               extract(uret[0]->fullname, cret, 0);
-               extract(uret[0]->password, cret, 1);
+               extract_token(uret[0]->fullname, cret, 0, '|', sizeof uret[0]->fullname);
+               extract_token(uret[0]->password, cret, 1, '|', sizeof uret[0]->password);
                uret[0]->flags = extract_int(cret, 2);
                uret[0]->timescalled = extract_long(cret, 3);
                uret[0]->posted = extract_long(cret, 4);
index cb73a2ad6f8ea83817b687203496239cb029118a..1fec901a42f609a30c849794fe0c70aab15f3b46 100644 (file)
@@ -273,8 +273,8 @@ void cmd_time(void)
  */
 int is_public_client(void)
 {
-       char buf[SIZ];
-       char addrbuf[SIZ];
+       char buf[1024];
+       char addrbuf[1024];
        FILE *fp;
        int i;
        struct stat statbuf;
@@ -329,7 +329,7 @@ int is_public_client(void)
        lprintf(CTDL_DEBUG, "Checking whether %s is a local or public client\n",
                CC->cs_addr);
        for (i=0; i<num_parms(public_clients); ++i) {
-               extract(addrbuf, public_clients, i);
+               extract_token(addrbuf, public_clients, i, '|', sizeof addrbuf);
                if (!strcasecmp(CC->cs_addr, addrbuf)) {
                        lprintf(CTDL_DEBUG, "... yes it is.\n");
                        return(1);
@@ -350,8 +350,8 @@ void cmd_iden(char *argbuf)
        int dev_code;
        int cli_code;
        int rev_level;
-       char desc[SIZ];
-       char from_host[SIZ];
+       char desc[128];
+       char from_host[128];
        struct in_addr addr;
        int do_lookup = 0;
 
@@ -363,11 +363,11 @@ void cmd_iden(char *argbuf)
        dev_code = extract_int(argbuf,0);
        cli_code = extract_int(argbuf,1);
        rev_level = extract_int(argbuf,2);
-       extract(desc,argbuf,3);
+       extract_token(desc, argbuf, 3, '|', sizeof desc);
 
        safestrncpy(from_host, config.c_fqdn, sizeof from_host);
        from_host[sizeof from_host - 1] = 0;
-       if (num_parms(argbuf)>=5) extract(from_host,argbuf,4);
+       if (num_parms(argbuf)>=5) extract_token(from_host, argbuf, 4, '|', sizeof from_host);
 
        CC->cs_clientdev = dev_code;
        CC->cs_clienttyp = cli_code;
@@ -410,24 +410,24 @@ void cmd_iden(char *argbuf)
 void cmd_mesg(char *mname)
 {
        FILE *mfp;
-       char targ[SIZ];
-       char buf[SIZ];
-       char buf2[SIZ];
+       char targ[256];
+       char buf[256];
+       char buf2[256];
        char *dirs[2];
 
-       extract(buf,mname,0);
+       extract_token(buf, mname, 0, '|', sizeof buf);
 
        dirs[0]=malloc(64);
        dirs[1]=malloc(64);
        strcpy(dirs[0],"messages");
        strcpy(dirs[1],"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);
+       mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs);
        if (strlen(targ) == 0) {
                snprintf(buf2, sizeof buf2, "%s.%d", buf, CC->cs_clientdev);
-               mesg_locate(targ,sizeof targ,buf2,2,(const char **)dirs);
+               mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs);
                if (strlen(targ) == 0) {
-                       mesg_locate(targ,sizeof targ,buf,2,(const char **)dirs);
+                       mesg_locate(targ, sizeof targ, buf, 2, (const char **)dirs);
                }       
        }
        free(dirs[0]);
@@ -463,8 +463,8 @@ void cmd_mesg(char *mname)
 void cmd_emsg(char *mname)
 {
        FILE *mfp;
-       char targ[SIZ];
-       char buf[SIZ];
+       char targ[256];
+       char buf[256];
        char *dirs[2];
        int a;
 
@@ -472,16 +472,14 @@ void cmd_emsg(char *mname)
 
        if (CtdlAccessCheck(ac_aide)) return;
 
-       extract(buf,mname,0);
+       extract_token(buf, mname, 0, '|', sizeof buf);
        for (a=0; a<strlen(buf); ++a) {         /* security measure */
                if (buf[a] == '/') buf[a] = '.';
        }
 
-       dirs[0]=malloc(64);
-       dirs[1]=malloc(64);
-       strcpy(dirs[0],"messages");
-       strcpy(dirs[1],"help");
-       mesg_locate(targ,sizeof targ,buf,2,(const char**)dirs);
+       dirs[0] = strdup("messages");
+       dirs[1] = strdup("help");
+       mesg_locate(targ, sizeof targ, buf, 2, (const char**)dirs);
        free(dirs[0]);
        free(dirs[1]);
 
index 1c2369a633ee3ff768d86ca479c7a670c3b450b6..a98b4bdfc0c9fd914dcf50bd8dd595bd5a79ba38 100644 (file)
@@ -172,10 +172,10 @@ RCL:              if (send_complete_line) {
                                return;
                        }
                        if (num_parms(buf) >= 2) {
-                               extract(c_user, buf, 0);
-                               extract(c_text, buf, 1);
+                               extract_token(c_user, buf, 0, '|', sizeof c_user);
+                               extract_token(c_text, buf, 1, '|', sizeof c_text);
                                if (num_parms(buf) > 2) {
-                                       extract(c_room, buf, 2);
+                                       extract_token(c_room, buf, 2, '|', sizeof c_room);
                                        scr_printf("Got room %s\n", c_room);
                                }
                                if (strcasecmp(c_text, "NOOP")) {
index 5e8dc10de1cf56c9700d5027009fcb13ed946e04..603588bf7e89d7912126e346a0c2cde2a62ae2a4 100644 (file)
@@ -47,7 +47,7 @@ void get_stored_password(
        FILE *fp;
        char buf[SIZ];
        char buf64[SIZ];
-       char hostbuf[SIZ], portbuf[SIZ], ubuf[SIZ], pbuf[SIZ];
+       char hostbuf[256], portbuf[256], ubuf[256], pbuf[256];
 
        strcpy(username, "");
        strcpy(password, "");
@@ -59,10 +59,10 @@ void get_stored_password(
        if (fp == NULL) return;
        while (fgets(buf64, sizeof buf64, fp) != NULL) {
                CtdlDecodeBase64(buf, buf64, sizeof(buf64));
-               extract(hostbuf, buf, 0);
-               extract(portbuf, buf, 1);
-               extract(ubuf, buf, 2);
-               extract(pbuf, buf, 3);
+               extract_token(hostbuf, buf, 0, '|', sizeof hostbuf);
+               extract_token(portbuf, buf, 1, '|', sizeof portbuf);
+               extract_token(ubuf, buf, 2, '|', sizeof ubuf);
+               extract_token(pbuf, buf, 3, '|', sizeof pbuf);
 
                if (!strcasecmp(hostbuf, host)) {
                        if (!strcasecmp(portbuf, port)) {
@@ -88,7 +88,7 @@ void set_stored_password(
        FILE *fp, *oldfp;
        char buf[SIZ];
        char buf64[SIZ];
-       char hostbuf[SIZ], portbuf[SIZ], ubuf[SIZ], pbuf[SIZ];
+       char hostbuf[256], portbuf[256], ubuf[256], pbuf[256];
 
        determine_pwfilename(pwfile, sizeof pwfile);
        if (strlen(pwfile)==0) return;
@@ -100,10 +100,10 @@ void set_stored_password(
        if (fp == NULL) fp = fopen("/dev/null", "w");
        while (fgets(buf64, sizeof buf64, oldfp) != NULL) {
                CtdlDecodeBase64(buf, buf64, sizeof(buf64));
-               extract(hostbuf, buf, 0);
-               extract(portbuf, buf, 1);
-               extract(ubuf, buf, 2);
-               extract(pbuf, buf, 3);
+               extract_token(hostbuf, buf, 0, '|', sizeof hostbuf);
+               extract_token(portbuf, buf, 1, '|', sizeof portbuf);
+               extract_token(ubuf, buf, 2, '|', sizeof ubuf);
+               extract_token(pbuf, buf, 3, '|', sizeof pbuf);
 
                if ( (strcasecmp(hostbuf, host)) 
                   || (strcasecmp(portbuf, port)) ) {
index 758df4aa04a304ce356da10cad83e54416310b2b..892258f62eeca28233fed73c07de4f318e95a189 100644 (file)
@@ -232,8 +232,8 @@ void print_instant(void)
                instant_msgs = extract_int(buf, 0);
                timestamp = extract_long(buf, 1);
                flags = extract_int(buf, 2);
-               extract(sender, buf, 3);
-               extract(node, buf, 4);
+               extract_token(sender, buf, 3, '|', sizeof sender);
+               extract_token(node, buf, 4, '|', sizeof node);
                strcpy(last_paged, sender);
        
                localtime_r(&timestamp, &stamp);
@@ -1627,7 +1627,7 @@ char keymenu(char *menuprompt, char *menustring) {
                        } 
                        else {
                                for (i=0; i<choices; ++i) {
-                                       extract(buf, menustring, i);
+                                       extract_token(buf, menustring, i, '|', sizeof buf);
                                        keyopt(buf);
                                        scr_printf(" ");
                                }
@@ -1641,7 +1641,7 @@ char keymenu(char *menuprompt, char *menustring) {
                        scr_printf("\rOne of...                               ");
                        scr_printf("                                      \n");
                        for (i=0; i<choices; ++i) {
-                               extract(buf, menustring, i);
+                               extract_token(buf, menustring, i, '|', sizeof buf);
                                scr_printf("   ");
                                keyopt(buf);
                                scr_printf("\n");
@@ -1651,7 +1651,7 @@ char keymenu(char *menuprompt, char *menustring) {
                }
 
                for (i=0; i<choices; ++i) {
-                       extract(buf, menustring, i);
+                       extract_token(buf, menustring, i, '|', sizeof buf);
                        for (c=1; c<strlen(buf); ++c) {
                                if ( (ch == tolower(buf[c]))
                                   && (buf[c-1]=='<')
index 78f0736c0e7ca2fee6525970dd095cc3b33e8e21..a535192ed7633ae4a678ec0f57c8d9938f5ed7a2 100644 (file)
@@ -153,15 +153,15 @@ long get_new_room_number(void)
  */
 void cmd_conf(char *argbuf)
 {
-       char cmd[SIZ];
-       char buf[SIZ];
+       char cmd[16];
+       char buf[256];
        int a;
        char *confptr;
-       char confname[SIZ];
+       char confname[128];
 
        if (CtdlAccessCheck(ac_aide)) return;
 
-       extract(cmd, argbuf, 0);
+       extract_token(cmd, argbuf, 0, '|', sizeof cmd);
        if (!strcasecmp(cmd, "GET")) {
                cprintf("%d Configuration...\n", LISTING_FOLLOWS);
                cprintf("%s\n", config.c_nodename);
@@ -402,7 +402,7 @@ void cmd_conf(char *argbuf)
        }
 
        else if (!strcasecmp(cmd, "GETSYS")) {
-               extract(confname, argbuf, 1);
+               extract_token(confname, argbuf, 1, '|', sizeof confname);
                confptr = CtdlGetSysConfig(confname);
                if (confptr != NULL) {
                        cprintf("%d %s\n", LISTING_FOLLOWS, confname);
@@ -418,7 +418,7 @@ void cmd_conf(char *argbuf)
        }
 
        else if (!strcasecmp(cmd, "PUTSYS")) {
-               extract(confname, argbuf, 1);
+               extract_token(confname, argbuf, 1, '|', sizeof confname);
                unbuffer_output();
                cprintf("%d %s\n", SEND_LISTING, confname);
                confptr = CtdlReadMessageBody("000",
index 9a825928d3a90577f9b194e27b1ad89e24f61e57..d7bd402de868f2352e71b8ba91331c43c868da91 100644 (file)
@@ -38,8 +38,8 @@
 int get_hosts(char *mxbuf, char *rectype) {
        int config_lines;
        int i;
-       char buf[SIZ];
-       char host[SIZ], type[SIZ];
+       char buf[256];
+       char host[256], type[256];
        int total_smarthosts = 0;
 
        if (inetcfg == NULL) return(0);
@@ -47,9 +47,9 @@ int get_hosts(char *mxbuf, char *rectype) {
 
        config_lines = num_tokens(inetcfg, '\n');
        for (i=0; i<config_lines; ++i) {
-               extract_token(buf, inetcfg, i, '\n');
-               extract_token(host, buf, 0, '|');
-               extract_token(type, buf, 1, '|');
+               extract_token(buf, inetcfg, i, '\n', sizeof buf);
+               extract_token(host, buf, 0, '|', sizeof host);
+               extract_token(type, buf, 1, '|', sizeof type);
 
                if (!strcasecmp(type, rectype)) {
                        strcat(mxbuf, host);
index 2430bec35a421a0f79d9077402a0d5353bc84e7c..bcc7759bdb750b9b87e6b88644d383905b8bb886 100644 (file)
@@ -80,7 +80,7 @@ int network_talking_to(char *nodename, int operation) {
                        if (ptr == NULL) break;
                        strcpy(ptr, "");
                        for (i = 0; i < num_tokens(nttlist, '|'); ++i) {
-                               extract(buf, nttlist, i);
+                               extract_token(buf, nttlist, i, '|', sizeof buf);
                                if ( (strlen(buf) > 0)
                                     && (strcasecmp(buf, nodename)) ) {
                                                strcat(ptr, buf);
@@ -95,7 +95,7 @@ int network_talking_to(char *nodename, int operation) {
                        if (nttlist == NULL) break;
                        if (strlen(nttlist) == 0) break;
                        for (i = 0; i < num_tokens(nttlist, '|'); ++i) {
-                               extract(buf, nttlist, i);
+                               extract_token(buf, nttlist, i, '|', sizeof buf);
                                if (!strcasecmp(buf, nodename)) ++retval;
                        }
                        break;
@@ -156,16 +156,16 @@ void cmd_delf(char *filename)
  */
 void cmd_movf(char *cmdbuf)
 {
-       char filename[SIZ];
-       char pathname[SIZ];
-       char newpath[SIZ];
-       char newroom[SIZ];
-       char buf[SIZ];
+       char filename[PATH_MAX];
+       char pathname[PATH_MAX];
+       char newpath[PATH_MAX];
+       char newroom[ROOMNAMELEN];
+       char buf[PATH_MAX];
        int a;
        struct ctdlroom qrbuf;
 
-       extract(filename, cmdbuf, 0);
-       extract(newroom, cmdbuf, 1);
+       extract_token(filename, cmdbuf, 0, '|', sizeof filename);
+       extract_token(newroom, cmdbuf, 1, '|', sizeof newroom);
 
        if (CtdlAccessCheck(ac_room_aide)) return;
 
@@ -226,15 +226,15 @@ void cmd_movf(char *cmdbuf)
  */
 void cmd_netf(char *cmdbuf)
 {
-       char pathname[SIZ], filename[SIZ], destsys[SIZ], buf[SIZ];
-       char outfile[SIZ];
+       char pathname[256], filename[256], destsys[256], buf[256];
+       char outfile[256];
        int a, e;
        time_t now;
        FILE *ofp;
        static int seq = 1;
 
-       extract(filename, cmdbuf, 0);
-       extract(destsys, cmdbuf, 1);
+       extract_token(filename, cmdbuf, 0, '|', sizeof filename);
+       extract_token(destsys, cmdbuf, 1, '|', sizeof destsys);
 
        if (CtdlAccessCheck(ac_room_aide)) return;
 
@@ -341,11 +341,11 @@ void OpenCmdResult(char *filename, char *mime_type)
  */
 void cmd_open(char *cmdbuf)
 {
-       char filename[SIZ];
-       char pathname[SIZ];
+       char filename[256];
+       char pathname[PATH_MAX];
        int a;
 
-       extract(filename, cmdbuf, 0);
+       extract_token(filename, cmdbuf, 0, '|', sizeof filename);
 
        if (CtdlAccessCheck(ac_logged_in)) return;
 
@@ -391,14 +391,14 @@ void cmd_open(char *cmdbuf)
  */
 void cmd_oimg(char *cmdbuf)
 {
-       char filename[SIZ];
-       char pathname[SIZ];
+       char filename[256];
+       char pathname[PATH_MAX];
        struct ctdluser usbuf;
        char which_user[USERNAME_SIZE];
        int which_floor;
        int a;
 
-       extract(filename, cmdbuf, 0);
+       extract_token(filename, cmdbuf, 0, '|', sizeof filename);
 
        if (strlen(filename) == 0) {
                cprintf("%d You must specify a file name.\n",
@@ -413,7 +413,7 @@ void cmd_oimg(char *cmdbuf)
        }
 
        if (!strcasecmp(filename, "_userpic_")) {
-               extract(which_user, cmdbuf, 1);
+               extract_token(which_user, cmdbuf, 1, '|', sizeof which_user);
                if (getuser(&usbuf, which_user) != 0) {
                        cprintf("%d No such user.\n",
                                ERROR + NO_SUCH_USER);
@@ -455,8 +455,8 @@ void cmd_uopn(char *cmdbuf)
 {
        int a;
 
-       extract(CC->upl_file, cmdbuf, 0);
-       extract(CC->upl_comment, cmdbuf, 1);
+       extract_token(CC->upl_file, cmdbuf, 0, '|', sizeof CC->upl_file);
+       extract_token(CC->upl_comment, cmdbuf, 1, '|', sizeof CC->upl_comment);
 
        if (CtdlAccessCheck(ac_logged_in)) return;
 
@@ -514,7 +514,7 @@ void cmd_uopn(char *cmdbuf)
 void cmd_uimg(char *cmdbuf)
 {
        int is_this_for_real;
-       char basenm[SIZ];
+       char basenm[256];
        int which_floor;
        int a;
 
@@ -524,7 +524,7 @@ void cmd_uimg(char *cmdbuf)
        }
 
        is_this_for_real = extract_int(cmdbuf, 0);
-       extract(basenm, cmdbuf, 1);
+       extract_token(basenm, cmdbuf, 1, '|', sizeof basenm);
        if (CC->upload_fp != NULL) {
                cprintf("%d You already have an upload file open.\n",
                        ERROR + RESOURCE_BUSY);
@@ -588,7 +588,7 @@ void cmd_uimg(char *cmdbuf)
  */
 void cmd_clos(void)
 {
-       char buf[SIZ];
+       char buf[256];
 
        if (CC->download_fp == NULL) {
                cprintf("%d You don't have a download file open.\n",
@@ -683,7 +683,7 @@ void cmd_read(char *cmdbuf)
        long start_pos;
        size_t bytes;
        size_t actual_bytes;
-       char buf[4096];
+       char *buf = NULL;
 
        start_pos = extract_long(cmdbuf, 0);
        bytes = extract_int(cmdbuf, 1);
@@ -694,12 +694,14 @@ void cmd_read(char *cmdbuf)
                return;
        }
 
-       if (bytes > 4096) bytes = 4096;
+       if (bytes > 100000) bytes = 100000;
+       buf = malloc(bytes + 1);
 
        fseek(CC->download_fp, start_pos, 0);
        actual_bytes = fread(buf, 1, bytes, CC->download_fp);
        cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes);
        client_write(buf, actual_bytes);
+       free(buf);
 }
 
 
@@ -710,7 +712,7 @@ void cmd_read(char *cmdbuf)
 void cmd_writ(char *cmdbuf)
 {
        int bytes;
-       char buf[4096];
+       char *buf;
 
        unbuffer_output();
 
@@ -721,15 +723,17 @@ void cmd_writ(char *cmdbuf)
                return;
        }
 
-       if (bytes > 4096) {
-               cprintf("%d You may not write more than 4096 bytes.\n",
+       if (bytes > 100000) {
+               cprintf("%d You may not write more than 100000 bytes.\n",
                        ERROR + TOO_BIG);
                return;
        }
 
        cprintf("%d %d\n", SEND_BINARY, bytes);
+       buf = malloc(bytes + 1);
        client_read(buf, bytes);
        fwrite(buf, bytes, 1, CC->upload_fp);
+       free(buf);
 }
 
 
@@ -740,7 +744,7 @@ void cmd_writ(char *cmdbuf)
  */
 void cmd_ndop(char *cmdbuf)
 {
-       char pathname[SIZ];
+       char pathname[256];
        struct stat statbuf;
 
        if (strlen(CC->net_node) == 0) {
index cee9785c542a2804022a9dfa7480a5179ca54dd1..3d59567f39c011e408533365e543fa293013e8c1 100644 (file)
@@ -322,12 +322,12 @@ void imap_output_envelope_from(struct CtdlMessage *msg) {
  * fields.  But we can use it for "To" and possibly others.
  */
 void imap_output_envelope_addr(char *addr) {
-       char individual_addr[SIZ];
+       char individual_addr[256];
        int num_addrs;
        int i;
-       char user[SIZ];
-       char node[SIZ];
-       char name[SIZ];
+       char user[256];
+       char node[256];
+       char name[256];
 
        if (addr == NULL) {
                cprintf("NIL ");
@@ -346,7 +346,7 @@ void imap_output_envelope_addr(char *addr) {
 
        /* Output them one by one. */
        for (i=0; i<num_addrs; ++i) {
-               extract_token(individual_addr, addr, i, ',');
+               extract_token(individual_addr, addr, i, ',', sizeof individual_addr);
                striplt(individual_addr);
                process_rfc822_addr(individual_addr, user, node, name);
                cprintf("(");
@@ -678,12 +678,12 @@ void imap_fetch_bodystructure_post(
                void *cbuserdata
                ) {
 
-       char subtype[SIZ];
+       char subtype[128];
 
        cprintf(" ");
 
        /* disposition */
-       extract_token(subtype, cbtype, 1, '/');
+       extract_token(subtype, cbtype, 1, '/', sizeof subtype);
        imap_strout(subtype);
 
        /* body language */
@@ -708,13 +708,13 @@ void imap_fetch_bodystructure_part(
        int have_encoding = 0;
        int lines = 0;
        size_t i;
-       char cbmaintype[SIZ];
-       char cbsubtype[SIZ];
+       char cbmaintype[128];
+       char cbsubtype[128];
 
        if (cbtype != NULL) if (strlen(cbtype)>0) have_cbtype = 1;
        if (have_cbtype) {
-               extract_token(cbmaintype, cbtype, 0, '/');
-               extract_token(cbsubtype, cbtype, 1, '/');
+               extract_token(cbmaintype, cbtype, 0, '/', sizeof cbmaintype);
+               extract_token(cbsubtype, cbtype, 1, '/', sizeof cbsubtype);
        }
        else {
                strcpy(cbmaintype, "TEXT");
@@ -1122,15 +1122,15 @@ void imap_pick_range(char *supplied_range, int is_uid) {
         */
        num_sets = num_tokens(actual_range, ',');
        for (s=0; s<num_sets; ++s) {
-               extract_token(setstr, actual_range, s, ',');
+               extract_token(setstr, actual_range, s, ',', sizeof setstr);
 
-               extract_token(lostr, setstr, 0, ':');
+               extract_token(lostr, setstr, 0, ':', sizeof lostr);
                if (num_tokens(setstr, ':') >= 2) {
-                       extract_token(histr, setstr, 1, ':');
+                       extract_token(histr, setstr, 1, ':', sizeof histr);
                        if (!strcmp(histr, "*")) snprintf(histr, sizeof histr, "%ld", LONG_MAX);
                } 
                else {
-                       strcpy(histr, lostr);
+                       safestrncpy(histr, lostr, sizeof histr);
                }
                lo = atol(lostr);
                hi = atol(histr);
index c26ee32c2192427dc93bc264a2bb3a4a5203c6ec..0ddd8d401ea553310776285422f834fdc8843f19 100644 (file)
@@ -224,7 +224,7 @@ void imap_do_append_flags(long new_msgnum, char *new_message_flags) {
        safestrncpy(flags, new_message_flags, sizeof flags);
 
        for (i=0; i<num_tokens(flags, ' '); ++i) {
-               extract_token(this_flag, flags, i, ' ');
+               extract_token(this_flag, flags, i, ' ', sizeof this_flag);
                if (this_flag[0] == '\\') strcpy(this_flag, &this_flag[1]);
                if (!strcasecmp(this_flag, "Seen")) {
                        CtdlSetSeen(new_msgnum, 1, ctdlsetseen_seen);
index 2f5e8c6c74e69cb6a6e05cfcaeb5e6bb2ea0183f..1e65dae4c81c1db07743d7c6ee0ccf429efe9d57 100644 (file)
@@ -113,8 +113,8 @@ void imap_do_store(int num_items, char **itemlist) {
        int i, j;
        unsigned int bits_to_twiddle = 0;
        char *oper;
-       char flag[SIZ];
-       char whichflags[SIZ];
+       char flag[32];
+       char whichflags[256];
        char num_flags;
 
        if (num_items < 2) return;
@@ -122,7 +122,7 @@ void imap_do_store(int num_items, char **itemlist) {
 
        for (i=1; i<num_items; ++i) {
                strcpy(whichflags, itemlist[i]);
-               if (whichflags[0]=='(') strcpy(whichflags, &whichflags[1]);
+               if (whichflags[0]=='(') safestrncpy(whichflags, &whichflags[1], sizeof whichflags);
                if (whichflags[strlen(whichflags)-1]==')') {
                        whichflags[strlen(whichflags)-1]=0;
                }
@@ -134,7 +134,7 @@ void imap_do_store(int num_items, char **itemlist) {
                 */
                num_flags = num_tokens(whichflags, ' ');
                for (j=0; j<num_flags; ++j) {
-                       extract_token(flag, whichflags, j, ' ');
+                       extract_token(flag, whichflags, j, ' ', sizeof flag);
 
                        if ((!strcasecmp(flag, "\\Deleted"))
                           || (!strcasecmp(flag, "Deleted"))) {
index a022fefaa1d72bb75c0f3ce6067e19beb2bbd23c..72b8325ea5ee4162cd73b4dcfa7593cc7bdb9f6d 100644 (file)
@@ -506,8 +506,8 @@ void imap_mailboxname(char *buf, int bufsize, struct ctdlroom *qrbuf)
 int imap_roomname(char *rbuf, int bufsize, char *foldername)
 {
        int levels;
-       char floorname[SIZ];
-       char roomname[SIZ];
+       char floorname[256];
+       char roomname[ROOMNAMELEN];
        int i;
        struct floor *fl;
        int ret = (-1);
@@ -551,7 +551,7 @@ int imap_roomname(char *rbuf, int bufsize, char *foldername)
        {
                /* Extract the main room name. */
                
-               extract_token(floorname, rbuf, 0, FDELIM);
+               extract_token(floorname, rbuf, 0, FDELIM, sizeof floorname);
                strcpy(roomname, &rbuf[strlen(floorname)+1]);
 
                /* Try and find it on any floor. */
@@ -565,7 +565,7 @@ int imap_roomname(char *rbuf, int bufsize, char *foldername)
                                {
                                        /* Got it! */
 
-                                       strcpy(rbuf, roomname);
+                                       safestrncpy(rbuf, roomname, bufsize);
                                        ret = i;
                                        goto exit;
                                }
@@ -761,9 +761,9 @@ int imap_mailbox_matches_pattern(char *pattern, char *mailboxname)
  * a Unix timestamp.
  */
 int imap_datecmp(char *datestr, time_t msgtime) {
-       char daystr[SIZ];
-       char monthstr[SIZ];
-       char yearstr[SIZ];
+       char daystr[256];
+       char monthstr[256];
+       char yearstr[256];
        int i;
        int day, month, year;
        int msgday, msgmonth, msgyear;
@@ -772,9 +772,9 @@ int imap_datecmp(char *datestr, time_t msgtime) {
        if (datestr == NULL) return(0);
 
        /* Expecting a date in the form dd-Mmm-yyyy */
-       extract_token(daystr, datestr, 0, '-');
-       extract_token(monthstr, datestr, 1, '-');
-       extract_token(yearstr, datestr, 2, '-');
+       extract_token(daystr, datestr, 0, '-', sizeof daystr);
+       extract_token(monthstr, datestr, 1, '-', sizeof monthstr);
+       extract_token(yearstr, datestr, 2, '-', sizeof yearstr);
 
        day = atoi(daystr);
        year = atoi(yearstr);
index fcb96cca88db8f82359890bd7bcd229243aaad73..f99c1b0756b115033e9dc03d47c1ea629aa18c68 100644 (file)
@@ -70,8 +70,8 @@ struct spamstrings_t *spamstrings = NULL;
 int CtdlHostAlias(char *fqdn) {
        int config_lines;
        int i;
-       char buf[SIZ];
-       char host[SIZ], type[SIZ];
+       char buf[256];
+       char host[256], type[256];
 
        if (fqdn == NULL) return(hostalias_nomatch);
        if (strlen(fqdn) == 0) return(hostalias_nomatch);
@@ -82,9 +82,9 @@ int CtdlHostAlias(char *fqdn) {
 
        config_lines = num_tokens(inetcfg, '\n');
        for (i=0; i<config_lines; ++i) {
-               extract_token(buf, inetcfg, i, '\n');
-               extract_token(host, buf, 0, '|');
-               extract_token(type, buf, 1, '|');
+               extract_token(buf, inetcfg, i, '\n', sizeof buf);
+               extract_token(host, buf, 0, '|', sizeof host);
+               extract_token(type, buf, 1, '|', sizeof type);
 
                if ( (!strcasecmp(type, "localhost"))
                   && (!strcasecmp(fqdn, host)))
@@ -549,21 +549,18 @@ void directory_key(char *key, char *addr) {
  * the directory
  */
 int IsDirectory(char *addr) {
-       char domain[SIZ];
+       char domain[256];
        int h;
 
-       extract_token(domain, addr, 1, '@');
+       extract_token(domain, addr, 1, '@', sizeof domain);
        striplt(domain);
 
        h = CtdlHostAlias(domain);
-       lprintf(CTDL_DEBUG, "IsDirectory(%s)\n", domain);
 
        if ( (h == hostalias_localhost) || (h == hostalias_directory) ) {
-               lprintf(CTDL_DEBUG, " ...yes\n");
                return(1);
        }
        else {
-               lprintf(CTDL_DEBUG, " ...no\n");
                return(0);
        }
 }
index c19f92316dd88c9f04b1b1b1c66218bc30e08eb9..a3ff5c028529102ac7f926f3b9de46fd1193475a 100644 (file)
@@ -95,7 +95,7 @@ int rbl_check_addr(struct in_addr *addr, char *message_to_spammer)
 {
        const char *i;
        int a1, a2, a3, a4;
-       char tbuf[SIZ];
+       char tbuf[256];
        int rbl;
        int num_rbl;
        char rbl_domains[SIZ];
@@ -117,12 +117,11 @@ int rbl_check_addr(struct in_addr *addr, char *message_to_spammer)
                snprintf(tbuf, sizeof tbuf,
                        "%d.%d.%d.%d.",
                        a4, a3, a2, a1);
-                extract(&tbuf[strlen(tbuf)], rbl_domains, rbl);
+                extract_token(&tbuf[strlen(tbuf)], rbl_domains, rbl, '|', (sizeof tbuf - strlen(tbuf)));
 
                if (gethostbyname(tbuf) != NULL) {
                        strcpy(message_to_spammer,
-                               "5.7.1 Message rejected due to "
-                               "known spammer source IP address"
+                               "5.7.1 Message rejected due to known spammer source IP address"
                        );
                        return(1);
                }
index 8e1f12884ca668e11f2ef0e09f33d8af54200df9..53949a7ad5ee8d7d2fb8e2bd5bbf8f0d7341efa1 100644 (file)
@@ -1766,7 +1766,7 @@ RMSGREAD: scr_flush();
                        if (r / 100 != 2) {
                                scr_printf("%s\n", cmd);
                        } else {
-                               extract(filename, cmd, 2);
+                               extract_token(filename, cmd, 2, '|', sizeof filename);
                                /*
                                 * Part 1 won't have a filename; use the
                                 * subject of the message instead. IO
@@ -1883,7 +1883,7 @@ void check_message_base(CtdlIPC *ipc)
 
        while (transcript && strlen(transcript)) {
                lines_printed = 1;
-               extract_token(buf, transcript, 0, '\n');
+               extract_token(buf, transcript, 0, '\n', sizeof buf);
                remove_token(transcript, 0, '\n');
                pprintf("%s\n", buf);
        }
index 7e4830858ea586c5d4d0d0b72021a8f150bcabf2..9ddf52142b7d0445f97a498523c50dc2ed60ec2c 100644 (file)
@@ -134,8 +134,8 @@ int alias(char *name)
        char *ignetcfg = NULL;
        char *ignetmap = NULL;
        int at = 0;
-       char node[SIZ];
-       char testnode[SIZ];
+       char node[64];
+       char testnode[64];
        char buf[SIZ];
 
        striplt(name);
@@ -190,7 +190,7 @@ int alias(char *name)
        remove_any_whitespace_to_the_left_or_right_of_at_symbol(name);
 
        /* figure out the delivery mode */
-       extract_token(node, name, 1, '@');
+       extract_token(node, name, 1, '@', sizeof node);
 
        /* If there are one or more dots in the nodename, we assume that it
         * is an FQDN and will attempt SMTP delivery to the Internet.
@@ -204,8 +204,8 @@ int alias(char *name)
         */
        ignetcfg = CtdlGetSysConfig(IGNETCFG);
        for (i=0; i<num_tokens(ignetcfg, '\n'); ++i) {
-               extract_token(buf, ignetcfg, i, '\n');
-               extract_token(testnode, buf, 0, '|');
+               extract_token(buf, ignetcfg, i, '\n', sizeof buf);
+               extract_token(testnode, buf, 0, '|', sizeof testnode);
                if (!strcasecmp(node, testnode)) {
                        free(ignetcfg);
                        return(MES_IGNET);
@@ -218,8 +218,8 @@ int alias(char *name)
         */
        ignetmap = CtdlGetSysConfig(IGNETMAP);
        for (i=0; i<num_tokens(ignetmap, '\n'); ++i) {
-               extract_token(buf, ignetmap, i, '\n');
-               extract_token(testnode, buf, 0, '|');
+               extract_token(buf, ignetmap, i, '\n', sizeof buf);
+               extract_token(testnode, buf, 0, '|', sizeof testnode);
                if (!strcasecmp(node, testnode)) {
                        free(ignetmap);
                        return(MES_IGNET);
@@ -536,7 +536,7 @@ void cmd_msgs(char *cmdbuf)
        int with_template = 0;
        struct CtdlMessage *template = NULL;
 
-       extract(which, cmdbuf, 0);
+       extract_token(which, cmdbuf, 0, '|', sizeof which);
        cm_ref = extract_int(cmdbuf, 1);
        with_template = extract_int(cmdbuf, 2);
 
@@ -566,8 +566,8 @@ void cmd_msgs(char *cmdbuf)
                        malloc(sizeof(struct CtdlMessage));
                memset(template, 0, sizeof(struct CtdlMessage));
                while(client_getln(buf, sizeof buf), strcmp(buf,"000")) {
-                       extract(tfield, buf, 0);
-                       extract(tvalue, buf, 1);
+                       extract_token(tfield, buf, 0, '|', sizeof tfield);
+                       extract_token(tvalue, buf, 1, '|', sizeof tvalue);
                        for (i='A'; i<='Z'; ++i) if (msgkeys[i]!=NULL) {
                                if (!strcasecmp(tfield, msgkeys[i])) {
                                        template->cm_fields[i] =
@@ -1001,7 +1001,7 @@ void choose_preferred(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, size_t length, char *encoding,
                void *cbuserdata)
 {
-       char buf[SIZ];
+       char buf[1024];
        int i;
        struct ma_info *ma;
        
@@ -1009,7 +1009,7 @@ void choose_preferred(char *name, char *filename, char *partnum, char *disp,
 
        if (ma->is_ma > 0) {
                for (i=0; i<num_tokens(CC->preferred_formats, '|'); ++i) {
-                       extract(buf, CC->preferred_formats, i);
+                       extract_token(buf, CC->preferred_formats, i, '|', sizeof buf);
                        if (!strcasecmp(buf, cbtype)) {
                                strcpy(ma->chosen_part, partnum);
                        }
@@ -1039,7 +1039,7 @@ void output_preferred(char *name, char *filename, char *partnum, char *disp,
         * list, we can simply output it verbatim.
         */
        for (i=0; i<num_tokens(CC->preferred_formats, '|'); ++i) {
-               extract(buf, CC->preferred_formats, i);
+               extract_token(buf, CC->preferred_formats, i, '|', sizeof buf);
                if (!strcasecmp(buf, cbtype)) {
                        /* Yeah!  Go!  W00t!! */
 
@@ -1609,12 +1609,11 @@ void cmd_msgp(char *cmdbuf)
 void cmd_opna(char *cmdbuf)
 {
        long msgid;
-       char desired_section[SIZ];
+       char desired_section[128];
 
        msgid = extract_long(cmdbuf, 0);
-       extract(desired_section, cmdbuf, 1);
+       extract_token(desired_section, cmdbuf, 1, '|', sizeof desired_section);
        safestrncpy(CC->download_desired_section, desired_section, sizeof CC->download_desired_section);
-
        CtdlOutputMsg(msgid, MT_DOWNLOAD, 0, 1, 1);
 }                      
 
@@ -2078,7 +2077,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        if (recps != NULL)
         if (recps->num_room > 0)
          for (i=0; i<num_tokens(recps->recp_room, '|'); ++i) {
-               extract(recipient, recps->recp_room, i);
+               extract_token(recipient, recps->recp_room, i, '|', sizeof recipient);
                lprintf(CTDL_DEBUG, "Delivering to local room <%s>\n", recipient);
                CtdlSaveMsgPointerInRoom(recipient, newmsgid, 0);
        }
@@ -2095,7 +2094,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        if (recps != NULL)
         if (recps->num_local > 0)
          for (i=0; i<num_tokens(recps->recp_local, '|'); ++i) {
-               extract(recipient, recps->recp_local, i);
+               extract_token(recipient, recps->recp_local, i, '|', sizeof recipient);
                lprintf(CTDL_DEBUG, "Delivering private local mail to <%s>\n",
                        recipient);
                if (getuser(&userbuf, recipient) == 0) {
@@ -2124,14 +2123,14 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,     /* message to save */
        if (recps != NULL)
         if (recps->num_ignet > 0)
          for (i=0; i<num_tokens(recps->recp_ignet, '|'); ++i) {
-               extract(recipient, recps->recp_ignet, i);
+               extract_token(recipient, recps->recp_ignet, i, '|', sizeof recipient);
 
                hold_R = msg->cm_fields['R'];
                hold_D = msg->cm_fields['D'];
                msg->cm_fields['R'] = malloc(SIZ);
-               msg->cm_fields['D'] = malloc(SIZ);
-               extract_token(msg->cm_fields['R'], recipient, 0, '@');
-               extract_token(msg->cm_fields['D'], recipient, 1, '@');
+               msg->cm_fields['D'] = malloc(128);
+               extract_token(msg->cm_fields['R'], recipient, 0, '@', SIZ);
+               extract_token(msg->cm_fields['D'], recipient, 1, '@', 128);
                
                serialize_message(&smr, msg);
                if (smr.len > 0) {
@@ -2175,7 +2174,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
 
                for (i=0; i<num_tokens(recps->recp_internet, '|'); ++i) {
                        size_t tmp = strlen(instr);
-                       extract(recipient, recps->recp_internet, i);
+                       extract_token(recipient, recps->recp_internet, i, '|', sizeof recipient);
                        snprintf(&instr[tmp], SIZ * 2 - tmp,
                                 "remote|%s|0||\n", recipient);
                }
@@ -2504,7 +2503,7 @@ struct recptypes *validate_recipients(char *recipients) {
        }
 
        if (num_recps > 0) for (i=0; i<num_recps; ++i) {
-               extract_token(this_recp, recipients, i, ',');
+               extract_token(this_recp, recipients, i, ',', sizeof this_recp);
                striplt(this_recp);
                lprintf(CTDL_DEBUG, "Evaluating recipient #%d <%s>\n", i, this_recp);
                mailtype = alias(this_recp);
@@ -2658,10 +2657,10 @@ void cmd_ent0(char *entargs)
        unbuffer_output();
 
        post = extract_int(entargs, 0);
-       extract(recp, entargs, 1);
+       extract_token(recp, entargs, 1, '|', sizeof recp);
        anon_flag = extract_int(entargs, 2);
        format_type = extract_int(entargs, 3);
-       extract(subject, entargs, 4);
+       extract_token(subject, entargs, 4, '|', sizeof subject);
        do_confirm = extract_int(entargs, 6);
 
        /* first check to make sure the request is valid. */
@@ -2680,7 +2679,7 @@ void cmd_ent0(char *entargs)
                                ERROR + HIGHER_ACCESS_REQUIRED);
                        return;
                }
-               extract(newusername, entargs, 5);
+               extract_token(newusername, entargs, 5, '|', sizeof newusername);
                memset(CC->fake_postname, 0, sizeof(CC->fake_postname) );
                safestrncpy(CC->fake_postname, newusername,
                        sizeof(CC->fake_postname) );
@@ -2968,7 +2967,7 @@ int CtdlCopyMsgToRoom(long msgnum, char *dest) {
 void cmd_move(char *args)
 {
        long num;
-       char targ[SIZ];
+       char targ[ROOMNAMELEN];
        struct ctdlroom qtemp;
        int err;
        int is_copy = 0;
@@ -2976,7 +2975,7 @@ void cmd_move(char *args)
        int permit = 0;
 
        num = extract_long(args, 0);
-       extract(targ, args, 1);
+       extract_token(targ, args, 1, '|', sizeof targ);
        targ[ROOMNAMELEN - 1] = 0;
        is_copy = extract_int(args, 2);
 
@@ -3290,7 +3289,7 @@ char *CtdlGetSysConfig(char *sysconfname) {
        getroom(&CC->room, hold_rm);
 
        if (conf != NULL) do {
-               extract_token(buf, conf, 0, '\n');
+               extract_token(buf, conf, 0, '\n', sizeof buf);
                strcpy(conf, &conf[strlen(buf)+1]);
        } while ( (strlen(conf)>0) && (strlen(buf)>0) );
 
@@ -3317,7 +3316,8 @@ void CtdlPutSysConfig(char *sysconfname, char *sysconfdata) {
 /*
  * Determine whether a given Internet address belongs to the current user
  */
-int CtdlIsMe(char *addr) {
+int CtdlIsMe(char *addr, int addr_buf_len)
+{
        struct recptypes *recp;
        int i;
 
@@ -3330,7 +3330,7 @@ int CtdlIsMe(char *addr) {
        }
 
        for (i=0; i<recp->num_local; ++i) {
-               extract(addr, recp->recp_local, i);
+               extract_token(addr, recp->recp_local, i, '|', addr_buf_len);
                if (!strcasecmp(addr, CC->user.fullname)) {
                        free(recp);
                        return(1);
@@ -3346,12 +3346,12 @@ int CtdlIsMe(char *addr) {
  * Citadel protocol command to do the same
  */
 void cmd_isme(char *argbuf) {
-       char addr[SIZ];
+       char addr[256];
 
        if (CtdlAccessCheck(ac_logged_in)) return;
-       extract(addr, argbuf, 0);
+       extract_token(addr, argbuf, 0, '|', sizeof addr);
 
-       if (CtdlIsMe(addr)) {
+       if (CtdlIsMe(addr, sizeof addr)) {
                cprintf("%d %s\n", CIT_OK, addr);
        }
        else {
index 876b6e46d4b3e6c9368e9b2b38f2106e7d35cd5a..009f975c542fb855689e92e812a90612390c6c03 100644 (file)
@@ -147,4 +147,4 @@ struct CtdlMessage *CtdlMakeMessage(
         char *preformatted_text         /* ...or NULL to read text from client */
 );
 int CtdlCheckInternetMailPermission(struct ctdluser *who);
-int CtdlIsMe(char *addr);
+int CtdlIsMe(char *addr, int addr_buf_len);
index c5f10b83d9cd21b9e9ac68ed1e20df3f2df73b8b..b2c489e5180ad034235aece4722c711b8c613288 100644 (file)
@@ -86,9 +86,9 @@ void GetExpirePolicy(struct ExpirePolicy *epbuf, struct ctdlroom *qrbuf) {
 void cmd_gpex(char *argbuf) {
        struct ExpirePolicy exp;
        struct floor *fl;
-       char which[SIZ];
+       char which[128];
 
-       extract(which, argbuf, 0);
+       extract_token(which, argbuf, 0, '|', sizeof which);
        if (!strcasecmp(which, "room")) {
                memcpy(&exp, &CC->room.QRep, sizeof(struct ExpirePolicy));
        }
@@ -117,10 +117,10 @@ void cmd_gpex(char *argbuf) {
 void cmd_spex(char *argbuf) {
        struct ExpirePolicy exp;
        struct floor flbuf;
-       char which[SIZ];
+       char which[128];
 
        memset(&exp, 0, sizeof(struct ExpirePolicy));
-       extract(which, argbuf, 0);
+       extract_token(which, argbuf, 0, '|', sizeof which);
        exp.expire_mode = extract_int(argbuf, 1);
        exp.expire_value = extract_int(argbuf, 2);
 
index a03b349b525308b9c31f4dd33013a740421770e9..b49d7ed179d73127037f245b4ed09eb2b8b0ce3e 100644 (file)
@@ -893,27 +893,27 @@ void cmd_goto(char *gargs)
        int c;
        int ok = 0;
        int ra;
-       char augmented_roomname[SIZ];
-       char towhere[SIZ];
-       char password[SIZ];
+       char augmented_roomname[ROOMNAMELEN];
+       char towhere[ROOMNAMELEN];
+       char password[32];
        int transiently = 0;
 
        if (CtdlAccessCheck(ac_logged_in)) return;
 
-       extract(towhere, gargs, 0);
-       extract(password, gargs, 1);
+       extract_token(towhere, gargs, 0, '|', sizeof towhere);
+       extract_token(password, gargs, 1, '|', sizeof password);
        transiently = extract_int(gargs, 2);
 
        getuser(&CC->user, CC->curr_user);
 
        if (!strcasecmp(towhere, "_BASEROOM_"))
-               strcpy(towhere, config.c_baseroom);
+               safestrncpy(towhere, config.c_baseroom, sizeof towhere);
 
        if (!strcasecmp(towhere, "_MAIL_"))
-               strcpy(towhere, MAILROOM);
+               safestrncpy(towhere, MAILROOM, sizeof towhere);
 
        if (!strcasecmp(towhere, "_BITBUCKET_"))
-               strcpy(towhere, config.c_twitroom);
+               safestrncpy(towhere, config.c_twitroom, sizeof towhere);
 
 
        /* First try a regular match */
@@ -925,7 +925,7 @@ void cmd_goto(char *gargs)
                            &CC->user, towhere);
                c = getroom(&QRscratch, augmented_roomname);
                if (c == 0)
-                       strcpy(towhere, augmented_roomname);
+                       safestrncpy(towhere, augmented_roomname, sizeof towhere);
        }
 
        /* And if the room was found... */
@@ -1245,7 +1245,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
  */
 void cmd_setr(char *args)
 {
-       char buf[SIZ];
+       char buf[256];
        int new_order = 0;
        int r;
        int new_floor;
@@ -1267,7 +1267,7 @@ void cmd_setr(char *args)
        } else {
                strcpy(new_name, "");
        }
-       extract(&new_name[strlen(new_name)], args, 0);
+       extract_token(&new_name[strlen(new_name)], args, 0, '|', (sizeof new_name - strlen(new_name)));
 
        r = CtdlRenameRoom(CC->room.QRname, new_name, new_floor);
 
@@ -1309,7 +1309,7 @@ void cmd_setr(char *args)
        lgetroom(&CC->room, CC->room.QRname);
 
        /* Directory room */
-       extract(buf, args, 2);
+       extract_token(buf, args, 2, '|', sizeof buf);
        buf[15] = 0;
        safestrncpy(CC->room.QRdirname, buf,
                sizeof CC->room.QRdirname);
@@ -1347,7 +1347,7 @@ void cmd_setr(char *args)
                if (num_parms(args) >= 7)
                        CC->room.QRorder = (char) new_order;
                /* Room password */
-               extract(buf, args, 1);
+               extract_token(buf, args, 1, '|', sizeof buf);
                buf[10] = 0;
                safestrncpy(CC->room.QRpasswd, buf,
                            sizeof CC->room.QRpasswd);
@@ -1371,8 +1371,7 @@ void cmd_setr(char *args)
 
        /* Create a room directory if necessary */
        if (CC->room.QRflags & QR_DIRECTORY) {
-               snprintf(buf, sizeof buf, "./files/%s",
-                       CC->room.QRdirname);
+               snprintf(buf, sizeof buf, "./files/%s", CC->room.QRdirname);
                mkdir(buf, 0755);
        }
        snprintf(buf, sizeof buf, "%s> edited by %s\n", CC->room.QRname, CC->curr_user);
@@ -1700,21 +1699,21 @@ unsigned create_room(char *new_room_name,
 void cmd_cre8(char *args)
 {
        int cre8_ok;
-       char new_room_name[SIZ];
+       char new_room_name[ROOMNAMELEN];
        int new_room_type;
-       char new_room_pass[SIZ];
+       char new_room_pass[32];
        int new_room_floor;
        int new_room_view;
-       char aaa[SIZ];
+       char *notification_message = NULL;
        unsigned newflags;
        struct floor *fl;
        int avoid_access = 0;
 
        cre8_ok = extract_int(args, 0);
-       extract(new_room_name, args, 1);
+       extract_token(new_room_name, args, 1, '|', sizeof new_room_name);
        new_room_name[ROOMNAMELEN - 1] = 0;
        new_room_type = extract_int(args, 2);
-       extract(new_room_pass, args, 3);
+       extract_token(new_room_pass, args, 3, '|', sizeof new_room_pass);
        avoid_access = extract_int(args, 5);
        new_room_view = extract_int(args, 6);
        new_room_pass[9] = 0;
@@ -1795,21 +1794,19 @@ void cmd_cre8(char *args)
                           new_room_view);
 
        /* post a message in Aide> describing the new room */
-       safestrncpy(aaa, new_room_name, sizeof aaa);
-       strcat(aaa, "> created by ");
-       strcat(aaa, CC->user.fullname);
-       if (newflags & QR_MAILBOX)
-               strcat(aaa, " [personal]");
-       else if (newflags & QR_PRIVATE)
-               strcat(aaa, " [private]");
-       if (newflags & QR_GUESSNAME)
-               strcat(aaa, "[guessname] ");
-       if (newflags & QR_PASSWORDED) {
-               strcat(aaa, "\n Password: ");
-               strcat(aaa, new_room_pass);
-       }
-       strcat(aaa, "\n");
-       aide_message(aaa);
+       notification_message = malloc(1024);
+       snprintf(notification_message, 1024,
+               "%s> created by %s%s%s%s%s%s\n",
+               new_room_name,
+               CC->user.fullname,
+               ((newflags & QR_MAILBOX) ? " [personal]" : ""),
+               ((newflags & QR_PRIVATE) ? " [private]" : ""),
+               ((newflags & QR_GUESSNAME) ? " [hidden]" : ""),
+               ((newflags & QR_PASSWORDED) ? " Password: " : ""),
+               ((newflags & QR_PASSWORDED) ? new_room_pass : "")
+       );
+       aide_message(notification_message);
+       free(notification_message);
 
        cprintf("%d '%s' has been created.\n", CIT_OK, new_room_name);
 }
@@ -1886,13 +1883,13 @@ void cmd_lflr(void)
  */
 void cmd_cflr(char *argbuf)
 {
-       char new_floor_name[SIZ];
+       char new_floor_name[256];
        struct floor flbuf;
        int cflr_ok;
        int free_slot = (-1);
        int a;
 
-       extract(new_floor_name, argbuf, 0);
+       extract_token(new_floor_name, argbuf, 0, '|', sizeof new_floor_name);
        cflr_ok = extract_int(argbuf, 1);
 
        if (CtdlAccessCheck(ac_aide)) return;
@@ -2010,7 +2007,7 @@ void cmd_eflr(char *argbuf)
                return;
        }
        if (np >= 2)
-               extract(flbuf.f_name, argbuf, 1);
+               extract_token(flbuf.f_name, argbuf, 1, '|', sizeof flbuf.f_name);
        lputfloor(&flbuf, floor_num);
 
        cprintf("%d Ok\n", CIT_OK);
index 562e04e06be7a16acb5a9d3c1a88ee6ec7e925c9..bb088a1afb7eb3f6b5ab1fe861564327f6a2925b 100644 (file)
@@ -79,9 +79,9 @@ void load_floorlist(CtdlIPC *ipc)
                return;
        }
        while (*listing && strlen(listing)) {
-               extract_token(buf, listing, 0, '\n');
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
-               extract(floorlist[extract_int(buf, 0)], buf, 1);
+               extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', SIZ);
        }
        free(listing);
 }
@@ -841,10 +841,10 @@ void download(CtdlIPC *ipc, int proto)
  */
 void roomdir(CtdlIPC *ipc)
 {
-       char flnm[SIZ];
+       char flnm[256];
        char flsz[32];
-       char comment[SIZ];
-       char buf[SIZ];
+       char comment[256];
+       char buf[256];
        char *listing = NULL;   /* Returned directory listing */
        int r;
 
@@ -854,17 +854,17 @@ void roomdir(CtdlIPC *ipc)
                return;
        }
 
-       extract(comment, buf, 0);
-       extract(flnm, buf, 1);
+       extract_token(comment, buf, 0, '|', sizeof comment);
+       extract_token(flnm, buf, 1, '|', sizeof flnm);
        pprintf("\nDirectory of %s on %s\n", flnm, comment);
        pprintf("-----------------------\n");
        while (*listing && strlen(listing)) {
-               extract_token(buf, listing, 0, '\n');
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
 
-               extract(flnm, buf, 0);
-               extract(flsz, buf, 1);
-               extract(comment, buf, 2);
+               extract_token(flnm, buf, 0, '|', sizeof flnm);
+               extract_token(flsz, buf, 1, '|', sizeof flsz);
+               extract_token(comment, buf, 2, '|', sizeof comment);
                if (strlen(flnm) <= 14)
                        pprintf("%-14s %8s %s\n", flnm, flsz, comment);
                else
@@ -1076,7 +1076,7 @@ void readinfo(CtdlIPC *ipc)
  */
 void whoknows(CtdlIPC *ipc)
 {
-       char buf[SIZ];
+       char buf[256];
        char *listing = NULL;
        int r;
 
@@ -1086,7 +1086,7 @@ void whoknows(CtdlIPC *ipc)
                return;
        }
        while (strlen(listing) > 0) {
-               extract_token(buf, listing, 0, '\n');
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
                if (sigcaught == 0)
                        pprintf("%s\n", buf);
index 3202f7996ca328c1bf32124282ccb23df6094b19..9e0c5aa682fa3eeb7b1f7242f22f9634d959a7c7 100644 (file)
@@ -90,16 +90,16 @@ void entregis(CtdlIPC *ipc)
 {                              /* register with name and address */
 
        char buf[SIZ];
-       char tmpname[SIZ];
-       char tmpaddr[SIZ];
-       char tmpcity[SIZ];
-       char tmpstate[SIZ];
-       char tmpzip[SIZ];
-       char tmpphone[SIZ];
+       char tmpname[30];
+       char tmpaddr[25];
+       char tmpcity[15];
+       char tmpstate[3];
+       char tmpzip[11];
+       char tmpphone[15];
        char tmpemail[SIZ];
-       char tmpcountry[SIZ];
-       char diruser[SIZ];
-       char dirnode[SIZ];
+       char tmpcountry[32];
+       char diruser[256];
+       char dirnode[256];
        char holdemail[SIZ];
        char *reg = NULL;
        int ok = 0;
@@ -120,25 +120,25 @@ void entregis(CtdlIPC *ipc)
 
                while (reg && strlen(reg) > 0) {
 
-                       extract_token(buf, reg, 0, '\n');
+                       extract_token(buf, reg, 0, '\n', sizeof buf);
                        remove_token(reg, 0, '\n');
 
                        if (a == 2)
-                               strcpy(tmpname, buf);
+                               safestrncpy(tmpname, buf, sizeof tmpname);
                        else if (a == 3)
-                               strcpy(tmpaddr, buf);
+                               safestrncpy(tmpaddr, buf, sizeof tmpaddr);
                        else if (a == 4)
-                               strcpy(tmpcity, buf);
+                               safestrncpy(tmpcity, buf, sizeof tmpcity);
                        else if (a == 5)
-                               strcpy(tmpstate, buf);
+                               safestrncpy(tmpstate, buf, sizeof tmpstate);
                        else if (a == 6)
-                               strcpy(tmpzip, buf);
+                               safestrncpy(tmpzip, buf, sizeof tmpzip);
                        else if (a == 7)
-                               strcpy(tmpphone, buf);
+                               safestrncpy(tmpphone, buf, sizeof tmpphone);
                        else if (a == 9)
-                               strcpy(tmpemail, buf);
+                               safestrncpy(tmpemail, buf, sizeof tmpemail);
                        else if (a == 10)
-                               strcpy(tmpcountry, buf);
+                               safestrncpy(tmpcountry, buf, sizeof tmpcountry);
                        ++a;
                }
        }
@@ -152,12 +152,12 @@ void entregis(CtdlIPC *ipc)
 
        do {
                ok = 1;
-               strcpy(holdemail, tmpemail);
+               safestrncpy(holdemail, tmpemail, sizeof holdemail);
                strprompt("Email address", tmpemail, 31);
                r = CtdlIPCDirectoryLookup(ipc, tmpemail, buf);
                if (r / 100 == 2) {
-                       extract_token(diruser, buf, 0, '@');
-                       extract_token(dirnode, buf, 1, '@');
+                       extract_token(diruser, buf, 0, '@', sizeof diruser);
+                       extract_token(dirnode, buf, 1, '@', sizeof dirnode);
                        striplt(diruser);
                        striplt(dirnode);
                        if ((strcasecmp(diruser, fullname))
@@ -169,13 +169,13 @@ void entregis(CtdlIPC *ipc)
                                        "It is already in use by %s @ %s.\n",
                                        diruser, dirnode);
                                ok = 0;
-                               strcpy(tmpemail, holdemail);
+                               safestrncpy(tmpemail, holdemail, sizeof tmpemail);
                        }
                }
        } while (ok == 0);
 
        /* now send the registration info back to the server */
-       reg = (char *)realloc(reg, 4096);       /* Overkill? */
+       reg = (char *)realloc(reg, SIZ);
        if (reg) {
                sprintf(reg, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
                        tmpname, tmpaddr, tmpcity, tmpstate,
@@ -259,7 +259,7 @@ void cli_upload(CtdlIPC *ipc)
                if (haschar(tbuf, '/'))
                        extract_token(tbuf, flnm,
                                num_tokens(tbuf, '/') - 1,
-                               '/'
+                               '/', sizeof tbuf
                        );
                /* filename.1, filename.2, etc */
                if (a > 0) {
@@ -425,7 +425,7 @@ int val_user(CtdlIPC *ipc, char *user, int do_validate)
        if (r / 100 == 1) {
                a = 0;
                do {
-                       extract_token(buf, resp, 0, '\n');
+                       extract_token(buf, resp, 0, '\n', sizeof buf);
                        remove_token(resp, 0, '\n');
                        ++a;
                        if (a == 1)
@@ -501,7 +501,7 @@ void validate(CtdlIPC *ipc)
                if (r / 100 == 2)
                        scr_printf("%s\n", cmd);
                if (r / 100 == 3) {
-                       extract(buf, cmd, 0);
+                       extract_token(buf, cmd, 0, '|', sizeof buf);
                        if (val_user(ipc, buf, 1) != 0) finished = 1;
                }
        } while (finished == 0);
@@ -593,7 +593,7 @@ void list_bio(CtdlIPC *ipc)
                return;
        }
        while (strlen(resp)) {
-               extract_token(buf, resp, 0, '\n');
+               extract_token(buf, resp, 0, '\n', sizeof buf);
                remove_token(resp, 0, '\n');
                if ((pos + strlen(buf) + 5) > screenwidth) {
                        pprintf("\n");
@@ -630,7 +630,7 @@ void read_bio(CtdlIPC *ipc)
                return;
        }
        while (strlen(resp)) {
-               extract_token(buf, resp, 0, '\n');
+               extract_token(buf, resp, 0, '\n', sizeof buf);
                remove_token(resp, 0, '\n');
                pprintf("%s\n", buf);
        }
@@ -663,7 +663,7 @@ void do_system_configuration(CtdlIPC *ipc)
        if (r / 100 == 1) {
                a = 0;
                while (strlen(resp)) {
-                       extract_token(buf, resp, 0, '\n');
+                       extract_token(buf, resp, 0, '\n', sizeof buf);
                        remove_token(resp, 0, '\n');
                        if (a < NUM_CONFIGS) {
                                strcpy(&sc[a][0], buf);
@@ -916,7 +916,7 @@ void do_internet_configuration(CtdlIPC *ipc)
        r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf);
        if (r / 100 == 1) {
                while (strlen(resp)) {
-                       extract_token(buf, resp, 0, '\n');
+                       extract_token(buf, resp, 0, '\n', sizeof buf);
                        remove_token(resp, 0, '\n');
                        ++num_recs;
                        if (num_recs == 1) recs = malloc(sizeof(char *));
@@ -936,10 +936,10 @@ void do_internet_configuration(CtdlIPC *ipc)
                for (i=0; i<num_recs; ++i) {
                color(DIM_WHITE);
                scr_printf("%3d ", i+1);
-               extract(buf, recs[i], 0);
+               extract_token(buf, recs[i], 0, '|', sizeof buf);
                color(BRIGHT_CYAN);
                scr_printf("%-50s ", buf);
-               extract(buf, recs[i], 1);
+               extract_token(buf, recs[i], 1, '|', sizeof buf);
                color(BRIGHT_MAGENTA);
                scr_printf("%-20s\n", buf);
                color(DIM_WHITE);
@@ -1053,13 +1053,13 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
        r = CtdlIPCGetRoomNetworkConfig(ipc, &listing, buf);
        if (r / 100 == 1) {
                while(listing && strlen(listing)) {
-                       extract_token(buf, listing, 0, '\n');
+                       extract_token(buf, listing, 0, '\n', sizeof buf);
                        remove_token(listing, 0, '\n');
-                       extract(instr, buf, 0);
+                       extract_token(instr, buf, 0, '|', sizeof instr);
                        if (!strcasecmp(instr, entrytype)) {
                                tokens = num_tokens(buf, '|');
                                for (i=1; i<tokens; ++i) {
-                                       extract(addr, buf, i);
+                                       extract_token(addr, buf, i, '|', sizeof addr);
                                        fprintf(tempfp, "%s", addr);
                                        if (i < (tokens-1)) {
                                                fprintf(tempfp, "|");
@@ -1106,9 +1106,9 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
                r = CtdlIPCGetRoomNetworkConfig(ipc, &listing, buf);
                if (r / 100 == 1) {
                        while(listing && strlen(listing)) {
-                               extract_token(buf, listing, 0, '\n');
+                               extract_token(buf, listing, 0, '\n', sizeof buf);
                                remove_token(listing, 0, '\n');
-                               extract(instr, buf, 0);
+                               extract_token(instr, buf, 0, '|', sizeof instr);
                                if (strcasecmp(instr, entrytype)) {
                                        fprintf(changefp, "%s\n", buf);
                                }
@@ -1166,7 +1166,7 @@ void do_ignet_configuration(CtdlIPC *ipc) {
 
        r = CtdlIPCGetSystemConfigByType(ipc, IGNETCFG, &listing, buf);
        if (r / 100 == 1) while (*listing && strlen(listing)) {
-               extract_token(buf, listing, 0, '\n');
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
 
                ++num_recs;
@@ -1194,16 +1194,16 @@ void do_ignet_configuration(CtdlIPC *ipc) {
                for (i=0; i<num_recs; ++i) {
                color(DIM_WHITE);
                scr_printf("%3d ", i+1);
-               extract(buf, recs[i], 0);
+               extract_token(buf, recs[i], 0, '|', sizeof buf);
                color(BRIGHT_CYAN);
                scr_printf("%-16s ", buf);
-               extract(buf, recs[i], 1);
+               extract_token(buf, recs[i], 1, '|', sizeof buf);
                color(BRIGHT_MAGENTA);
                scr_printf("%-18s ", buf);
-               extract(buf, recs[i], 2);
+               extract_token(buf, recs[i], 2, '|', sizeof buf);
                color(BRIGHT_CYAN);
                scr_printf("%-32s ", buf);
-               extract(buf, recs[i], 3);
+               extract_token(buf, recs[i], 3, '|', sizeof buf);
                color(BRIGHT_MAGENTA);
                scr_printf("%-3s\n", buf);
                color(DIM_WHITE);
@@ -1294,7 +1294,7 @@ void do_filterlist_configuration(CtdlIPC *ipc)
 
        r = CtdlIPCGetSystemConfigByType(ipc, FILTERLIST, &listing, buf);
        if (r / 100 == 1) while (*listing && strlen(listing)) {
-               extract_token(buf, listing, 0, '\n');
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
 
                ++num_recs;
@@ -1322,16 +1322,16 @@ void do_filterlist_configuration(CtdlIPC *ipc)
                for (i=0; i<num_recs; ++i) {
                color(DIM_WHITE);
                scr_printf("%3d ", i+1);
-               extract(buf, recs[i], 0);
+               extract_token(buf, recs[i], 0, '|', sizeof buf);
                color(BRIGHT_CYAN);
                scr_printf("%-28s ", buf);
-               extract(buf, recs[i], 1);
+               extract_token(buf, recs[i], 1, '|', sizeof buf);
                color(BRIGHT_MAGENTA);
                scr_printf("%-28s ", buf);
-               extract(buf, recs[i], 2);
+               extract_token(buf, recs[i], 2, '|', sizeof buf);
                color(BRIGHT_CYAN);
                scr_printf("%-16s\n", buf);
-               extract(buf, recs[i], 3);
+               extract_token(buf, recs[i], 3, '|', sizeof buf);
                color(DIM_WHITE);
                }
 
index 987e1df788571e87b48beb8ca3ad86002a55b6f5..0331b13e19e7aab644eceb06ae9855e74c19d3d8 100644 (file)
@@ -84,11 +84,11 @@ void cmd_ebio(char *cmdbuf) {
 void cmd_rbio(char *cmdbuf)
 {
        struct ctdluser ruser;
-       char buf[SIZ];
+       char buf[256];
        FILE *fp;
 
-       extract(buf,cmdbuf,0);
-       if (getuser(&ruser,buf)!=0) {
+       extract_token(buf, cmdbuf, 0, '|', sizeof buf);
+       if (getuser(&ruser, buf) != 0) {
                cprintf("%d No such user.\n",ERROR + NO_SUCH_USER);
                return;
        }
@@ -101,7 +101,7 @@ void cmd_rbio(char *cmdbuf)
        if (fp == NULL)
                cprintf("%s has no bio on file.\n", ruser.fullname);
        else {
-               while (fgets(buf,256,fp)!=NULL) cprintf("%s",buf);
+               while (fgets(buf, sizeof buf, fp) != NULL) cprintf("%s",buf);
                fclose(fp);
        }
        cprintf("000\n");
@@ -111,20 +111,20 @@ void cmd_rbio(char *cmdbuf)
  * list of users who have entered bios
  */
 void cmd_lbio(char *cmdbuf) {
-       char buf[SIZ];
+       char buf[256];
        FILE *ls;
        struct ctdluser usbuf;
 
-       ls=popen("cd ./bio; ls","r");
-       if (ls==NULL) {
-               cprintf("%d Cannot open listing.\n",ERROR + FILE_NOT_FOUND);
+       ls = popen("cd ./bio; ls", "r");
+       if (ls == NULL) {
+               cprintf("%d Cannot open listing.\n", ERROR + FILE_NOT_FOUND);
                return;
        }
 
-       cprintf("%d\n",LISTING_FOLLOWS);
-       while (fgets(buf,sizeof buf,ls)!=NULL)
+       cprintf("%d\n", LISTING_FOLLOWS);
+       while (fgets(buf, sizeof buf, ls)!=NULL)
                if (getuserbynumber(&usbuf,atol(buf))==0)
-                       cprintf("%s\n",usbuf.fullname);
+                       cprintf("%s\n", usbuf.fullname);
        pclose(ls);
        cprintf("000\n");
 }
index 7d28b940377618b40cc75e5a7fa3b8fe741b3222..1381174a51654e9d3f2c23227c1175db1afe4a3c 100644 (file)
@@ -1175,9 +1175,9 @@ void ical_freebusy(char *who) {
        icalcomponent *fb = NULL;
        int found_user = (-1);
        struct recptypes *recp = NULL;
-       char buf[SIZ];
-       char host[SIZ];
-       char type[SIZ];
+       char buf[256];
+       char host[256];
+       char type[256];
        int i = 0;
        int config_lines = 0;
 
@@ -1218,9 +1218,9 @@ void ical_freebusy(char *who) {
        if (found_user != 0) {
                config_lines = num_tokens(inetcfg, '\n');
                for (i=0; ((i < config_lines) && (found_user != 0)); ++i) {
-                       extract_token(buf, inetcfg, i, '\n');
-                       extract_token(host, buf, 0, '|');
-                       extract_token(type, buf, 1, '|');
+                       extract_token(buf, inetcfg, i, '\n', sizeof buf);
+                       extract_token(host, buf, 0, '|', sizeof host);
+                       extract_token(type, buf, 1, '|', sizeof type);
 
                        if ( (!strcasecmp(type, "localhost"))
                           || (!strcasecmp(type, "directory")) ) {
@@ -1336,13 +1336,13 @@ void ical_freebusy(char *who) {
  */
 void cmd_ical(char *argbuf)
 {
-       char subcmd[SIZ];
+       char subcmd[64];
        long msgnum;
-       char partnum[SIZ];
-       char action[SIZ];
-       char who[SIZ];
+       char partnum[256];
+       char action[256];
+       char who[256];
 
-       extract(subcmd, argbuf, 0);
+       extract_token(subcmd, argbuf, 0, '|', sizeof subcmd);
 
        /* Allow "test" and "freebusy" subcommands without logging in. */
 
@@ -1352,7 +1352,7 @@ void cmd_ical(char *argbuf)
        }
 
        if (!strcasecmp(subcmd, "freebusy")) {
-               extract(who, argbuf, 1);
+               extract_token(who, argbuf, 1, '|', sizeof who);
                ical_freebusy(who);
                return;
        }
@@ -1369,23 +1369,23 @@ void cmd_ical(char *argbuf)
 
        if (!strcasecmp(subcmd, "respond")) {
                msgnum = extract_long(argbuf, 1);
-               extract(partnum, argbuf, 2);
-               extract(action, argbuf, 3);
+               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+               extract_token(action, argbuf, 3, '|', sizeof action);
                ical_respond(msgnum, partnum, action);
                return;
        }
 
        if (!strcasecmp(subcmd, "handle_rsvp")) {
                msgnum = extract_long(argbuf, 1);
-               extract(partnum, argbuf, 2);
-               extract(action, argbuf, 3);
+               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+               extract_token(action, argbuf, 3, '|', sizeof action);
                ical_handle_rsvp(msgnum, partnum, action);
                return;
        }
 
        if (!strcasecmp(subcmd, "conflicts")) {
                msgnum = extract_long(argbuf, 1);
-               extract(partnum, argbuf, 2);
+               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
                ical_conflicts(msgnum, partnum);
                return;
        }
@@ -1471,7 +1471,7 @@ void ical_send_out_invitations(icalcomponent *cal) {
        struct recptypes *valid = NULL;
        char attendees_string[SIZ];
        int num_attendees = 0;
-       char this_attendee[SIZ];
+       char this_attendee[256];
        icalproperty *attendee = NULL;
        char summary_string[SIZ];
        icalproperty *summary = NULL;
@@ -1515,11 +1515,11 @@ void ical_send_out_invitations(icalcomponent *cal) {
        strcpy(attendees_string, "");
        for (attendee = icalcomponent_get_first_property(the_request, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(the_request, ICAL_ATTENDEE_PROPERTY)) {
                if (icalproperty_get_attendee(attendee)) {
-                       strcpy(this_attendee, icalproperty_get_attendee(attendee) );
+                       safestrncpy(this_attendee, icalproperty_get_attendee(attendee), sizeof this_attendee);
                        if (!strncasecmp(this_attendee, "MAILTO:", 7)) {
                                strcpy(this_attendee, &this_attendee[7]);
 
-                               if (!CtdlIsMe(this_attendee)) { /* don't send an invitation to myself! */
+                               if (!CtdlIsMe(this_attendee, sizeof this_attendee)) {   /* don't send an invitation to myself! */
                                        snprintf(&attendees_string[strlen(attendees_string)],
                                                sizeof(attendees_string) - strlen(attendees_string),
                                                "%s, ",
@@ -1639,7 +1639,7 @@ void ical_saving_vevent(icalcomponent *cal) {
                         * If the user saving the event is listed as the
                         * organizer, then send out invitations.
                         */
-                       if (CtdlIsMe(organizer_string)) {
+                       if (CtdlIsMe(organizer_string, sizeof organizer_string)) {
                                ical_send_out_invitations(cal);
                        }
                }
index e8d1e46eee6fb9ebfa978033db636c973db106ec..fd941f51643d8f676b9e3b3bef71697d71478787 100644 (file)
@@ -667,8 +667,8 @@ int send_instant_message(char *lun, char *x_user, char *x_msg)
 void cmd_sexp(char *argbuf)
 {
        int message_sent = 0;
-       char x_user[SIZ];
-       char x_msg[SIZ];
+       char x_user[USERNAME_SIZE];
+       char x_msg[1024];
        char *lun;              /* <bc> */
        char *x_big_msgbuf = NULL;
 
@@ -681,9 +681,8 @@ void cmd_sexp(char *argbuf)
        else
                lun = CC->user.fullname;
 
-       extract(x_user, argbuf, 0);
-
-       extract(x_msg, argbuf, 1);
+       extract_token(x_user, argbuf, 0, '|', sizeof x_user);
+       extract_token(x_msg, argbuf, 1, '|', sizeof x_msg);
 
        if (!x_user[0]) {
                cprintf("%d You were not previously paged.\n", ERROR + NO_SUCH_USER);
index 93ff9990f590fd2c93fdca1e58546008dd95bbc8..89b5e5d66bdbd925e9ab0ae56096045f07320520 100644 (file)
@@ -61,7 +61,7 @@ void inetcfg_setTo(struct CtdlMessage *msg) {
 
        if (conf != NULL) {
                do {
-                       extract_token(buf, conf, 0, '\n');
+                       extract_token(buf, conf, 0, '\n', sizeof buf);
                        strcpy(conf, &conf[strlen(buf)+1]);
                } while ( (strlen(conf)>0) && (strlen(buf)>0) );
 
@@ -93,7 +93,7 @@ void spamstrings_setTo(struct CtdlMessage *msg) {
 
        n = num_tokens(conf, '\n');
        for (i=0; i<n; ++i) {
-               extract_token(buf, conf, i, '\n');
+               extract_token(buf, conf, i, '\n', sizeof buf);
                sptr = malloc(sizeof(struct spamstrings_t));
                sptr->string = strdup(buf);
                sptr->next = spamstrings;
index ca81ae5d9c6c640deb5cce55fcec7aaf160e5657..1dff8761ff94da6b8eb420c8074f69bf0fe2eac7 100644 (file)
@@ -220,14 +220,14 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) {
        int have_addr = 0;
        int have_cn = 0;
 
-       char givenname[SIZ];
-       char sn[SIZ];
-       char uid[SIZ];
-       char street[SIZ];
-       char city[SIZ];
-       char state[SIZ];
-       char zipcode[SIZ];
-       char calFBURL[SIZ];
+       char givenname[128];
+       char sn[128];
+       char uid[256];
+       char street[256];
+       char city[128];
+       char state[3];
+       char zipcode[10];
+       char calFBURL[256];
 
        if (dirserver == NULL) return;
        if (msg == NULL) return;
@@ -290,8 +290,8 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) {
        if (v->numprops) for (i=0; i<(v->numprops); ++i) if (striplt(v->prop[i].value), strlen(v->prop[i].value) > 0) {
 
                if (!strcasecmp(v->prop[i].name, "n")) {
-                       extract_token(sn,               v->prop[i].value, 0, ';');
-                       extract_token(givenname,        v->prop[i].value, 1, ';');
+                       extract_token(sn,               v->prop[i].value, 0, ';', sizeof sn);
+                       extract_token(givenname,        v->prop[i].value, 1, ';', sizeof givenname);
                }
 
                if (!strcasecmp(v->prop[i].name, "fn")) {
@@ -335,17 +335,17 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) {
                                have_addr = 1;
                                strcpy(street, "");
                                extract_token(&street[strlen(street)],
-                                       v->prop[i].value, 0, ';'); /* po box */
+                                       v->prop[i].value, 0, ';', (sizeof street - strlen(street))); /* po box */
                                strcat(street, " ");
                                extract_token(&street[strlen(street)],
-                                       v->prop[i].value, 1, ';'); /* extend addr */
+                                       v->prop[i].value, 1, ';', (sizeof street - strlen(street))); /* extend addr */
                                strcat(street, " ");
                                extract_token(&street[strlen(street)],
-                                       v->prop[i].value, 2, ';'); /* street */
+                                       v->prop[i].value, 2, ';', (sizeof street - strlen(street))); /* street */
                                striplt(street);
-                               extract_token(city, v->prop[i].value, 3, ';');
-                               extract_token(state, v->prop[i].value, 4, ';');
-                               extract_token(zipcode, v->prop[i].value, 5, ';');
+                               extract_token(city, v->prop[i].value, 3, ';', sizeof city);
+                               extract_token(state, v->prop[i].value, 4, ';', sizeof state);
+                               extract_token(zipcode, v->prop[i].value, 5, ';', sizeof zipcode);
 
                                attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) );
                                attrs[num_attrs-1] = malloc(sizeof(LDAPMod));
index e7481d139d6691f2b1479b7afb175af2965bb1b4..1e668ca48c9e16401efc3d484b7fcf9ba59f7434 100644 (file)
@@ -83,13 +83,13 @@ void listsub_generate_token(char *buf) {
 void do_subscribe(char *room, char *email, char *subtype, char *webpage) {
        struct ctdlroom qrbuf;
        FILE *ncfp;
-       char filename[SIZ];
-       char token[SIZ];
-       char confirmation_request[SIZ];
-       char buf[SIZ];
-       char urlroom[SIZ];
-       char scancmd[SIZ];
-       char scanemail[SIZ];
+       char filename[256];
+       char token[256];
+       char confirmation_request[512];
+       char buf[512];
+       char urlroom[ROOMNAMELEN];
+       char scancmd[64];
+       char scanemail[256];
        int found_sub = 0;
 
        if (getroom(&qrbuf, room) != 0) {
@@ -116,8 +116,8 @@ void do_subscribe(char *room, char *email, char *subtype, char *webpage) {
        if (ncfp != NULL) {
                while (fgets(buf, sizeof buf, ncfp) != NULL) {
                        buf[strlen(buf)-1] = 0;
-                       extract(scancmd, buf, 0);
-                       extract(scanemail, buf, 1);
+                       extract_token(scancmd, buf, 0, '|', sizeof scancmd);
+                       extract_token(scanemail, buf, 1, '|', sizeof scanemail);
                        if ((!strcasecmp(scancmd, "listrecp"))
                           || (!strcasecmp(scancmd, "digestrecp"))) {
                                if (!strcasecmp(scanemail, email)) {
@@ -195,13 +195,13 @@ void do_subscribe(char *room, char *email, char *subtype, char *webpage) {
 void do_unsubscribe(char *room, char *email, char *webpage) {
        struct ctdlroom qrbuf;
        FILE *ncfp;
-       char filename[SIZ];
-       char token[SIZ];
-       char buf[SIZ];
-       char confirmation_request[SIZ];
-       char urlroom[SIZ];
-       char scancmd[SIZ];
-       char scanemail[SIZ];
+       char filename[256];
+       char token[256];
+       char buf[512];
+       char confirmation_request[512];
+       char urlroom[ROOMNAMELEN];
+       char scancmd[256];
+       char scanemail[256];
        int found_sub = 0;
 
        if (getroom(&qrbuf, room) != 0) {
@@ -229,8 +229,8 @@ void do_unsubscribe(char *room, char *email, char *webpage) {
        if (ncfp != NULL) {
                while (fgets(buf, sizeof buf, ncfp) != NULL) {
                        buf[strlen(buf)-1] = 0;
-                       extract(scancmd, buf, 0);
-                       extract(scanemail, buf, 1);
+                       extract_token(scancmd, buf, 0, '|', sizeof scancmd);
+                       extract_token(scanemail, buf, 1, '|', sizeof scanemail);
                        if ((!strcasecmp(scancmd, "listrecp"))
                           || (!strcasecmp(scancmd, "digestrecp"))) {
                                if (!strcasecmp(scanemail, email)) {
@@ -309,18 +309,18 @@ void do_unsubscribe(char *room, char *email, char *webpage) {
 void do_confirm(char *room, char *token) {
        struct ctdlroom qrbuf;
        FILE *ncfp;
-       char filename[SIZ];
-       char line_token[SIZ];
+       char filename[256];
+       char line_token[256];
        long line_offset;
        int line_length;
-       char buf[SIZ];
-       char cmd[SIZ];
-       char email[SIZ];
-       char subtype[SIZ];
+       char buf[512];
+       char cmd[256];
+       char email[256];
+       char subtype[128];
        int success = 0;
-       char address_to_unsubscribe[SIZ];
-       char scancmd[SIZ];
-       char scanemail[SIZ];
+       char address_to_unsubscribe[256];
+       char scancmd[256];
+       char scanemail[256];
        char *holdbuf = NULL;
        int linelen = 0;
        int buflen = 0;
@@ -352,17 +352,17 @@ void do_confirm(char *room, char *token) {
                      (fgets(buf, sizeof buf, ncfp) != NULL) ) {
                        buf[strlen(buf)-1] = 0;
                        line_length = strlen(buf);
-                       extract(cmd, buf, 0);
+                       extract_token(cmd, buf, 0, '|', sizeof cmd);
                        if (!strcasecmp(cmd, "subpending")) {
-                               extract(email, buf, 1);
-                               extract(subtype, buf, 2);
-                               extract(line_token, buf, 3);
+                               extract_token(email, buf, 1, '|', sizeof email);
+                               extract_token(subtype, buf, 2, '|', sizeof subtype);
+                               extract_token(line_token, buf, 3, '|', sizeof line_token);
                                if (!strcasecmp(token, line_token)) {
                                        if (!strcasecmp(subtype, "digest")) {
-                                               strcpy(buf, "digestrecp|");
+                                               safestrncpy(buf, "digestrecp|", sizeof buf);
                                        }
                                        else {
-                                               strcpy(buf, "listrecp|");
+                                               safestrncpy(buf, "listrecp|", sizeof buf);
                                        }
                                        strcat(buf, email);
                                        strcat(buf, "|");
@@ -379,9 +379,10 @@ void do_confirm(char *room, char *token) {
                                }
                        }
                        if (!strcasecmp(cmd, "unsubpending")) {
-                               extract(line_token, buf, 2);
+                               extract_token(line_token, buf, 2, '|', sizeof line_token);
                                if (!strcasecmp(token, line_token)) {
-                                       extract(address_to_unsubscribe, buf, 1);
+                                       extract_token(address_to_unsubscribe, buf, 1, '|',
+                                               sizeof address_to_unsubscribe);
                                }
                        }
                }
@@ -402,8 +403,8 @@ void do_confirm(char *room, char *token) {
                        while (line_offset = ftell(ncfp),
                              (fgets(buf, sizeof buf, ncfp) != NULL) ) {
                                buf[strlen(buf)-1]=0;
-                               extract(scancmd, buf, 0);
-                               extract(scanemail, buf, 1);
+                               extract_token(scancmd, buf, 0, '|', sizeof scancmd);
+                               extract_token(scanemail, buf, 1, '|', sizeof scanemail);
                                if ( (!strcasecmp(scancmd, "listrecp"))
                                   && (!strcasecmp(scanemail,
                                                address_to_unsubscribe)) ) {
@@ -464,37 +465,37 @@ void do_confirm(char *room, char *token) {
  */
 void cmd_subs(char *cmdbuf) {
 
-       char opr[SIZ];
-       char room[SIZ];
-       char email[SIZ];
-       char subtype[SIZ];
-       char token[SIZ];
-       char webpage[SIZ];
+       char opr[256];
+       char room[ROOMNAMELEN];
+       char email[256];
+       char subtype[256];
+       char token[256];
+       char webpage[256];
 
-       extract(opr, cmdbuf, 0);
+       extract_token(opr, cmdbuf, 0, '|', sizeof opr);
        if (!strcasecmp(opr, "subscribe")) {
-               extract(subtype, cmdbuf, 3);
+               extract_token(subtype, cmdbuf, 3, '|', sizeof subtype);
                if ( (strcasecmp(subtype, "list"))
                   && (strcasecmp(subtype, "digest")) ) {
                        cprintf("%d Invalid subscription type '%s'\n",
                                ERROR + ILLEGAL_VALUE, subtype);
                }
                else {
-                       extract(room, cmdbuf, 1);
-                       extract(email, cmdbuf, 2);
-                       extract(webpage, cmdbuf, 4);
+                       extract_token(room, cmdbuf, 1, '|', sizeof room);
+                       extract_token(email, cmdbuf, 2, '|', sizeof email);
+                       extract_token(webpage, cmdbuf, 4, '|', sizeof webpage);
                        do_subscribe(room, email, subtype, webpage);
                }
        }
        else if (!strcasecmp(opr, "unsubscribe")) {
-               extract(room, cmdbuf, 1);
-               extract(email, cmdbuf, 2);
-               extract(webpage, cmdbuf, 3);
+               extract_token(room, cmdbuf, 1, '|', sizeof room);
+               extract_token(email, cmdbuf, 2, '|', sizeof email);
+               extract_token(webpage, cmdbuf, 3, '|', sizeof webpage);
                do_unsubscribe(room, email, webpage);
        }
        else if (!strcasecmp(opr, "confirm")) {
-               extract(room, cmdbuf, 1);
-               extract(token, cmdbuf, 2);
+               extract_token(room, cmdbuf, 1, '|', sizeof room);
+               extract_token(token, cmdbuf, 2, '|', sizeof token);
                do_confirm(room, token);
        }
        else {
index 1783e5865ca81941d6ba4536bff0922eab315dff..a28896cb1cc045c07f36751904624e3534616f1b 100644 (file)
@@ -110,9 +110,9 @@ void mrtg_messages(void) {
  * Fetch data for MRTG
  */
 void cmd_mrtg(char *argbuf) {
-       char which[SIZ];
+       char which[32];
 
-       extract(which, argbuf, 0);
+       extract_token(which, argbuf, 0, '|', sizeof which);
 
        if (!strcasecmp(which, "users")) {
                mrtg_users();
index 794c8449f9c06e4effeff5d5b35e5d03058a9951..8d90f311c19c4a0a944a15fac8d2b11cf6f9fc13 100644 (file)
@@ -124,13 +124,13 @@ struct FilterList *load_filter_list(void) {
 
        /* Use the string tokenizer to grab one line at a time */
        for (i=0; i<num_tokens(serialized_list, '\n'); ++i) {
-               extract_token(buf, serialized_list, i, '\n');
+               extract_token(buf, serialized_list, i, '\n', sizeof buf);
                nptr = (struct FilterList *) malloc(sizeof(struct FilterList));
-               extract(nptr->fl_user, buf, 0);
+               extract_token(nptr->fl_user, buf, 0, '|', sizeof nptr->fl_user);
                striplt(nptr->fl_user);
-               extract(nptr->fl_room, buf, 1);
+               extract_token(nptr->fl_room, buf, 1, '|', sizeof nptr->fl_room);
                striplt(nptr->fl_room);
-               extract(nptr->fl_node, buf, 2);
+               extract_token(nptr->fl_node, buf, 2, '|', sizeof nptr->fl_node);
                striplt(nptr->fl_node);
 
                /* Cowardly refuse to add an any/any/any entry that would
@@ -223,11 +223,11 @@ void read_network_map(void) {
 
        /* Use the string tokenizer to grab one line at a time */
        for (i=0; i<num_tokens(serialized_map, '\n'); ++i) {
-               extract_token(buf, serialized_map, i, '\n');
+               extract_token(buf, serialized_map, i, '\n', sizeof buf);
                nmptr = (struct NetMap *) malloc(sizeof(struct NetMap));
-               extract(nmptr->nodename, buf, 0);
+               extract_token(nmptr->nodename, buf, 0, '|', sizeof nmptr->nodename);
                nmptr->lastcontact = extract_long(buf, 1);
-               extract(nmptr->nexthop, buf, 2);
+               extract_token(nmptr->nexthop, buf, 2, '|', sizeof nmptr->nexthop);
                nmptr->next = the_netmap;
                the_netmap = nmptr;
        }
@@ -308,14 +308,14 @@ int is_valid_node(char *nexthop, char *secret, char *node) {
 
        /* Use the string tokenizer to grab one line at a time */
        for (i=0; i<num_tokens(working_ignetcfg, '\n'); ++i) {
-               extract_token(linebuf, working_ignetcfg, i, '\n');
-               extract(buf, linebuf, 0);
+               extract_token(linebuf, working_ignetcfg, i, '\n', sizeof linebuf);
+               extract_token(buf, linebuf, 0, '|', sizeof buf);
                if (!strcasecmp(buf, node)) {
                        if (nexthop != NULL) {
                                strcpy(nexthop, "");
                        }
                        if (secret != NULL) {
-                               extract(secret, linebuf, 1);
+                               extract_token(secret, linebuf, 1, '|', 256);
                        }
                        retval = 0;
                }
@@ -650,7 +650,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                                bang = num_tokens(msg->cm_fields['P'], '!');
                                if (bang > 1) for (i=0; i<(bang-1); ++i) {
                                        extract_token(buf, msg->cm_fields['P'],
-                                               i, '!');
+                                               i, '!', sizeof buf);
                                        if (!strcasecmp(buf, mptr->remote_nodename)) {
                                                send = 0;
                                        }
@@ -812,9 +812,9 @@ void network_spoolout_room(char *room_to_spool) {
        char filename[SIZ];
        char buf[SIZ];
        char instr[SIZ];
-       char nodename[SIZ];
-       char roomname[SIZ];
-       char nexthop[SIZ];
+       char nodename[256];
+       char roomname[ROOMNAMELEN];
+       char nexthop[256];
        FILE *fp;
        struct SpoolControl sc;
        struct namelist *nptr = NULL;
@@ -845,7 +845,7 @@ void network_spoolout_room(char *room_to_spool) {
        while (fgets(buf, sizeof buf, fp) != NULL) {
                buf[strlen(buf)-1] = 0;
 
-               extract(instr, buf, 0);
+               extract_token(instr, buf, 0, '|', sizeof instr);
                if (!strcasecmp(instr, "lastsent")) {
                        sc.lastsent = extract_long(buf, 1);
                }
@@ -853,21 +853,21 @@ void network_spoolout_room(char *room_to_spool) {
                        nptr = (struct namelist *)
                                malloc(sizeof(struct namelist));
                        nptr->next = sc.listrecps;
-                       extract(nptr->name, buf, 1);
+                       extract_token(nptr->name, buf, 1, '|', sizeof nptr->name);
                        sc.listrecps = nptr;
                }
                else if (!strcasecmp(instr, "participate")) {
                        nptr = (struct namelist *)
                                malloc(sizeof(struct namelist));
                        nptr->next = sc.participates;
-                       extract(nptr->name, buf, 1);
+                       extract_token(nptr->name, buf, 1, '|', sizeof nptr->name);
                        sc.participates = nptr;
                }
                else if (!strcasecmp(instr, "digestrecp")) {
                        nptr = (struct namelist *)
                                malloc(sizeof(struct namelist));
                        nptr->next = sc.digestrecps;
-                       extract(nptr->name, buf, 1);
+                       extract_token(nptr->name, buf, 1, '|', sizeof nptr->name);
                        sc.digestrecps = nptr;
                }
                else if (!strcasecmp(instr, "ignet_push_share")) {
@@ -875,8 +875,8 @@ void network_spoolout_room(char *room_to_spool) {
                         * purge nodes which do not exist from room network
                         * configurations at this time.
                         */
-                       extract(nodename, buf, 1);
-                       extract(roomname, buf, 2);
+                       extract_token(nodename, buf, 1, '|', sizeof nodename);
+                       extract_token(roomname, buf, 2, '|', sizeof roomname);
                        strcpy(nexthop, "xxx");
                        if (is_valid_node(nexthop, NULL, nodename) == 0) {
                                if (strlen(nexthop) == 0) {
@@ -1018,11 +1018,11 @@ int network_sync_to(char *target_node) {
        struct SpoolControl sc;
        int num_spooled = 0;
        int found_node = 0;
-       char buf[SIZ];
-       char sc_type[SIZ];
-       char sc_node[SIZ];
-       char sc_room[SIZ];
-       char filename[SIZ];
+       char buf[256];
+       char sc_type[256];
+       char sc_node[256];
+       char sc_room[256];
+       char filename[256];
        FILE *fp;
 
        /* Grab the configuration line we're looking for */
@@ -1035,9 +1035,9 @@ int network_sync_to(char *target_node) {
        }
        while (fgets(buf, sizeof buf, fp) != NULL) {
                buf[strlen(buf)-1] = 0;
-               extract(sc_type, buf, 0);
-               extract(sc_node, buf, 1);
-               extract(sc_room, buf, 2);
+               extract_token(sc_type, buf, 0, '|', sizeof sc_type);
+               extract_token(sc_node, buf, 1, '|', sizeof sc_node);
+               extract_token(sc_room, buf, 2, '|', sizeof sc_room);
                if ( (!strcasecmp(sc_type, "ignet_push_share"))
                   && (!strcasecmp(sc_node, target_node)) ) {
                        found_node = 1;
@@ -1078,11 +1078,11 @@ int network_sync_to(char *target_node) {
  */
 void cmd_nsyn(char *argbuf) {
        int num_spooled;
-       char target_node[SIZ];
+       char target_node[256];
 
        if (CtdlAccessCheck(ac_aide)) return;
 
-       extract(target_node, argbuf, 0);
+       extract_token(target_node, argbuf, 0, '|', sizeof target_node);
        num_spooled = network_sync_to(target_node);
        if (num_spooled >= 0) {
                cprintf("%d Spooled %d messages.\n", CIT_OK, num_spooled);
@@ -1114,7 +1114,7 @@ void network_queue_room(struct ctdlroom *qrbuf, void *data) {
  * Learn topology from path fields
  */
 void network_learn_topology(char *node, char *path) {
-       char nexthop[SIZ];
+       char nexthop[256];
        struct NetMap *nmptr;
 
        strcpy(nexthop, "");
@@ -1122,7 +1122,7 @@ void network_learn_topology(char *node, char *path) {
        if (num_tokens(path, '!') < 3) return;
        for (nmptr = the_netmap; nmptr != NULL; nmptr = nmptr->next) {
                if (!strcasecmp(nmptr->nodename, node)) {
-                       extract_token(nmptr->nexthop, path, 0, '!');
+                       extract_token(nmptr->nexthop, path, 0, '!', sizeof nmptr->nexthop);
                        nmptr->lastcontact = time(NULL);
                        return;
                }
@@ -1132,7 +1132,7 @@ void network_learn_topology(char *node, char *path) {
        nmptr = (struct NetMap *) malloc(sizeof (struct NetMap));
        strcpy(nmptr->nodename, node);
        nmptr->lastcontact = time(NULL);
-       extract_token(nmptr->nexthop, path, 0, '!');
+       extract_token(nmptr->nexthop, path, 0, '!', sizeof nmptr->nexthop);
        nmptr->next = the_netmap;
        the_netmap = nmptr;
 }
@@ -1729,13 +1729,13 @@ bail:   sock_close(sock);
  */
 void network_poll_other_citadel_nodes(int full_poll) {
        int i;
-       char linebuf[SIZ];
+       char linebuf[256];
        char node[SIZ];
-       char host[SIZ];
-       char port[SIZ];
-       char secret[SIZ];
+       char host[256];
+       char port[256];
+       char secret[256];
        int poll = 0;
-       char spoolfile[SIZ];
+       char spoolfile[256];
 
        if (working_ignetcfg == NULL) {
                lprintf(CTDL_DEBUG, "No nodes defined - not polling\n");
@@ -1744,17 +1744,17 @@ void network_poll_other_citadel_nodes(int full_poll) {
 
        /* Use the string tokenizer to grab one line at a time */
        for (i=0; i<num_tokens(working_ignetcfg, '\n'); ++i) {
-               extract_token(linebuf, working_ignetcfg, i, '\n');
-               extract(node, linebuf, 0);
-               extract(secret, linebuf, 1);
-               extract(host, linebuf, 2);
-               extract(port, linebuf, 3);
+               extract_token(linebuf, working_ignetcfg, i, '\n', sizeof linebuf);
+               extract_token(node, linebuf, 0, '|', sizeof node);
+               extract_token(secret, linebuf, 1, '|', sizeof secret);
+               extract_token(host, linebuf, 2, '|', sizeof host);
+               extract_token(port, linebuf, 3, '|', sizeof port);
                if ( (strlen(node) > 0) && (strlen(secret) > 0) 
                   && (strlen(host) > 0) && strlen(port) > 0) {
                        poll = full_poll;
                        if (poll == 0) {
-                               sprintf(spoolfile, "./network/spoolout/%s",
-                                       node);
+                               snprintf(spoolfile, sizeof spoolfile,
+                                       "./network/spoolout/%s", node);
                                if (access(spoolfile, R_OK) == 0) {
                                        poll = 1;
                                }
@@ -1860,16 +1860,16 @@ void network_do_queue(void) {
  */
 void cmd_netp(char *cmdbuf)
 {
-       char node[SIZ];
-       char pass[SIZ];
+       char node[256];
+       char pass[256];
        int v;
 
-       char secret[SIZ];
-       char nexthop[SIZ];
+       char secret[256];
+       char nexthop[256];
 
        /* Authenticate */
-       extract(node, cmdbuf, 0);
-       extract(pass, cmdbuf, 1);
+       extract_token(node, cmdbuf, 0, '|', sizeof node);
+       extract_token(pass, cmdbuf, 1, '|', sizeof pass);
 
        if (doing_queue) {
                lprintf(CTDL_WARNING, "Network node <%s> refused - spooling", node);
index c3f31cea3d9c66ab81acbb3eab1a2518c8e8f4cc..0de1a66ee24549f7c91883585186106b37aedc0c 100644 (file)
@@ -34,7 +34,7 @@
 
 void cmd_pas2(char *argbuf)
 {
-       char pw[SIZ];
+       char pw[256];
        char hexstring[MD5_HEXSTRING_SIZE];
        
 
@@ -50,7 +50,7 @@ void cmd_pas2(char *argbuf)
                return;
        }
        
-       extract(pw, argbuf, 0);
+       extract_token(pw, argbuf, 0, '|', sizeof pw);
        
        if (getuser(&CC->user, CC->curr_user))
        {
index 6b1d1abacc63d02fd34d24ddb4e53f71dfaecfc3..0123145f0bbff2b01ad2460f03497dc6a3ed6748 100644 (file)
@@ -162,17 +162,17 @@ void cmd_rwho(char *argbuf) {
  */
 void cmd_rchg(char *argbuf)
 {
-       char newroomname[SIZ];
+       char newroomname[ROOMNAMELEN];
 
-       extract(newroomname, argbuf, 0);
+       extract_token(newroomname, argbuf, 0, '|', sizeof newroomname);
        newroomname[ROOMNAMELEN-1] = 0;
        if (strlen(newroomname) > 0) {
                safestrncpy(CC->fake_roomname, newroomname,
                        sizeof(CC->fake_roomname) );
-               }
+       }
        else {
-               strcpy(CC->fake_roomname, "");
-               }
+               safestrncpy(CC->fake_roomname, "", sizeof CC->fake_roomname);
+       }
        cprintf("%d OK\n", CIT_OK);
 }
 
@@ -181,16 +181,16 @@ void cmd_rchg(char *argbuf)
  */
 void cmd_hchg(char *argbuf)
 {
-       char newhostname[SIZ];
+       char newhostname[64];
 
-       extract(newhostname, argbuf, 0);
+       extract_token(newhostname, argbuf, 0, '|', sizeof newhostname);
        if (strlen(newhostname) > 0) {
                safestrncpy(CC->fake_hostname, newhostname,
                        sizeof(CC->fake_hostname) );
-               }
+       }
        else {
-               strcpy(CC->fake_hostname, "");
-               }
+               safestrncpy(CC->fake_hostname, "", sizeof CC->fake_hostname);
+       }
        cprintf("%d OK\n", CIT_OK);
 }
 
@@ -201,9 +201,9 @@ void cmd_hchg(char *argbuf)
 void cmd_uchg(char *argbuf)
 {
 
-       char newusername[SIZ];
+       char newusername[USERNAME_SIZE];
 
-       extract(newusername, argbuf, 0);
+       extract_token(newusername, argbuf, 0, '|', sizeof newusername);
 
        if (CtdlAccessCheck(ac_aide)) return;
 
index a354110c8451ee8509bbbcb3b31fb628868a1c76..c628aa4d98f134a7df764b3f0f7accadfdf9e3a2 100644 (file)
@@ -311,41 +311,41 @@ void smtp_get_pass(char *argbuf) {
  *
  */
 void smtp_auth(char *argbuf) {
-       char buf[SIZ];
-       char method[SIZ];
-       char encoded_authstring[SIZ];
-       char decoded_authstring[SIZ];
-       char ident[SIZ];
-       char user[SIZ];
-       char pass[SIZ];
+       char username_prompt[64];
+       char method[64];
+       char encoded_authstring[1024];
+       char decoded_authstring[1024];
+       char ident[256];
+       char user[256];
+       char pass[256];
 
        if (CC->logged_in) {
                cprintf("504 5.7.4 Already logged in.\r\n");
                return;
        }
 
-       extract_token(method, argbuf, 0, ' ');
+       extract_token(method, argbuf, 0, ' ', sizeof method);
 
        if (!strncasecmp(method, "login", 5) ) {
                if (strlen(argbuf) >= 7) {
                        smtp_get_user(&argbuf[6]);
                }
                else {
-                       CtdlEncodeBase64(buf, "Username:", 9);
-                       cprintf("334 %s\r\n", buf);
+                       CtdlEncodeBase64(username_prompt, "Username:", 9);
+                       cprintf("334 %s\r\n", username_prompt);
                        SMTP->command_state = smtp_user;
                }
                return;
        }
 
        if (!strncasecmp(method, "plain", 5) ) {
-               extract_token(encoded_authstring, argbuf, 1, ' ');
+               extract_token(encoded_authstring, argbuf, 1, ' ', sizeof encoded_authstring);
                CtdlDecodeBase64(decoded_authstring,
                                encoded_authstring,
                                strlen(encoded_authstring) );
-               strcpy(ident, decoded_authstring);
-               strcpy(user, &decoded_authstring[strlen(ident) + 1] );
-               strcpy(pass, &decoded_authstring[strlen(ident) + strlen(user) + 2] );
+               safestrncpy(ident, decoded_authstring, sizeof ident);
+               safestrncpy(user, &decoded_authstring[strlen(ident) + 1], sizeof user);
+               safestrncpy(pass, &decoded_authstring[strlen(ident) + strlen(user) + 2], sizeof pass);
 
                if (CtdlLoginExistingUser(user) == login_ok) {
                        if (CtdlTryPassword(pass) == pass_ok) {
@@ -983,7 +983,7 @@ void smtp_try(const char *key, const char *addr, int *status,
 
        sock = (-1);
        for (mx=0; (mx<num_mxhosts && sock < 0); ++mx) {
-               extract(buf, mxhosts, mx);
+               extract_token(buf, mxhosts, mx, '|', sizeof buf);
                lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
                sock = sock_connect(buf, "25", "tcp");
                snprintf(dsn, SIZ, "Could not connect: %s", strerror(errno));
@@ -1186,9 +1186,9 @@ void smtp_do_bounce(char *instr) {
 
        /* See if it's time to give up on delivery of this message */
        for (i=0; i<lines; ++i) {
-               extract_token(buf, instr, i, '\n');
-               extract(key, buf, 0);
-               extract(addr, buf, 1);
+               extract_token(buf, instr, i, '\n', sizeof buf);
+               extract_token(key, buf, 0, '|', sizeof key);
+               extract_token(addr, buf, 1, '|', sizeof addr);
                if (!strcasecmp(key, "submitted")) {
                        submitted = atol(addr);
                }
@@ -1226,11 +1226,11 @@ void smtp_do_bounce(char *instr) {
         * Now go through the instructions checking for stuff.
         */
        for (i=0; i<lines; ++i) {
-               extract_token(buf, instr, i, '\n');
-               extract(key, buf, 0);
-               extract(addr, buf, 1);
+               extract_token(buf, instr, i, '\n', sizeof buf);
+               extract_token(key, buf, 0, '|', sizeof key);
+               extract_token(addr, buf, 1, '|', sizeof addr);
                status = extract_int(buf, 2);
-               extract(dsn, buf, 3);
+               extract_token(dsn, buf, 3, '|', sizeof dsn);
                bounce_this = 0;
 
                lprintf(CTDL_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
@@ -1326,11 +1326,11 @@ int smtp_purge_completed_deliveries(char *instr) {
 
        lines = num_tokens(instr, '\n');
        for (i=0; i<lines; ++i) {
-               extract_token(buf, instr, i, '\n');
-               extract(key, buf, 0);
-               extract(addr, buf, 1);
+               extract_token(buf, instr, i, '\n', sizeof buf);
+               extract_token(key, buf, 0, '|', sizeof key);
+               extract_token(addr, buf, 1, '|', sizeof addr);
                status = extract_int(buf, 2);
-               extract(dsn, buf, 3);
+               extract_token(dsn, buf, 3, '|', sizeof dsn);
 
                completed = 0;
 
@@ -1391,7 +1391,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
        /* Strip out the headers amd any other non-instruction line */
        lines = num_tokens(instr, '\n');
        for (i=0; i<lines; ++i) {
-               extract_token(buf, instr, i, '\n');
+               extract_token(buf, instr, i, '\n', sizeof buf);
                if (num_tokens(buf, '|') < 2) {
                        remove_token(instr, i, '\n');
                        --lines;
@@ -1402,8 +1402,8 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
        /* Learn the message ID and find out about recent delivery attempts */
        lines = num_tokens(instr, '\n');
        for (i=0; i<lines; ++i) {
-               extract_token(buf, instr, i, '\n');
-               extract(key, buf, 0);
+               extract_token(buf, instr, i, '\n', sizeof buf);
+               extract_token(key, buf, 0, '|', sizeof key);
                if (!strcasecmp(key, "msgid")) {
                        text_msgid = extract_long(buf, 1);
                }
@@ -1447,11 +1447,11 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
         */
        lines = num_tokens(instr, '\n');
        for (i=0; i<lines; ++i) {
-               extract_token(buf, instr, i, '\n');
-               extract(key, buf, 0);
-               extract(addr, buf, 1);
+               extract_token(buf, instr, i, '\n', sizeof buf);
+               extract_token(key, buf, 0, '|', sizeof key);
+               extract_token(addr, buf, 1, '|', sizeof addr);
                status = extract_int(buf, 2);
-               extract(dsn, buf, 3);
+               extract_token(dsn, buf, 3, '|', sizeof dsn);
                if ( (!strcasecmp(key, "remote"))
                   && ((status==0)||(status==3)||(status==4)) ) {
 
@@ -1577,23 +1577,23 @@ void smtp_do_queue(void) {
 /*****************************************************************************/
 
 void cmd_smtp(char *argbuf) {
-       char cmd[SIZ];
-       char node[SIZ];
-       char buf[SIZ];
+       char cmd[64];
+       char node[256];
+       char buf[1024];
        int i;
        int num_mxhosts;
 
        if (CtdlAccessCheck(ac_aide)) return;
 
-       extract(cmd, argbuf, 0);
+       extract_token(cmd, argbuf, 0, '|', sizeof cmd);
 
        if (!strcasecmp(cmd, "mx")) {
-               extract(node, argbuf, 1);
+               extract_token(node, argbuf, 1, '|', sizeof node);
                num_mxhosts = getmx(buf, node);
                cprintf("%d %d MX hosts listed for %s\n",
                        LISTING_FOLLOWS, num_mxhosts, node);
                for (i=0; i<num_mxhosts; ++i) {
-                       extract(node, buf, i);
+                       extract_token(node, buf, i, '|', sizeof node);
                        cprintf("%s\n", node);
                }
                cprintf("000\n");
index 317dd7da8642289bac7cfddb703b8b9772f8a3b6..8cdca5648ba1551767a6dfff89609a82eb246705 100644 (file)
@@ -119,7 +119,7 @@ int spam_assassin(struct CtdlMessage *msg) {
 
        /* Try them one by one until we get a working one */
         for (sa=0; sa<num_sahosts; ++sa) {
-                extract(buf, sahosts, sa);
+                extract_token(buf, sahosts, sa, '|', sizeof buf);
                 lprintf(CTDL_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
                 sock = sock_connect(buf, SPAMASSASSIN_PORT, "tcp");
                 if (sock >= 0) lprintf(CTDL_DEBUG, "Connected!\n");
index 922e1dc277cdf97ded7316d57c908775a7f1f015..46a2a56c0f5c5b41ddf4a59237e97fe33cda5c8a 100644 (file)
@@ -573,7 +573,7 @@ void artv_do_import(void) {
 
 
 void cmd_artv(char *cmdbuf) {
-       char cmd[SIZ];
+       char cmd[32];
        static int is_running = 0;
 
        if (CtdlAccessCheck(ac_internal)) return;
@@ -587,7 +587,7 @@ void cmd_artv(char *cmdbuf) {
        strcpy(artv_tempfilename1, tmpnam(NULL));
        strcpy(artv_tempfilename2, tmpnam(NULL));
 
-       extract(cmd, cmdbuf, 0);
+       extract_token(cmd, cmdbuf, 0, '|', sizeof cmd);
        if (!strcasecmp(cmd, "export")) artv_do_export();
        else if (!strcasecmp(cmd, "import")) artv_do_import();
        else cprintf("%d illegal command\n", ERROR + ILLEGAL_VALUE);
index 5dd95868fceee53ad929d75178303c55cea90062..d1f747e69cc97909eb046667dae76b4b99cf2fe8 100644 (file)
@@ -636,11 +636,11 @@ void cmd_greg(char *argbuf)
        struct ctdluser usbuf;
        struct vCard *v;
        char *s;
-       char who[SIZ];
-       char adr[SIZ];
-       char buf[SIZ];
+       char who[USERNAME_SIZE];
+       char adr[256];
+       char buf[256];
 
-       extract(who, argbuf, 0);
+       extract_token(who, argbuf, 0, '|', sizeof who);
 
        if (!(CC->logged_in)) {
                cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
@@ -671,13 +671,13 @@ void cmd_greg(char *argbuf)
        s = vcard_get_prop(v, "adr", 0, 0, 0);
        snprintf(adr, sizeof adr, "%s", s ? s : " ");/* address... */
 
-       extract_token(buf, adr, 2, ';');
+       extract_token(buf, adr, 2, ';', sizeof buf);
        cprintf("%s\n", buf);                           /* street */
-       extract_token(buf, adr, 3, ';');
+       extract_token(buf, adr, 3, ';', sizeof buf);
        cprintf("%s\n", buf);                           /* city */
-       extract_token(buf, adr, 4, ';');
+       extract_token(buf, adr, 4, ';', sizeof buf);
        cprintf("%s\n", buf);                           /* state */
-       extract_token(buf, adr, 5, ';');
+       extract_token(buf, adr, 5, ';', sizeof buf);
        cprintf("%s\n", buf);                           /* zip */
 
        s = vcard_get_prop(v, "tel;home", 0, 0, 0);
@@ -696,7 +696,7 @@ void cmd_greg(char *argbuf)
        s = vcard_get_prop(v, "adr", 0, 0, 0);
        snprintf(adr, sizeof adr, "%s", s ? s : " ");/* address... */
 
-       extract_token(buf, adr, 6, ';');
+       extract_token(buf, adr, 6, ';', sizeof buf);
        cprintf("%s\n", buf);                           /* country */
        cprintf("000\n");
 }
@@ -706,14 +706,14 @@ void cmd_greg(char *argbuf)
  * When a user is being created, create his/her vCard.
  */
 void vcard_newuser(struct ctdluser *usbuf) {
-       char buf[SIZ];
-       char vname[SIZ];
+       char buf[256];
+       char vname[256];
 
-       char lastname[SIZ];
-       char firstname[SIZ];
-       char middlename[SIZ];
-       char honorific_prefixes[SIZ];
-       char honorific_suffixes[SIZ];
+       char lastname[256];
+       char firstname[256];
+       char middlename[256];
+       char honorific_prefixes[256];
+       char honorific_suffixes[256];
 
        struct vCard *v;
        int i;
@@ -722,42 +722,43 @@ void vcard_newuser(struct ctdluser *usbuf) {
         * fully expanded vCard name based on the number of
         * words in the name
         */
-       strcpy(lastname, "");
-       strcpy(firstname, "");
-       strcpy(middlename, "");
-       strcpy(honorific_prefixes, "");
-       strcpy(honorific_suffixes, "");
+       safestrncpy(lastname, "", sizeof lastname);
+       safestrncpy(firstname, "", sizeof firstname);
+       safestrncpy(middlename, "", sizeof middlename);
+       safestrncpy(honorific_prefixes, "", sizeof honorific_prefixes);
+       safestrncpy(honorific_suffixes, "", sizeof honorific_suffixes);
 
-       strcpy(buf, usbuf->fullname);
+       safestrncpy(buf, usbuf->fullname, sizeof buf);
 
        /* Honorific suffixes */
        if (num_tokens(buf, ',') > 1) {
-               extract_token(honorific_suffixes, buf, (num_tokens(buf, ' ') - 1), ',');
+               extract_token(honorific_suffixes, buf, (num_tokens(buf, ' ') - 1), ',',
+                       sizeof honorific_suffixes);
                remove_token(buf, (num_tokens(buf, ',') - 1), ',');
        }
 
        /* Find a last name */
-       extract_token(lastname, buf, (num_tokens(buf, ' ') - 1), ' ');
+       extract_token(lastname, buf, (num_tokens(buf, ' ') - 1), ' ', sizeof lastname);
        remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');
 
        /* Find honorific prefixes */
        if (num_tokens(buf, ' ') > 2) {
-               extract_token(honorific_prefixes, buf, 0, ' ');
+               extract_token(honorific_prefixes, buf, 0, ' ', sizeof honorific_prefixes);
                remove_token(buf, 0, ' ');
        }
 
        /* Find a middle name */
        if (num_tokens(buf, ' ') > 1) {
-               extract_token(middlename, buf, (num_tokens(buf, ' ') - 1), ' ');
+               extract_token(middlename, buf, (num_tokens(buf, ' ') - 1), ' ', sizeof middlename);
                remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');
        }
 
        /* Anything left is probably the first name */
-       strcpy(firstname, buf);
+       safestrncpy(firstname, buf, sizeof firstname);
        striplt(firstname);
 
        /* Compose the structured name */
-       sprintf(vname, "%s;%s;%s;%s;%s", lastname, firstname, middlename,
+       snprintf(vname, sizeof vname, "%s;%s;%s;%s;%s", lastname, firstname, middlename,
                honorific_prefixes, honorific_suffixes);
 
        lprintf(CTDL_DEBUG, "Converted <%s> to <%s>\n", usbuf->fullname, vname);
@@ -894,12 +895,12 @@ EOH:      CtdlFreeMessage(msg);
  * Query Directory
  */
 void cmd_qdir(char *argbuf) {
-       char citadel_addr[SIZ];
-       char internet_addr[SIZ];
+       char citadel_addr[256];
+       char internet_addr[256];
 
        if (CtdlAccessCheck(ac_logged_in)) return;
 
-       extract(internet_addr, argbuf, 0);
+       extract_token(internet_addr, argbuf, 0, '|', sizeof internet_addr);
 
        if (CtdlDirectoryLookup(citadel_addr, internet_addr) != 0) {
                cprintf("%d %s was not found.\n",
index 776f30c20d3545572ee6c24cc293cb2c1393baf2..261662671b4ed651f0812940012f70856ab56f4c 100644 (file)
@@ -120,10 +120,10 @@ void set_init_entry(char *which_entry, char *new_state) {
        while(fgets(buf, sizeof buf, fp) != NULL) {
 
                if (num_tokens(buf, ':') == 4) {
-                       extract_token(entry, buf, 0, ':');
-                       extract_token(levels, buf, 1, ':');
-                       extract_token(state, buf, 2, ':');
-                       extract_token(prog, buf, 3, ':'); /* includes 0x0a LF */
+                       extract_token(entry, buf, 0, ':', sizeof entry);
+                       extract_token(levels, buf, 1, ':', sizeof levels);
+                       extract_token(state, buf, 2, ':', sizeof state);
+                       extract_token(prog, buf, 3, ':', sizeof prog); /* includes 0x0a LF */
 
                        if (!strcmp(entry, which_entry)) {
                                strcpy(state, new_state);
@@ -173,8 +173,8 @@ void locate_init_entry(char *init_entry, char *looking_for) {
        } else {
                while (fgets(buf, sizeof buf, infp) != NULL) {
                        buf[strlen(buf) - 1] = 0;
-                       extract_token(entry, buf, 0, ':');      
-                       extract_token(prog, buf, 3, ':');
+                       extract_token(entry, buf, 0, ':', sizeof entry);
+                       extract_token(prog, buf, 3, ':', sizeof prog);
                        if (!strncasecmp(prog, looking_for,
                           strlen(looking_for))) {
                                ++have_entry;
@@ -278,7 +278,7 @@ int yesno(char *question)
                newtCenteredWindow(76, prompt_window_height, "Question");
                form = newtForm(NULL, NULL, 0);
                for (i=0; i<num_tokens(question, '\n'); ++i) {
-                       extract_token(buf, question, i, '\n');
+                       extract_token(buf, question, i, '\n', sizeof buf);
                        newtFormAddComponent(form, newtLabel(1, 1+i, buf));
                }
                yesbutton = newtButton(10, (prompt_window_height - 4), "Yes");
@@ -332,7 +332,7 @@ void important_message(char *title, char *msgtext)
                newtCenteredWindow(76, 10, title);
                form = newtForm(NULL, NULL, 0);
                for (i=0; i<num_tokens(msgtext, '\n'); ++i) {
-                       extract_token(buf, msgtext, i, '\n');
+                       extract_token(buf, msgtext, i, '\n', sizeof buf);
                        newtFormAddComponent(form, newtLabel(1, 1+i, buf));
                }
                newtFormAddComponent(form, newtButton(35, 5, "OK"));
@@ -738,7 +738,7 @@ void strprompt(char *prompt_title, char *prompt_text, char *str)
                                prompt_title);
                form = newtForm(NULL, NULL, 0);
                for (i=0; i<num_tokens(prompt_text, '\n'); ++i) {
-                       extract_token(buf, prompt_text, i, '\n');
+                       extract_token(buf, prompt_text, i, '\n', sizeof buf);
                        newtFormAddComponent(form, newtLabel(1, 1+i, buf));
                }
                newtFormAddComponent(form,
index aa78e3544be39c931c30aaa02f83ad3ee4ffe99d..b1e95fcc46c8cb4899863852d3c54b245413bb16 100644 (file)
@@ -94,11 +94,12 @@ int num_tokens(const char *source, char tok) {
 /*
  * extract_token() - a string tokenizer
  */
-void extract_token(char *dest, const char *source, int parmnum, char separator)
+void extract_token(char *dest, const char *source, int parmnum, char separator, int maxlen)
 {
        char *d;                /* dest */
        const char *s;          /* source */
        int count = 0;
+       int len = 0;
 
        strcpy(dest, "");
 
@@ -117,7 +118,7 @@ void extract_token(char *dest, const char *source, int parmnum, char separator)
        }
        if (!s) return;         /* Parameter not found */
 
-       for (d = dest; *s && *s != separator; s++, d++) {
+       for (d = dest; *s && *s != separator && ++len<maxlen; s++, d++) {
                *d = *s;
        }
        *d = 0;
@@ -174,9 +175,9 @@ void remove_token(char *source, int parmnum, char separator)
  */
 int extract_int(const char *source, int parmnum)
 {
-       char buf[SIZ];
+       char buf[32];
        
-       extract_token(buf, source, parmnum, '|');
+       extract_token(buf, source, parmnum, '|', sizeof buf);
        return(atoi(buf));
 }
 
@@ -185,9 +186,9 @@ int extract_int(const char *source, int parmnum)
  */
 long extract_long(const char *source, int parmnum)
 {
-       char buf[SIZ];
+       char buf[32];
        
-       extract_token(buf, source, parmnum, '|');
+       extract_token(buf, source, parmnum, '|', sizeof buf);
        return(atol(buf));
 }
 
@@ -197,9 +198,9 @@ long extract_long(const char *source, int parmnum)
  */
 unsigned long extract_unsigned_long(const char *source, int parmnum)
 {
-       char buf[SIZ];
+       char buf[32];
 
-       extract_token(buf, source, parmnum, '|');
+       extract_token(buf, source, parmnum, '|', sizeof buf);
        return strtoul(buf, NULL, 10);
 }
 
@@ -421,11 +422,11 @@ int is_msg_in_mset(char *mset, long msgnum) {
         */
        num_sets = num_tokens(mset, ',');
        for (s=0; s<num_sets; ++s) {
-               extract_token(setstr, mset, s, ',');
+               extract_token(setstr, mset, s, ',', sizeof setstr);
 
-               extract_token(lostr, setstr, 0, ':');
+               extract_token(lostr, setstr, 0, ':', sizeof lostr);
                if (num_tokens(setstr, ':') >= 2) {
-                       extract_token(histr, setstr, 1, ':');
+                       extract_token(histr, setstr, 1, ':', sizeof histr);
                        if (!strcmp(histr, "*")) {
                                snprintf(histr, sizeof histr, "%ld", LONG_MAX);
                        }
index c29d4344129341f49ca9f11a16f8173acd101914..f34eef4be79f2c18dc88d6a50d444994c63830bb 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$ */
 char *safestrncpy(char *dest, const char *src, size_t n);
 int num_tokens (const char *source, char tok);
-void extract_token(char *dest, const char *source, int parmnum, char separator);
+void extract_token(char *dest, const char *source, int parmnum, char separator, int maxlen);
 int extract_int (const char *source, int parmnum);
 long extract_long (const char *source, int parmnum);
 unsigned long extract_unsigned_long(const char *source, int parmnum);
@@ -21,7 +21,6 @@ int strncasecmp(char *, char *, int);
 #define strcasecmp(x,y) strncasecmp(x,y,INT_MAX);
 #endif
 
-#define extract(dest,source,parmnum)   extract_token(dest,source,parmnum,(char)'|')
 #define num_parms(source)              num_tokens(source,(char)'|')
 void stripout(char *str, char leftboundary, char rightboundary);
 void stripallbut(char *str, char leftboundary, char rightboundary);
index 4c7ed660a519f251654848e64a04ca643cc2e1c5..a9757e2dbdc4cb586c22c1bce6f38d9d1141cbac 100644 (file)
@@ -417,10 +417,10 @@ int CtdlLoginExistingUser(char *trythisname)
  */
 void cmd_user(char *cmdbuf)
 {
-       char username[SIZ];
+       char username[256];
        int a;
 
-       extract(username, cmdbuf, 0);
+       extract_token(username, cmdbuf, 0, '|', sizeof username);
        striplt(username);
 
        a = CtdlLoginExistingUser(username);
@@ -684,10 +684,10 @@ int CtdlTryPassword(char *password)
 
 void cmd_pass(char *buf)
 {
-       char password[SIZ];
+       char password[256];
        int a;
 
-       extract(password, buf, 0);
+       extract_token(password, buf, 0, '|', sizeof password);
        a = CtdlTryPassword(password);
 
        switch (a) {
@@ -778,7 +778,7 @@ int create_user(char *newusername, int become_user)
 {
        struct ctdluser usbuf;
        struct ctdlroom qrbuf;
-       char username[SIZ];
+       char username[256];
        char mailboxname[ROOMNAMELEN];
        uid_t uid;
 
@@ -790,7 +790,7 @@ int create_user(char *newusername, int become_user)
                struct passwd *p = (struct passwd *) getpwnam(username);
 
                if (p != NULL) {
-                       extract_token(username, p->pw_gecos, 0, ',');
+                       extract_token(username, p->pw_gecos, 0, ',', sizeof username);
                        uid = p->pw_uid;
                } else {
                        uid = (-1);
@@ -877,7 +877,7 @@ int create_user(char *newusername, int become_user)
 void cmd_newu(char *cmdbuf)
 {
        int a;
-       char username[SIZ];
+       char username[26];
 
        if (config.c_disable_newu) {
                cprintf("%d Self-service user account creation "
@@ -894,7 +894,7 @@ void cmd_newu(char *cmdbuf)
                        ERROR + MAX_SESSIONS_EXCEEDED,
                        config.c_nodename, config.c_maxsessions);
        }
-       extract(username, cmdbuf, 0);
+       extract_token(username, cmdbuf, 0, '|', sizeof username);
        username[25] = 0;
        strproc(username);
 
@@ -962,16 +962,16 @@ void cmd_setp(char *new_pw)
 void cmd_creu(char *cmdbuf)
 {
        int a;
-       char username[SIZ];
-       char password[SIZ];
+       char username[26];
+       char password[32];
        struct ctdluser tmp;
 
        if (CtdlAccessCheck(ac_aide)) {
                return;
        }
 
-       extract(username, cmdbuf, 0);
-       extract(password, cmdbuf, 1);
+       extract_token(username, cmdbuf, 0, '|', sizeof username);
+       extract_token(password, cmdbuf, 1, '|', sizeof password);
        username[25] = 0;
        password[31] = 0;
        strproc(username);
@@ -1295,11 +1295,11 @@ void cmd_gnur(void)
  */
 void cmd_vali(char *v_args)
 {
-       char user[SIZ];
+       char user[128];
        int newax;
        struct ctdluser userbuf;
 
-       extract(user, v_args, 0);
+       extract_token(user, v_args, 0, '|', sizeof user);
        newax = extract_int(v_args, 1);
 
        if (CtdlAccessCheck(ac_aide)) {
@@ -1437,13 +1437,13 @@ void cmd_qusr(char *who)
 void cmd_agup(char *cmdbuf)
 {
        struct ctdluser usbuf;
-       char requested_user[SIZ];
+       char requested_user[128];
 
        if (CtdlAccessCheck(ac_aide)) {
                return;
        }
 
-       extract(requested_user, cmdbuf, 0);
+       extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
        if (getuser(&usbuf, requested_user) != 0) {
                cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
                return;
@@ -1469,7 +1469,7 @@ void cmd_agup(char *cmdbuf)
 void cmd_asup(char *cmdbuf)
 {
        struct ctdluser usbuf;
-       char requested_user[SIZ];
+       char requested_user[128];
        char notify[SIZ];
        int np;
        int newax;
@@ -1478,14 +1478,14 @@ void cmd_asup(char *cmdbuf)
        if (CtdlAccessCheck(ac_aide))
                return;
 
-       extract(requested_user, cmdbuf, 0);
+       extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
        if (lgetuser(&usbuf, requested_user) != 0) {
                cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
                return;
        }
        np = num_parms(cmdbuf);
        if (np > 1)
-               extract(usbuf.password, cmdbuf, 1);
+               extract_token(usbuf.password, cmdbuf, 1, '|', sizeof usbuf.password);
        if (np > 2)
                usbuf.flags = extract_int(cmdbuf, 2);
        if (np > 3)
index 00534037d1a976634ae2fbc7586c05a321149917..59a398d7999843eb238a50e94d514e9335c9e04e 100644 (file)
@@ -47,11 +47,11 @@ void userlist(CtdlIPC *ipc) {
        printf("       User Name           Num  L  LastCall  Calls Posts\n");
        printf("------------------------- ----- - ---------- ----- -----\n");
        while (strlen(listing) > 0) {
-               extract_token(buf, listing, 0, '\n');
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
-               extract(fl,buf,0);
+               extract_token(fl, buf, 0, '|', sizeof fl);
                printf("%-25s ",fl);
-               printf("%5ld %d ",extract_long(buf,2),
+               printf("%5ld %d ", extract_long(buf,2),
                        extract_int(buf,1));
                lc = extract_long(buf,3);
                localtime_r(&lc, &tmbuf);
index 42cba2227fb2b86d86d81e42fc882c635395bb04..80fb72f3e7bb0baa585c64d8d1ad6d7f1c5fc33a 100644 (file)
@@ -128,17 +128,17 @@ int main(int argc, char **argv)
 
 
        while (strlen(listing) > 0) {
-               extract_token(buf, listing, 0, '\n');
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
 
                /* Escape some stuff if we're using www mode */
                if (www) escapize(buf, sizeof buf);
 
                s_pid = extract_int(buf,0);
-               extract(s_user,buf,1);
-               extract(s_room,buf,2);
-               extract(s_host,buf,3);
-               extract(s_client,buf,4);
+               extract_token(s_user, buf, 1, '|', sizeof s_user);
+               extract_token(s_room, buf, 2, '|', sizeof s_room);
+               extract_token(s_host, buf, 3, '|', sizeof s_host);
+               extract_token(s_client, buf, 4, '|', sizeof s_client);
                if (s_pid != my_pid) {
 
                        if (www) printf("<TR><TD>");