removed all references to sprintf from several files (not all files yet)
authorNathan Bryant <loanshark@uncensored.citadel.org>
Mon, 11 Mar 2002 05:42:47 +0000 (05:42 +0000)
committerNathan Bryant <loanshark@uncensored.citadel.org>
Mon, 11 Mar 2002 05:42:47 +0000 (05:42 +0000)
and replace with snprintf

24 files changed:
citadel/ChangeLog
citadel/citadel.c
citadel/citmail.c
citadel/citserver.c
citadel/client_chat.c
citadel/client_passwords.c
citadel/database_sleepycat.c
citadel/dynloader.c
citadel/file_ops.c
citadel/genstamp.c
citadel/genstamp.h
citadel/imap_fetch.c
citadel/imap_misc.c
citadel/ipc_c_tcp.c
citadel/locate_host.c
citadel/locate_host.h
citadel/md5.c
citadel/md5.h
citadel/messages.c
citadel/migratenet.c
citadel/msgbase.c
citadel/serv_pas2.c
citadel/serv_pop3.c
citadel/serv_smtp.c

index 42fc5bae36082de32dedfbe8ca4883e19fd24e6b..0521c48407ba590c5607bc7343b947975899f894 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 590.137  2002/03/11 05:42:46  nbryant
+ removed all references to sprintf from several files (not all files yet)
+ and replace with snprintf
+
  Revision 590.136  2002/03/11 04:16:20  nbryant
  warning fixes on sparc-sun-solaris2.8 with gcc 3.0.4, mostly for *printf
  format strings
@@ -3424,4 +3428,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index fc93f3e0729ec7220713906479bd92fd754c76d8..7f5b7dd43ec84b4e3e34e760a99d7f4aa8c3fc53 100644 (file)
@@ -1091,7 +1091,7 @@ GSTA:     /* See if we have a username and password on disk */
                        serv_gets(aaa);
                        if (nonce[0])
                        {
-                               sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
+                               snprintf(aaa, sizeof aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring, sizeof hexstring));
                        }
                        else    /* Else no APOP */
                        {
@@ -1149,11 +1149,11 @@ GSTA:   /* See if we have a username and password on disk */
 
        if (nonce[0])
        {
-               sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
+               snprintf(aaa, sizeof aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring, sizeof hexstring));
        }
        else    /* Else no APOP */
        {
-                       snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
+               snprintf(aaa, sizeof aaa, "PASS %s", password);
        }
        
        serv_puts(aaa);
