From e1494f6e6849389939a101fbf1e673a20c7dcca3 Mon Sep 17 00:00:00 2001 From: Nathan Bryant Date: Tue, 10 Nov 1998 04:52:56 +0000 Subject: [PATCH] *** empty log message *** --- citadel/ChangeLog | 5 +++++ citadel/citmail.c | 14 +++++++------- citadel/citserver.c | 4 ++-- citadel/client_chat.c | 14 ++++++++++---- citadel/commands.h | 1 + citadel/routines.c | 1 - citadel/routines2.c | 2 +- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index d04447df0..dfa688221 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,3 +1,7 @@ +1998-11-09 Nathan Bryant + * 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 * 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 * 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 * useradmin.c: removed diff --git a/citadel/citmail.c b/citadel/citmail.c index d3751c45b..60f7c3573 100644 --- a/citadel/citmail.c +++ b/citadel/citmail.c @@ -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; } diff --git a/citadel/citserver.c b/citadel/citserver.c index ca34147a7..7cf5518ce 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -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; diff --git a/citadel/client_chat.c b/citadel/client_chat.c index bfe288df8..f54b11f3c 100644 --- a/citadel/client_chat.c +++ b/citadel/client_chat.c @@ -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)) { diff --git a/citadel/commands.h b/citadel/commands.h index 8c23ccdcc..4518ba0d2 100644 --- a/citadel/commands.h +++ b/citadel/commands.h @@ -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); diff --git a/citadel/routines.c b/citadel/routines.c index 0feedb9d8..2cea59f5a 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -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); diff --git a/citadel/routines2.c b/citadel/routines2.c index d371cb022..4724ca79d 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -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; -- 2.39.2