*** empty log message ***
authorNathan Bryant <loanshark@uncensored.citadel.org>
Tue, 10 Nov 1998 04:52:56 +0000 (04:52 +0000)
committerNathan Bryant <loanshark@uncensored.citadel.org>
Tue, 10 Nov 1998 04:52:56 +0000 (04:52 +0000)
citadel/ChangeLog
citadel/citmail.c
citadel/citserver.c
citadel/client_chat.c
citadel/commands.h
citadel/routines.c
citadel/routines2.c

index d04447df0ad7ac176b3b16d6e7bdad5fa328872c..dfa6882219c24ffcdb72882eb8b231e20b14f5c9 100644 (file)
@@ -1,3 +1,7 @@
+1998-11-09 Nathan Bryant <bryant@cs.usm.maine.edu>
+       * client_chat.c: eliminate calls to sprintf()
+       * commands.h, routines.c, routines2.c: warning fix
+
 Mon Nov  9 19:15:31 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * serv_upgrade.c: added all missing fields to export/import
        * serv_expire.c: support per-user purge time when purging users
@@ -16,6 +20,7 @@ Sun Nov  8 22:56:53 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * useradmin.c: really removed (cvs remove)
        * aidepost.c, citadel.c: convert all sprintf() calls to snprintf()
        * sysdep.c: fix overrun in lprintf() described by dme/Dead Monkey
+       * citmail.c, citserver.c: convert all sprintf() call to snprintf()
 
 Sun Nov  8 13:19:36 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * useradmin.c: removed
index d3751c45bbdb70effba7614c75818d9f9d9d0218..60f7c35733990abc855c3a75ba3230c8e0bb33f9 100644 (file)
@@ -132,7 +132,7 @@ char *strerror(int e)
 {
        static char buf[32];
 
-       sprintf(buf,"errno = %d",e);
+       snprintf(buf,sizeof buf,"errno = %d",e);
        return(buf);
        }
 #endif
@@ -376,9 +376,9 @@ void do_citmail(char recp[], int dtype) {
                }
 
        time(&now);
-       sprintf(from, "postmaster@%s", config.c_nodename);
+       snprintf(from, sizeof from, "postmaster@%s", config.c_nodename);
 
-       sprintf(buf, "./network/spoolin/citmail.%d", getpid());
+       snprintf(buf, sizeof buf, "./network/spoolin/citmail.%d", getpid());
        temp = fopen(buf,"w");
 
        putc(255,temp); putc(MES_NORMAL,temp); putc(1,temp);
@@ -432,7 +432,7 @@ void do_uudecode(char *target)
        static char buf[1024];
        FILE *fp;
        
-       sprintf(buf,"cd %s; uudecode",target);
+       snprintf(buf,sizeof buf,"cd %s; uudecode",target);
 
        fp=popen(buf,"w");
        if (fp==NULL) return;
@@ -609,7 +609,7 @@ int main(int argc, char **argv)
                
                                                        /* Otherwise, we're dealing with Citadel mail. */
                                                        else {
-                                                               sprintf(recp, "%s!%s", node, user);
+                                                               snprintf(recp, sizeof recp, "%s!%s", node, user);
                                                                deliver_to_ignet = 1;
                                                                printf("250 IGnet recipient.\n");
                                                                }
@@ -665,14 +665,14 @@ int main(int argc, char **argv)
                        * back to an external mail transport agent such as sendmail.
                        */
                        if (haschar(node, '.')) {
-                               sprintf(buf, SENDMAIL, recp);
+                               snprintf(buf, sizeof buf, SENDMAIL, recp);
                                system(buf);
                                exit(0);
                                }
        
                        /* Otherwise, we're dealing with Citadel mail. */
                        else {
-                               sprintf(recp, "%s!%s", node, user);
+                               snprintf(recp, sizeof recp, "%s!%s", node, user);
                                deliver_to_ignet = 1;
                                }
        
