From 20e75a10ace92a6710468eb307b0d3fa1f21c597 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 30 Dec 2000 04:55:06 +0000 Subject: [PATCH] * more buffer size stuff --- citadel/ChangeLog | 4 ++++ citadel/citmail.c | 4 ++-- citadel/citserver.c | 2 +- citadel/clientsocket.c | 4 ++-- citadel/commands.c | 2 +- citadel/ipc_c_tcp.c | 4 ++-- citadel/msgbase.c | 4 ++-- citadel/netsetup.c | 18 +++++++++--------- citadel/rooms.c | 2 +- citadel/sendcommand.c | 2 +- citadel/serv_bio.c | 2 +- citadel/support.c | 2 +- citadel/sysdep.c | 4 ++-- 13 files changed, 29 insertions(+), 25 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index bd410dd3f..d3b3d1f72 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 573.60 2000/12/30 04:55:05 ajc + * more buffer size stuff + Revision 573.59 2000/12/27 20:19:51 ajc * The size constant "256" which shows up everywhere as a buffer size has now been changed to SIZ. And, SIZ has been defined now as 1024, not 256, because @@ -2253,3 +2256,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citmail.c b/citadel/citmail.c index 4842532cf..183d1544a 100644 --- a/citadel/citmail.c +++ b/citadel/citmail.c @@ -122,13 +122,13 @@ void serv_gets(char *buf) */ for (i = 0;; i++) { serv_read(&buf[i], 1); - if (buf[i] == '\n' || i == 255) + if (buf[i] == '\n' || i == (SIZ-1)) break; } /* If we got a long line, discard characters until the newline. */ - if (i == 255) + if (i == (SIZ-1)) while (buf[i] != '\n') serv_read(&buf[i], 1); diff --git a/citadel/citserver.c b/citadel/citserver.c index e4d76c02b..f635a1998 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -506,7 +506,7 @@ void cmd_mesg(char *mname) } cprintf("%d %s\n",LISTING_FOLLOWS,buf); - while (fgets(buf,255,mfp)!=NULL) { + while (fgets(buf, (SIZ-1), mfp)!=NULL) { buf[strlen(buf)-1] = 0; do_help_subst(buf); cprintf("%s\n",buf); diff --git a/citadel/clientsocket.c b/citadel/clientsocket.c index a7a7e82c2..00039e5de 100644 --- a/citadel/clientsocket.c +++ b/citadel/clientsocket.c @@ -138,13 +138,13 @@ int sock_gets(int sock, char *buf) */ for (i = 0;; i++) { if (sock_read(sock, &buf[i], 1) < 0) return(-1); - if (buf[i] == '\n' || i == 255) + if (buf[i] == '\n' || i == (SIZ-1)) break; } /* If we got a long line, discard characters until the newline. */ - if (i == 255) + if (i == (SIZ-1)) while (buf[i] != '\n') if (sock_read(sock, &buf[i], 1) < 0) return(-1); diff --git a/citadel/commands.c b/citadel/commands.c index 3a67eb77e..50cc2fe0b 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -1195,7 +1195,7 @@ FMTA: while ((eof_flag == 0) && (strlen(buffer) < 126)) { if ( (!strncasecmp(buffer, "http://", 7)) || (!strncasecmp(buffer, "ftp://", 6)) ) { - safestrncpy(urls[num_urls], buffer, 255); + safestrncpy(urls[num_urls], buffer, (SIZ-1)); for (a=0; a') || (b==10) diff --git a/citadel/ipc_c_tcp.c b/citadel/ipc_c_tcp.c index b49c6f1f2..c8a3ab9d8 100644 --- a/citadel/ipc_c_tcp.c +++ b/citadel/ipc_c_tcp.c @@ -239,13 +239,13 @@ void serv_gets(char *buf) */ for (i = 0;; i++) { serv_read(&buf[i], 1); - if (buf[i] == '\n' || i == 255) + if (buf[i] == '\n' || i == (SIZ-1)) break; } /* If we got a long line, discard characters until the newline. */ - if (i == 255) + if (i == (SIZ-1)) while (buf[i] != '\n') serv_read(&buf[i], 1); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 4b50a464c..167e475da 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -708,7 +708,7 @@ void CtdlFreeMessage(struct CtdlMessage *msg) if (is_valid_message(msg) == 0) return; - for (i = 0; i < SIZ; ++i) + for (i = 0; i < 256; ++i) if (msg->cm_fields[i] != NULL) { phree(msg->cm_fields[i]); } @@ -969,7 +969,7 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage, strcpy(lnode, HUMANNODE); if (mode == MT_RFC822) { cprintf("X-UIDL: %ld%s", msg_num, nl); - for (i = 0; i < SIZ; ++i) { + for (i = 0; i < 256; ++i) { if (TheMessage->cm_fields[i]) { mptr = TheMessage->cm_fields[i]; diff --git a/citadel/netsetup.c b/citadel/netsetup.c index c11df8c4f..92710f021 100644 --- a/citadel/netsetup.c +++ b/citadel/netsetup.c @@ -48,17 +48,17 @@ struct netnode *load_node(char *nodename) strcpy(newnn->nn_nodename, nodename); newnn->nn_first = NULL; - fgets(buf, 255, fp); + fgets(buf, (SIZ-1), fp); buf[strlen(buf)-1] = 0; strcpy(newnn->nn_spoolcmd, buf); - while (fgets(buf, 255, fp) != NULL) { + while (fgets(buf, (SIZ-1), fp) != NULL) { newrs = (struct roomshare *) malloc(sizeof(struct roomshare)); newrs->next = newnn->nn_first; newnn->nn_first = newrs; buf[strlen(buf)-1] = 0; strcpy(newrs->rs_name, buf); - fgets(buf, 255, fp); + fgets(buf, (SIZ-1), fp); buf[strlen(buf)-1] = 0; newrs->rs_lastsent = atol(buf); } @@ -127,7 +127,7 @@ void display_nodelist(void) { exit(errno); } - while (fgets(buf, 255, ls) != NULL) { + while (fgets(buf, (SIZ-1), ls) != NULL) { printf("%s", buf); } @@ -209,10 +209,10 @@ void do_roomlist(char *NodeName) exit(3); } - fgets(buf, 255, fp); /* skip past spool cmd */ - while (fgets(buf, 255, fp) != NULL) { + fgets(buf, (SIZ-1), fp); /* skip past spool cmd */ + while (fgets(buf, (SIZ-1), fp) != NULL) { printf("%s", buf); - fgets(buf, 255, fp); /* skip past last-sent pointer */ + fgets(buf, (SIZ-1), fp); /* skip past last-sent pointer */ } fclose(fp); @@ -237,7 +237,7 @@ void show_spool_cmd(char *NodeName) exit(3); } - fgets(buf, 255, fp); + fgets(buf, (SIZ-1), fp); printf("%s", buf); fclose(fp); } @@ -255,7 +255,7 @@ void set_spool_cmd(char *nodename, char *spoolcmd) exit(4); } - strncpy(nnptr->nn_spoolcmd, spoolcmd, 255); + strncpy(nnptr->nn_spoolcmd, spoolcmd, (SIZ-1)); save_node(nnptr); } diff --git a/citadel/rooms.c b/citadel/rooms.c index 3e276edc2..e69a2a9eb 100644 --- a/citadel/rooms.c +++ b/citadel/rooms.c @@ -977,7 +977,7 @@ void do_edit(char *desc, char *read_cmd, char *check_cmd, char *write_cmd) } fp=fopen(temp,"r"); - while (fgets(cmd,255,fp)!=NULL) { + while (fgets(cmd,SIZ-1,fp)!=NULL) { cmd[strlen(cmd)-1] = 0; serv_puts(cmd); } diff --git a/citadel/sendcommand.c b/citadel/sendcommand.c index 061d0b44f..3a04baeaf 100644 --- a/citadel/sendcommand.c +++ b/citadel/sendcommand.c @@ -164,7 +164,7 @@ int main(int argc, char **argv) } } else if (buf[0] == '4') { do { - if (fgets(buf, 255, stdin) == NULL) + if (fgets(buf, sizeof buf, stdin) == NULL) strcpy(buf, "000"); if (strlen(buf) > 0) if (buf[strlen(buf) - 1] == '\n') diff --git a/citadel/serv_bio.c b/citadel/serv_bio.c index 37543c89c..f4599bec8 100644 --- a/citadel/serv_bio.c +++ b/citadel/serv_bio.c @@ -106,7 +106,7 @@ void cmd_lbio(char *cmdbuf) { } cprintf("%d\n",LISTING_FOLLOWS); - while (fgets(buf,255,ls)!=NULL) + while (fgets(buf,sizeof buf,ls)!=NULL) if (getuserbynumber(&usbuf,atol(buf))==0) cprintf("%s\n",usbuf.fullname); pclose(ls); diff --git a/citadel/support.c b/citadel/support.c index c876ca218..99284f6c7 100644 --- a/citadel/support.c +++ b/citadel/support.c @@ -109,7 +109,7 @@ void mesg_locate(char *targ, char *searchfor, int numdirs, char **dirs) sprintf(buf,"cd %s; exec ls",dirs[a]); ls = (FILE *) popen(buf,"r"); if (ls != NULL) { - while(fgets(buf,255,ls)!=NULL) { + while(fgets(buf,sizeof buf,ls)!=NULL) { while (isspace(buf[strlen(buf)-1])) buf[strlen(buf)-1] = 0; if (!strcasecmp(buf,searchfor)) { diff --git a/citadel/sysdep.c b/citadel/sysdep.c index a50bb0818..107d40df5 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -536,13 +536,13 @@ int client_gets(char *buf) */ for (i = 0;;i++) { retval = client_read(&buf[i], 1); - if (retval != 1 || buf[i] == '\n' || i == 255) + if (retval != 1 || buf[i] == '\n' || i == (SIZ-1)) break; } /* If we got a long line, discard characters until the newline. */ - if (i == 255) + if (i == (SIZ-1)) while (buf[i] != '\n' && retval == 1) retval = client_read(&buf[i], 1); -- 2.39.2