index 183d1544abd783e502e0ea9dbb071d327707e332..1c54a5d404092b68685fd7bb715a0a79c8392688 100644 (file)
@@ -177,7 +177,7 @@ int main(int argc, char **argv) {
 
        fp = tmpfile();
        if (fp == NULL) return(errno);
-       sprintf(fromline, "From: someone@somewhere.org");
+       snprintf(fromline, sizeof fromline, "From: someone@somewhere.org");
        while (fgets(buf, 1024, stdin) != NULL) {
                fprintf(fp, "%s", buf);
                if (!strncasecmp(buf, "From:", 5)) strcpy(fromline, buf);
@@ -192,12 +192,12 @@ int main(int argc, char **argv) {
        serv_gets(buf);
        if (buf[0]!='2') cleanup(1);
 
-       sprintf(buf, "MAIL %s", fromline);
+       snprintf(buf, sizeof buf, "MAIL %s", fromline);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0]!='2') cleanup(1);
 
-       sprintf(buf, "RCPT To: %s", argv[1]);
+       snprintf(buf, sizeof buf, "RCPT To: %s", argv[1]);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0]!='2') cleanup(1);
index 6244d1423487744e130d972438b011a7f23fa191..ddb966012b1d878c0f66f01cc384c09873305c8c 100644 (file)
@@ -460,7 +460,7 @@ void cmd_iden(char *argbuf)
        if (do_lookup) {
                lprintf(9, "Looking up hostname '%s'\n", from_host);
                if ((addr.s_addr = inet_addr(from_host)) != -1) {
-                       locate_host(CC->cs_host, &addr);
+                       locate_host(CC->cs_host, sizeof CC->cs_host, &addr);
                }
                else {
                        safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
@@ -829,7 +829,7 @@ void begin_session(struct CitContext *con)
        if (!CC->is_local_socket) {
                if (!getpeername(con->client_socket,
                   (struct sockaddr *) &sin, &len))
-                       locate_host(con->cs_host, &sin.sin_addr);
+                       locate_host(con->cs_host, sizeof con->cs_host, &sin.sin_addr);
        }
        else {
                strcpy(con->cs_host, "");
index 6d9261e3216094c7454252e305b2aef9251ca7b0..482bcdc265dd2ac0a0056df5e35c346389a1b6c2 100644 (file)
@@ -300,7 +300,7 @@ void quiet_mode(void)
                qstate = 1;
        else
                qstate = 0;
-       sprintf(buf, "DEXP %d", qstate);
+       snprintf(buf, sizeof buf, "DEXP %d", qstate);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0] != '2') {
index 75076af09c8db29d99472e2f51d3efaaf6b07604..3552c42ec897a4e0b68c48c00d1cd9e938398c1f 100644 (file)
 
 #define PWFILENAME "%s/.citadel.passwords"
 
-void determine_pwfilename(char *pwfile) {
+static void determine_pwfilename(char *pwfile, size_t n) {
        struct passwd *p;
 
        p = getpwuid(getuid());
        if (p == NULL) strcpy(pwfile, "");
-       sprintf(pwfile, PWFILENAME, p->pw_dir);
+       snprintf(pwfile, n, PWFILENAME, p->pw_dir);
 }
 
 
@@ -50,7 +50,7 @@ void get_stored_password(
        strcpy(username, "");
        strcpy(password, "");
 
-       determine_pwfilename(pwfile);
+       determine_pwfilename(pwfile, sizeof pwfile);
        if (strlen(pwfile)==0) return;
 
        fp = fopen(pwfile, "r");
@@ -88,7 +88,7 @@ void set_stored_password(
        char buf64[SIZ];
        char hostbuf[SIZ], portbuf[SIZ], ubuf[SIZ], pbuf[SIZ];
 
-       determine_pwfilename(pwfile);
+       determine_pwfilename(pwfile, sizeof pwfile);
        if (strlen(pwfile)==0) return;
 
        oldfp = fopen(pwfile, "r");
@@ -105,14 +105,14 @@ void set_stored_password(
 
                if ( (strcasecmp(hostbuf, host)) 
                   || (strcasecmp(portbuf, port)) ) {
-                       sprintf(buf, "%s|%s|%s|%s|",
+                       snprintf(buf, sizeof buf, "%s|%s|%s|%s|",
                                hostbuf, portbuf, ubuf, pbuf);
                        encode_base64(buf64, buf);
                        fprintf(fp, "%s\n", buf64);
                }
        }
        if (strlen(username) > 0) {
-               sprintf(buf, "%s|%s|%s|%s|",
+               snprintf(buf, sizeof buf, "%s|%s|%s|%s|",
                        host, port, username, password);
                encode_base64(buf64, buf);
                fprintf(fp, "%s\n", buf64);
index d98215036ac4c5710b9448a7819c14c2cf185ca0..07f16c4bb709c0445f2e59ce07091077adf2f000 100644 (file)
@@ -319,7 +319,7 @@ void open_databases(void)
                /* Arbitrary names for our tables -- we reference them by
                 * number, so we don't have string names for them.
                 */
-               sprintf(dbfilename, "cdb.%02x", i);
+               snprintf(dbfilename, sizeof dbfilename, "cdb.%02x", i);
 
                ret = dbp[i]->open(dbp[i],
                                dbfilename,
index 00bd8091aac80468df0332ba26a63f859cc6324d..c1e3c64b3d60e42395f9f11c3301eff2372a6756 100644 (file)
@@ -488,7 +488,7 @@ void CtdlRegisterServiceHook(int tcp_port,
 
        if (sockpath != NULL) {
                newfcn->msock = ig_uds_server(sockpath, config.c_maxsessions);
-               sprintf(message, "Unix domain socket '%s': ", sockpath);
+               snprintf(message, sizeof message, "Unix domain socket '%s': ", sockpath);
        }
        else if (tcp_port <= 0) {       /* port -1 to disable */
                lprintf(7, "Service has been manually disabled, skipping\n");
@@ -497,7 +497,7 @@ void CtdlRegisterServiceHook(int tcp_port,
        }
        else {
                newfcn->msock = ig_tcp_server(tcp_port, config.c_maxsessions);
-               sprintf(message, "TCP port %d: ", tcp_port);
+               snprintf(message, sizeof message, "TCP port %d: ", tcp_port);
        }
 
        if (newfcn->msock > 0) {
index 1d1e8705d87ff42274370e38bbed7eed37bb0fe7..f1536050725fde00f6fb0ed8e0f2e665554367be 100644 (file)
@@ -661,7 +661,7 @@ void cmd_ucls(char *cmd)
                }
 
                /* put together an upload notice */
-               sprintf(upload_notice,
+               snprintf(upload_notice, sizeof upload_notice,
                        "NEW UPLOAD: '%s'\n %s\n",
                        CC->upl_file, CC->upl_comment);
                quickie_message(CC->curr_user, NULL, CC->quickroom.QRname,
index cfbb8bbb6c7ef16a378ba042e9a1d0d37c097b7e..737b3fa54ebd8fdfaa8535329527776f2d0f617e 100644 (file)
@@ -44,7 +44,7 @@ static char *weekdays[] = {
  * Supplied with a unix timestamp, generate an RFC822-compliant textual
  * time and date stamp.
  */
-void datestring(char *buf, time_t xtime, int which_format) {
+void datestring(char *buf, size_t n, time_t xtime, int which_format) {
        struct tm *t;
 
        long offset;
@@ -70,7 +70,7 @@ void datestring(char *buf, time_t xtime, int which_format) {
        switch(which_format) {
 
                case DATESTRING_RFC822:
-                       sprintf(buf, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
+                       snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
                                weekdays[t->tm_wday],
                                t->tm_mday,
                                months[t->tm_mon],
@@ -83,7 +83,7 @@ void datestring(char *buf, time_t xtime, int which_format) {
                break;
 
                case DATESTRING_IMAP:
-                       sprintf(buf, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",
+                       snprintf(buf, n, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",
                                t->tm_mday,
                                months[t->tm_mon],
                                t->tm_year + 1900,
index ce8e0f9f6685b246e6482c9a9546127f3e83deeb..58e32c78d845d7815d4f3ef0f8b7a3657ecf52bf 100644 (file)
@@ -3,7 +3,7 @@
  *
  */
 
-void datestring(char *buf, time_t xtime, int which_format);
+void datestring(char *buf, size_t n, time_t xtime, int which_format);
 
 enum {
        DATESTRING_RFC822,
index f1c3dac417cdfa537945e9442174a026f07f7328..e4697c5838f921e03a78dedb28a21a12959e442b 100644 (file)
@@ -87,7 +87,7 @@ void imap_fetch_internaldate(struct CtdlMessage *msg) {
                msgdate = time(NULL);
        }
 
-       datestring(buf, msgdate, DATESTRING_IMAP);
+       datestring(buf, sizeof buf, msgdate, DATESTRING_IMAP);
        cprintf("INTERNALDATE \"%s\"", buf);
 }
 
@@ -199,7 +199,7 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp,
                fwrite(content, length, 1, imfp->output_fp);
        }
 
-       sprintf(mbuf2, "%s.MIME", partnum);
+       snprintf(mbuf2, sizeof mbuf2, "%s.MIME", partnum);
 
        if (!strcasecmp(imfp->desired_section, mbuf2)) {
                fprintf(imfp->output_fp, "Content-type: %s", cbtype);
@@ -280,7 +280,7 @@ void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
        else {
                msgdate = time(NULL);
        }
-       datestring(datestringbuf, msgdate, DATESTRING_IMAP);
+       datestring(datestringbuf, sizeof datestringbuf, msgdate, DATESTRING_IMAP);
 
        /* Now start spewing data fields.  The order is important, as it is
         * defined by the protocol specification.  Nonexistent fields must
@@ -933,7 +933,7 @@ void imap_pick_range(char *supplied_range, int is_uid) {
                extract_token(lostr, setstr, 0, ':');
                if (num_tokens(setstr, ':') >= 2) {
                        extract_token(histr, setstr, 1, ':');
-                       if (!strcmp(histr, "*")) sprintf(histr, "%d", INT_MAX);
+                       if (!strcmp(histr, "*")) snprintf(histr, sizeof histr, "%d", INT_MAX);
                } 
                else {
                        strcpy(histr, lostr);
index 75e4b0d33138c072c9e9d298e366716e10ef53ee..b5b42d60c6a9d0f624a8dd628dea3f3a463e7b58 100644 (file)
@@ -141,6 +141,7 @@ void imap_print_express_messages(void) {
        struct ExpressMessage *ptr, *holdptr;
        char *dumpomatic = NULL;
        int i;
+       size_t size, size2;
 
        if (CC->FirstExpressMessage == NULL) {
                return;
@@ -151,7 +152,8 @@ void imap_print_express_messages(void) {
        end_critical_section(S_SESSION_TABLE);
 
        while (ptr != NULL) {
-               dumpomatic = mallok(strlen(ptr->text) + SIZ);
+               size = strlen(ptr->text) + SIZ;
+               dumpomatic = mallok(size);
                strcpy(dumpomatic, "");
                if (ptr->flags && EM_BROADCAST)
                        strcat(dumpomatic, "Broadcast message ");
@@ -161,7 +163,9 @@ void imap_print_express_messages(void) {
                        strcat(dumpomatic, "Please logoff now, as requested ");
                else
                        strcat(dumpomatic, "Message ");
-               sprintf(&dumpomatic[strlen(dumpomatic)],
+
+               size2 = strlen(dumpomatic);
+               snprintf(&dumpomatic[size2], size - size2,
                        "from %s:\n", ptr->sender);
                if (ptr->text != NULL)
                        strcat(dumpomatic, ptr->text);
index f646a66f48b8dfaf6dc27c92ef5a19ed54c76996..45775a8cada7e3faa3f8638b845fe44d47d00560 100644 (file)
@@ -294,7 +294,7 @@ void attach_to_server(int argc, char **argv, char *hostbuf, char *portbuf)
 
        /* If we're using a unix domain socket we can do a bunch of stuff */
        if (!strcmp(cithost, UDS)) {
-               sprintf(sockpath, "citadel.socket");
+               snprintf(sockpath, sizeof sockpath, "citadel.socket");
                serv_sock = uds_connectsock(sockpath);
                if (hostbuf != NULL) strcpy(hostbuf, cithost);
                if (portbuf != NULL) strcpy(portbuf, sockpath);
index 1ca321e330e1d4516b1dbae0323ae4f84d9d50af..f7878684352db5ced117d24a5ce664de8d461e7d 100644 (file)
@@ -28,7 +28,7 @@
 #include "config.h"
 #include "tools.h"
 
-void locate_host(char *tbuf, const struct in_addr *addr)
+void locate_host(char *tbuf, size_t n, const struct in_addr *addr)
 {
        struct hostent *ch;
        char *i;
@@ -48,7 +48,7 @@ void locate_host(char *tbuf, const struct in_addr *addr)
                a2 = ((*i++) & 0xff);
                a3 = ((*i++) & 0xff);
                a4 = ((*i++) & 0xff);
-               sprintf(tbuf, "%d.%d.%d.%d", a1, a2, a3, a4);
+               snprintf(tbuf, n, "%d.%d.%d.%d", a1, a2, a3, a4);
                goto end;       /* because we might need to end the critical
                                   section */
        }
index 69e343574c09b81587b0334df10adfd26c9e2af3..229805363447c4c217af56329dacd1c0bd5623a2 100644 (file)
@@ -1,2 +1,2 @@
 /* $Id$ */
-void locate_host(char *tbuf, const struct in_addr *addr);
+void locate_host(char *tbuf, size_t n, const struct in_addr *addr);
index 218989038ab458aa0844b655fd3ba8b1c6293f3a..92196d377212af15765611b9f46e203acdc0e891 100644 (file)
@@ -336,7 +336,7 @@ void MD5Transform(cit_uint32_t buf[4], cit_uint32_t const in[16])
  * md5 string
  */
 
-char *make_apop_string(char *realpass, char *nonce, char *buffer)
+char *make_apop_string(char *realpass, char *nonce, char *buffer, size_t n)
 {
    struct MD5Context ctx;
    u_char rawdigest[MD5_DIGEST_LEN];
@@ -350,7 +350,7 @@ char *make_apop_string(char *realpass, char *nonce, char *buffer)
    MD5Final(rawdigest, &ctx);
    for (i=0; i<MD5_DIGEST_LEN; i++)
    {
-      sprintf(&buffer[i*2], "%02X", (unsigned char) (rawdigest[i] & 0xff));
+      snprintf(&buffer[i*2], n - i*2, "%02X", (unsigned char) (rawdigest[i] & 0xff));
       buffer[i*2] = tolower(buffer[i*2]);
       buffer[(i*2)+1] = tolower(buffer[(i*2)+1]);
    }
index ff8d0c835ed0c05cd2329288ac7aa202d06cb53b..553196c77c0583c7320cfd691cc5c94c9a38e30d 100644 (file)
@@ -14,7 +14,7 @@ void MD5Update(struct MD5Context *context, unsigned char const *buf,
               unsigned len);
 void MD5Final(unsigned char digest[16], struct MD5Context *context);
 void MD5Transform(cit_uint32_t buf[4], cit_uint32_t const in[16]);
-char *make_apop_string(char *realpass, char *nonce, char *buffer);
+char *make_apop_string(char *realpass, char *nonce, char *buffer, size_t n);
 
 /*
  * This is needed to make RSAREF happy on some MS-DOS compilers.
index 39c286d8661c3aee0bde5572c19ff226d4c686b4..8da83b3cc64f28003a4d3caab6cd7011b68059fe 100644 (file)
@@ -359,7 +359,7 @@ int read_message(
        sigcaught = 0;
        sttybbs(1);
 
-       sprintf(buf, "MSG0 %ld|%d", num, (pagin == READ_HEADER ? 1 : 0));
+       snprintf(buf, sizeof buf, "MSG0 %ld|%d", num, (pagin == READ_HEADER ? 1 : 0));
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0] != '1') {
@@ -693,13 +693,14 @@ int client_make_message(char *filename,   /* temporary file name */
        header[0] = 0;
 
        if (room_flags & QR_ANONONLY && !recipient) {
-               sprintf(&header[strlen(header)], " ****");
+               snprintf(header, sizeof header, " ****");
        }
        else {
-               sprintf(&header[strlen(header)],
+               snprintf(header, sizeof header,
                        " %s from %s", datestr, fullname);
                if (strlen(recipient) > 0) {
-                       sprintf(&header[strlen(header)],
+                       size_t tmp = strlen(header);
+                       snprintf(&header[tmp], sizeof header - tmp,
                                " to %s", recipient);
                }
        }
@@ -944,7 +945,7 @@ int entmsg(int is_reply,    /* nonzero if this was a <R>eply command */
         * First, check to see if we have permission to enter a message in
         * this room.  The server will return an error code if we can't.
         */
-       sprintf(cmd, "ENT0 0||0|%d", mode);
+       snprintf(cmd, sizeof cmd, "ENT0 0||0|%d", mode);
        serv_puts(cmd);
        serv_gets(cmd);
 
@@ -1005,7 +1006,7 @@ int entmsg(int is_reply,  /* nonzero if this was a <R>eply command */
 
        /* If it's mail, we've got to check the validity of the recipient... */
        if (strlen(buf) > 0) {
-               sprintf(cmd, "ENT0 0|%s|%d|%d|%s", buf, b, mode, subject);
+               snprintf(cmd, sizeof cmd, "ENT0 0|%s|%d|%d|%s", buf, b, mode, subject);
                serv_puts(cmd);
                serv_gets(cmd);
                if (cmd[0] != '2') {
@@ -1047,7 +1048,7 @@ int entmsg(int is_reply,  /* nonzero if this was a <R>eply command */
        }
 
        /* Transmit message to the server */
-       sprintf(cmd, "ENT0 1|%s|%d|%d|%s|", buf, b, mode, subject);
+       snprintf(cmd, sizeof cmd, "ENT0 1|%s|%d|%d|%s|", buf, b, mode, subject);
        serv_puts(cmd);
        serv_gets(cmd);
        if (cmd[0] != '4') {
@@ -1165,7 +1166,7 @@ void list_urls()
        if ((i = num_urls) != 1)
                i = intprompt("Display which one", 1, 1, num_urls);
 
-       sprintf(cmd, rc_url_cmd, urls[i - 1]);
+       snprintf(cmd, sizeof cmd, rc_url_cmd, urls[i - 1]);
        system(cmd);
        scr_printf("\n");
 }
@@ -1211,7 +1212,7 @@ void readmsgs(
                strcat(cmd, "OLD");
                break;
        case 3:
-               sprintf(&cmd[strlen(cmd)], "LAST|%d", q);
+               snprintf(&cmd[5], sizeof cmd - 5, "LAST|%d", q);
                break;
        }
        serv_puts(cmd);
@@ -1468,7 +1469,7 @@ RMSGREAD: scr_flush();
                        newprompt("Enter target room: ",
                                  targ, ROOMNAMELEN - 1);
                        if (strlen(targ) > 0) {
-                               sprintf(cmd, "MOVE %ld|%s|%d",
+                               snprintf(cmd, sizeof cmd, "MOVE %ld|%s|%d",
                                        msg_arr[a], targ,
                                        (e == 'c' ? 1 : 0));
                                serv_puts(cmd);
@@ -1501,7 +1502,7 @@ RMSGREAD: scr_flush();
                case 'd':
                        scr_printf("*** Delete this message? ");
                        if (yesno() == 1) {
-                               sprintf(cmd, "DELE %ld", msg_arr[a]);
+                               snprintf(cmd, sizeof cmd, "DELE %ld", msg_arr[a]);
                                serv_puts(cmd);
                                serv_gets(cmd);
                                scr_printf("%s\n", &cmd[4]);
@@ -1534,7 +1535,7 @@ RMSGREAD: scr_flush();
                 char buf[SIZ];
                 int founda = 0;
                 
-                       sprintf(buf, "MSG0 %ld|%d", msg_arr[finda], 1); /* read the header so we can get 'from=' */
+                       snprintf(buf, sizeof buf, "MSG0 %ld|%d", msg_arr[finda], 1); /* read the header so we can get 'from=' */
                serv_puts(buf);
                serv_gets(buf);
                while (serv_gets(buf), strcmp(buf, "000")) 
@@ -1570,9 +1571,9 @@ void edit_system_message(char *which_message)
        char read_cmd[64];
        char write_cmd[64];
 
-       sprintf(desc, "system message '%s'", which_message);
-       sprintf(read_cmd, "MESG %s", which_message);
-       sprintf(write_cmd, "EMSG %s", which_message);
+       snprintf(desc, sizeof desc, "system message '%s'", which_message);
+       snprintf(read_cmd, sizeof read_cmd, "MESG %s", which_message);
+       snprintf(write_cmd, sizeof write_cmd, "EMSG %s", which_message);
        do_edit(desc, read_cmd, "NOOP", write_cmd);
 }
 
index f940602e0f049f53d95b184296401b3366eb51b1..1ecf2c1e705f0d0b9ffa19b3aa16b823322e692e 100644 (file)
@@ -69,7 +69,7 @@ int main(int argc, char **argv)
                logoff(atoi(buf));
        }
 
-       sprintf(buf, "IPGM %d", config.c_ipgm_secret);
+       snprintf(buf, sizeof buf, "IPGM %d", config.c_ipgm_secret);
        serv_puts(buf);
        serv_gets(buf);
        fprintf(stderr, "%s\n", &buf[4]);
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
                        fprintf(nodefp, "%s|", buf);
                        printf("Enter host name/IP : ");
                        gets(buf);
-                       if (buf[0] == 0) sprintf(buf, "%s.citadel.org",
+                       if (buf[0] == 0) snprintf(buf, sizeof buf, "%s.citadel.org",
                                d->d_name);
                        fprintf(nodefp, "%s|", buf);
                        printf("Enter port number  : ");
@@ -149,7 +149,7 @@ int main(int argc, char **argv)
 
        /* Set up the node table */
        printf("Creating neighbor node table\n");
-       sprintf(buf, "CONF putsys|%s", IGNETCFG);
+       snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0] == '4') {
@@ -170,7 +170,7 @@ int main(int argc, char **argv)
 
        /* Now go through the table looking for node names to enter */
 
-       sprintf(buf, "cat %s |awk -F \"|\" '{ print $2 }' |sort -f |uniq -i",
+       snprintf(buf, sizeof buf, "cat %s |awk -F \"|\" '{ print $2 }' |sort -f |uniq -i",
                roomfilename);
        roomfp = popen(buf, "r");
        if (roomfp == NULL) {
@@ -195,7 +195,7 @@ int main(int argc, char **argv)
        while (mn != NULL) {
                printf("Room <%s>\n", mn->roomname);
 
-               sprintf(buf, "GOTO %s", mn->roomname);
+               snprintf(buf, sizeof buf, "GOTO %s", mn->roomname);
                serv_puts(buf);
                serv_gets(buf);
                printf("%s\n", &buf[4]);
@@ -205,7 +205,7 @@ int main(int argc, char **argv)
                serv_gets(buf);
                if (buf[0] != '4') goto roomerror;
 
-               sprintf(buf, "lastsent|%ld", highest);
+               snprintf(buf, sizeof buf, "lastsent|%ld", highest);
                serv_puts(buf);
 
                roomfp = fopen(roomfilename, "r");
@@ -215,7 +215,7 @@ int main(int argc, char **argv)
                                extract(node, buf, 0);
                                extract(room, buf, 1);
                                if (!strcasecmp(room, mn->roomname)) {
-                                       sprintf(buf, 
+                                       snprintf(buf, sizeof buf,
                                                "ignet_push_share|%s", node);
                                        serv_puts(buf);
                                }
index 6cbec8fc4dcf0e02f3191dd1575efbcba21b7c9f..0cd11884316994fa95a8731c3e023b80d8642d61 100644 (file)
@@ -1165,7 +1165,7 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
                                else if (i == 'R')
                                        cprintf("To: %s%s", mptr, nl);
                                else if (i == 'T') {
-                                       datestring(datestamp, atol(mptr),
+                                       datestring(datestamp, sizeof datestamp, atol(mptr),
                                                DATESTRING_RFC822 );
                                        cprintf("Date: %s%s", datestamp, nl);
                                }
index 592f661998dc44265acff1f3466b721980568cf4..f1b1dbf1e8e3b57535c2b61ec14aae7ec41d00b3 100644 (file)
@@ -67,7 +67,7 @@ void cmd_pas2(char *argbuf)
                return;
        }
        
-       make_apop_string(CC->usersupp.password, CC->cs_nonce, hexstring);
+       make_apop_string(CC->usersupp.password, CC->cs_nonce, hexstring, sizeof hexstring);
        
        if (!strcmp(hexstring, pw))
        {
index 8cd9d62a3a3a4483911ae38b809d9105928b4fbf..048459a27679b286d988a122b012b4f11e6af65d 100644 (file)
@@ -238,7 +238,7 @@ void pop3_apop(char *argbuf)
        return;
    }
    
-   make_apop_string(CC->usersupp.password, CC->cs_nonce, realdigest);
+   make_apop_string(CC->usersupp.password, CC->cs_nonce, realdigest, sizeof realdigest);
    if (!strncasecmp(realdigest, userdigest, MD5_HEXSTRING_SIZE-1))
    {
        do_login();
index ebbcd2b846df8c94d5e9ccae34208a884c6a9820..25082d77c12e04fca656e6bedf7f3a17de98c94c 100644 (file)
@@ -470,7 +470,7 @@ void smtp_data(void) {
 
        cprintf("354 Transmit message now; terminate with '.' by itself\r\n");
        
-       datestring(nowstamp, time(NULL), DATESTRING_RFC822);
+       datestring(nowstamp, sizeof nowstamp, time(NULL), DATESTRING_RFC822);
        body = mallok(4096);
 
        /* FIXME