index ca34147a783011f0667dd4c200f311716041d418..7cf5518ced4308ab4c0652626f87b5aadfc2f58b 100644 (file)
@@ -422,7 +422,7 @@ void cmd_emsg(char *mname)
        free(dirs[1]);
 
        if (strlen(targ)==0) {
-               sprintf(targ, "./help/%s", buf);
+               snprintf(targ, sizeof targ, "./help/%s", buf);
                }
 
        mfp = fopen(targ,"w");
@@ -668,7 +668,7 @@ void *context_loop(struct CitContext *con)
        strcpy(CC->cs_clientname, "(unknown)");
        strcpy(CC->curr_user,"");
        strcpy(CC->net_node,"");
-       sprintf(CC->temp,"/tmp/CitServer.%d.%d", getpid(), CC->cs_pid);
+       snprintf(CC->temp, sizeof CC->temp, "/tmp/CitServer.%d.%d", getpid(), CC->cs_pid);
        strcpy(CC->cs_room, "");
        strncpy(CC->cs_host, config.c_fqdn, sizeof CC->cs_host);
        CC->cs_host[sizeof CC->cs_host - 1] = 0;
index bfe288df83544beb8afe7807851d663159f34484..f54b11f3cedb162a890b30b31f03a8cd8a8f4dcb 100644 (file)
@@ -28,6 +28,9 @@
 #include "routines.h"
 #include "ipc.h"
 #include "citadel_decls.h"
+#include "tools.h"
+
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
 
 void chatmode(void) {
        char wbuf[256];
@@ -158,12 +161,15 @@ RCL:          if (send_complete_line) {
                                        color(2);
                                        }
                                if (strcmp(c_user,last_user)) {
-                                       sprintf(buf,"%s: %s",c_user,c_text);
+                                       snprintf(buf,sizeof buf,"%s: %s",c_user,c_text);
                                        }
                                else {
-                                       sprintf(buf,"%40s","");
-                                       sprintf(&buf[strlen(c_user)+2],
-                                               "%s",c_text);
+                                       size_t i = MIN(sizeof buf - 1,
+                                                      strlen(c_user) + 2);
+
+                                       memset(buf, ' ', i);
+                                       safestrncpy(&buf[i], c_text,
+                                                   sizeof buf - i);
                                        }
                                while (strlen(buf)<79) strcat(buf," ");
                                if (strcmp(c_user,last_user)) {
index 8c23ccdcc0bb5b496289cfe75483336fad0b2752..4518ba0d267dee2fb292d421e5ddc6df6cb4812b 100644 (file)
@@ -4,6 +4,7 @@ void sttybbs(int cmd);
 void newprompt(char *prompt, char *str, int len);
 void strprompt(char *prompt, char *str, int len);
 int boolprompt(char *prompt, int prev_val);
+int intprompt(char *prompt, int ival, int imin, int imax);
 int fmout(int width, FILE *fp, char pagin, int height, int starting_lp,
          char subst);
 int getcmd(char *argbuf);
index 0feedb9d8b9907dd32fee5089296cb581e8f7440..2cea59f5ae56f42dc9508a8a6fc2c298e7f7dffd 100644 (file)
@@ -26,7 +26,6 @@
 void sttybbs(int cmd);
 void newprompt(char *prompt, char *str, int len);
 void val_user(char *user);
-int intprompt(char *prompt, int ival, int imin, int imax);
 void formout(char *name);
 void logoff(int code);
 void set_keepalives(int s);
index d371cb02204905b6520b158a4e6ae75dbea5e6d7..4724ca79d4bf172de25c0a9d389fc23ee0ac1cda 100644 (file)
@@ -395,7 +395,7 @@ void upload(int c)  /* c = upload mode */
  */
 void val_user(char *user)
 {
-       int a,b;
+       int a;
        char cmd[256];
        char buf[256];
        int ax = 0;