$Log$
+ Revision 590.140 2002/03/12 01:33:42 nbryant
+ - pass -Wcast-qual to gcc
+ - more sprintf bashing
+
Revision 590.139 2002/03/12 00:03:43 nbryant
more sprintf removals
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
if test "$GCC" = yes; then
case "$host" in
*-*-solaris*|alpha*-dec-osf*)
- CFLAGS="$CFLAGS -Wall -Wcast-align -Wno-char-subscripts"
+ CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts"
;;
*)
- CFLAGS="$CFLAGS -Wall -Wcast-align -Wstrict-prototypes"
+ CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes"
;;
esac
fi
* Split an RFC822-style address into userid, host, and full name
*
*/
-void process_rfc822_addr(char *rfc822, char *user, char *node, char *name)
+void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
{
int a;
int fuzzy_match(struct usersupp *us, char *matchstring);
-void process_rfc822_addr(char *rfc822, char *user, char *node, char *name);
+void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name);
char *rfc822_fetch_field(char *rfc822, char *fieldname);
int IsDirectory(char *addr);
void locate_host(char *tbuf, size_t n, const struct in_addr *addr)
{
struct hostent *ch;
- char *i;
+ const char *i;
+ char *j;
int a1, a2, a3, a4;
lprintf(9, "locate_host() called\n");
begin_critical_section(S_NETDB);
#endif
- if ((ch = gethostbyaddr((char *) addr, sizeof(*addr), AF_INET)) ==
+ if ((ch = gethostbyaddr((const char *) addr, sizeof(*addr), AF_INET)) ==
NULL) {
bad_dns:
- i = (char *) addr;
+ i = (const char *) addr;
a1 = ((*i++) & 0xff);
a2 = ((*i++) & 0xff);
a3 = ((*i++) & 0xff);
section */
}
/* check if the forward DNS agrees; if not, they're spoofing */
- i = strdoop(ch->h_name);
- ch = gethostbyname(i);
- phree(i);
+ j = strdoop(ch->h_name);
+ ch = gethostbyname(j);
+ phree(j);
if (ch == NULL)
goto bad_dns;
};
void sttybbs(int cmd);
-int haschar(char *st, int ch);
+int haschar(const char *st, int ch);
int checkpagin(int lp, int pagin, int height);
void getline(char *string, int lim);
void formout(char *name);
int newnow = 0;
newprompt("User name: ",who,25);
-AGUP: sprintf(buf,"AGUP %s",who);
+AGUP: snprintf(buf, sizeof buf, "AGUP %s",who);
serv_puts(buf);
serv_gets(buf);
if (buf[0]!='2') {
scr_printf("%s\n",&buf[4]);
scr_printf("Do you want to create this user? ");
if (yesno()) {
- sprintf(buf, "CREU %s", who);
+ snprintf(buf, sizeof buf, "CREU %s", who);
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '2') {
userpurge = intprompt("Purge time (in days, 0 for system default",
userpurge, 0, INT_MAX);
- sprintf(buf, "ASUP %s|%s|%d|%d|%d|%d|%ld|%ld|%d",
+ snprintf(buf, sizeof buf, "ASUP %s|%s|%d|%d|%d|%d|%ld|%ld|%d",
who, pass, flags, timescalled, posted, axlevel, usernum,
(long)lastcall, userpurge);
serv_puts(buf);
int width, height, flags, filter;
char buf[128];
- sprintf(buf,"GETU");
+ snprintf(buf, sizeof buf, "GETU");
serv_puts(buf);
serv_gets(buf);
if (buf[0]!='2') {
}
}
- sprintf(buf,"SETU %d|%d|%d|%d",width,height,flags,filter);
+ snprintf(buf, sizeof buf, "SETU %d|%d|%d|%d",width,height,flags,filter);
serv_puts(buf);
serv_gets(buf);
if (buf[0]!='2') scr_printf("%s\n",&buf[4]);
{
static char buf[128];
- sprintf(buf,"errno = %d",e);
+ snprintf(buf, sizeof buf, "errno = %d",e);
return(buf);
}
#endif
}
while (d = readdir(dp), d != NULL) {
- sprintf(filename, "%s/%s", dirname, d->d_name);
+ snprintf(filename, sizeof filename, "%s/%s", dirname, d->d_name);
unlink(filename);
}
int num_parms(char *source);
void strproc(char *string);
void back(int spaces);
+void progress(long int curr, long int cmax);
#include "snprintf.h"
#endif
#include "screen.h"
-
-void interr(int errnum);
-void strprompt(char *prompt, char *str, int len);
-void newprompt(char *prompt, char *str, int len);
-void sttybbs(int cmd);
-int inkey(void);
-void serv_write(char *buf, int nbytes);
-int haschar(char *st, int ch);
-void progress(long int curr, long int cmax);
-int yesno(void);
+#include "client_crypto.h"
extern char temp[];
extern char tempdir[];
attach_to_server(1, args, hostbuf, portbuf);
serv_gets(buf);
fprintf(stderr, "%s\n", &buf[4]);
- 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]);
return;
}
- sprintf(buf,"./bio/%ld",CC->usersupp.usernum);
+ snprintf(buf, sizeof buf, "./bio/%ld",CC->usersupp.usernum);
fp = fopen(buf,"w");
if (fp == NULL) {
cprintf("%d Cannot create file\n",ERROR);
cprintf("%d No such user.\n",ERROR+NO_SUCH_USER);
return;
}
- sprintf(buf,"./bio/%ld",ruser.usernum);
+ snprintf(buf, sizeof buf, "./bio/%ld",ruser.usernum);
cprintf("%d OK|%s|%ld|%d|%ld|%ld|%ld\n", LISTING_FOLLOWS,
ruser.fullname, ruser.usernum, ruser.axlevel,
while (RoomPurgeList != NULL) {
if (getroom(&qrbuf, RoomPurgeList->name) == 0) {
transcript=reallok(transcript, strlen(transcript)+SIZ);
- sprintf(&transcript[strlen(transcript)], " %s\n",
+ snprintf(&transcript[strlen(transcript)], SIZ, " %s\n",
qrbuf.QRname);
delete_room(&qrbuf);
}
while (UserPurgeList != NULL) {
transcript=reallok(transcript, strlen(transcript)+SIZ);
- sprintf(&transcript[strlen(transcript)], " %s\n",
+ snprintf(&transcript[strlen(transcript)], SIZ, " %s\n",
UserPurgeList->name);
purge_user(UserPurgeList->name);
pptr = UserPurgeList->next;
cprintf("%s BAD arguments invalid\r\n", parms[0]);
return;
}
- sprintf(pattern, "%s%s", parms[2], parms[3]);
+ snprintf(pattern, sizeof pattern, "%s%s", parms[2], parms[3]);
if (strlen(parms[3])==0) {
cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
cprintf("%s BAD arguments invalid\r\n", parms[0]);
return;
}
- sprintf(pattern, "%s%s", parms[2], parms[3]);
+ snprintf(pattern, sizeof pattern, "%s%s", parms[2], parms[3]);
if (strlen(parms[3])==0) {
cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
serialized_map = reallok(serialized_map,
(strlen(serialized_map)+SIZ) );
if (strlen(nmptr->nodename) > 0) {
- sprintf(&serialized_map[strlen(serialized_map)],
+ snprintf(&serialized_map[strlen(serialized_map)],
+ SIZ,
"%s|%ld|%s\n",
nmptr->nodename,
(long)nmptr->lastcontact,
(long)instr_len);
abort();
}
- sprintf(instr,
+ snprintf(instr, instr_len,
"Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
"bounceto|postmaster@%s\n" ,
SPOOLMIME, msgnum, (long)time(NULL), config.c_fqdn );
/* Generate delivery instructions for each recipient */
for (nptr = sc->listrecps; nptr != NULL; nptr = nptr->next) {
- sprintf(&instr[strlen(instr)], "remote|%s|0||\n",
- nptr->name);
+ size_t tmp = strlen(instr);
+ snprintf(&instr[tmp], instr_len - tmp,
+ "remote|%s|0||\n", nptr->name);
}
/*
msg = CtdlFetchMessage(msgnum);
if (msg != NULL) {
+ size_t newpath_len;
/* Prepend our node name to the Path field whenever
* sending a message to another IGnet node
if (msg->cm_fields['P'] == NULL) {
msg->cm_fields['P'] = strdoop("username");
}
- newpath = mallok(strlen(msg->cm_fields['P']) +
- strlen(config.c_nodename) + 2);
- sprintf(newpath, "%s!%s", config.c_nodename,
- msg->cm_fields['P']);
+ newpath_len = strlen(msg->cm_fields['P']) +
+ strlen(config.c_nodename) + 2;
+ newpath = mallok(newpath_len);
+ snprintf(newpath, newpath_len, "%s!%s",
+ config.c_nodename, msg->cm_fields['P']);
phree(msg->cm_fields['P']);
msg->cm_fields['P'] = newpath;
/* Send the message */
if (send == 1) {
- sprintf(filename,
+ snprintf(filename, sizeof filename,
"./network/spoolout/%s",
nptr->name);
fp = fopen(filename, "ab");
struct recptypes *valid = NULL;
char force_room[ROOMNAMELEN];
static int serialnum = 0;
+ size_t size;
lprintf(9, "entering network_bounce()\n");
if (msg == NULL) return;
- sprintf(bouncesource, "%s@%s", BOUNCESOURCE, config.c_nodename);
+ snprintf(bouncesource, sizeof bouncesource, "%s@%s", BOUNCESOURCE, config.c_nodename);
/*
* Give it a fresh message ID
if (msg->cm_fields['I'] != NULL) {
phree(msg->cm_fields['I']);
}
- sprintf(buf, "%ld.%04lx.%04x@%s",
+ snprintf(buf, sizeof buf, "%ld.%04lx.%04x@%s",
(long)time(NULL), (long)getpid(), ++serialnum, config.c_fqdn);
msg->cm_fields['I'] = strdoop(buf);
else {
oldpath = strdoop("unknown_user");
}
- msg->cm_fields['P'] = mallok(strlen(oldpath) + SIZ);
- sprintf(msg->cm_fields['P'], "%s!%s", config.c_nodename, oldpath);
+ size = strlen(oldpath) + SIZ;
+ msg->cm_fields['P'] = mallok(size);
+ snprintf(msg->cm_fields['P'], size, "%s!%s", config.c_nodename, oldpath);
phree(oldpath);
/* Now submit the message */
else {
oldpath = strdoop("unknown_user");
}
- msg->cm_fields['P'] =
- mallok(strlen(oldpath) + SIZ);
- sprintf(msg->cm_fields['P'], "%s!%s",
+ size = strlen(oldpath) + SIZ;
+ msg->cm_fields['P'] = mallok(size);
+ snprintf(msg->cm_fields['P'], size, "%s!%s",
config.c_nodename, oldpath);
phree(oldpath);
serialize_message(&sermsg, msg);
/* now send it */
- sprintf(filename,
+ snprintf(filename, sizeof filename,
"./network/spoolout/%s",
msg->cm_fields['D']);
fp = fopen(filename, "ab");
* Check to see if we already have a copy of this message
*/
if (network_usetable(msg) != 0) {
- sprintf(buf,
+ snprintf(buf, sizeof buf,
"Loopzapper rejected message <%s> "
"from <%s> in <%s> @ <%s>\n",
((msg->cm_fields['I']!=NULL)?(msg->cm_fields['I']):""),
if (dp == NULL) return;
while (d = readdir(dp), d != NULL) {
- sprintf(filename, "./network/spoolin/%s", d->d_name);
+ snprintf(filename, sizeof filename, "./network/spoolin/%s", d->d_name);
network_process_file(filename);
}
}
while (bytes_received < download_len) {
- sprintf(buf, "READ %ld|%ld",
+ snprintf(buf, sizeof buf, "READ %ld|%ld",
bytes_received,
((download_len - bytes_received > IGNET_PACKET_SIZE)
? IGNET_PACKET_SIZE : (download_len - bytes_received)));
return;
}
lprintf(9, "%s\n", buf);
- sprintf(buf, "mv %s ./network/spoolin/%s.%ld",
+ snprintf(buf, sizeof buf, "mv %s ./network/spoolin/%s.%ld",
tempfilename, remote_nodename, (long) getpid());
system(buf);
}
return;
}
- sprintf(sfname, "./network/spoolout/%s", remote_nodename);
+ snprintf(sfname, sizeof sfname, "./network/spoolout/%s", remote_nodename);
fd = open(sfname, O_RDONLY);
if (fd < 0) {
if (errno == ENOENT) {
while (plen = (long) read(fd, pbuf, IGNET_PACKET_SIZE), plen > 0L) {
bytes_to_write = plen;
while (bytes_to_write > 0L) {
- sprintf(buf, "WRIT %ld", bytes_to_write);
+ snprintf(buf, sizeof buf, "WRIT %ld", bytes_to_write);
if (sock_puts(sock, buf) < 0) {
close(fd);
return;
lprintf(9, ">%s\n", buf);
/* Identify ourselves */
- sprintf(buf, "NETP %s|%s", config.c_nodename, secret);
+ snprintf(buf, sizeof buf, "NETP %s|%s", config.c_nodename, secret);
lprintf(9, "<%s\n", buf);
if (sock_puts(sock, buf) <0) goto bail;
if (sock_gets(sock, buf) < 0) goto bail;
lgetuser(&CC->usersupp, CC->curr_user);
CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
- sprintf(vbuf.v_seen, "*:%ld",
+ snprintf(vbuf.v_seen, sizeof vbuf.v_seen, "*:%ld",
POP3->msgs[POP3->num_msgs-1].msgnum);
CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
CtdlAllocUserData(SYM_SMTP, sizeof(struct citsmtp));
CtdlAllocUserData(SYM_SMTP_RECPS, SIZ);
CtdlAllocUserData(SYM_SMTP_ROOMS, SIZ);
- sprintf(SMTP_RECPS, "%s", "");
- sprintf(SMTP_ROOMS, "%s", "");
+ snprintf(SMTP_RECPS, SIZ, "%s", "");
+ snprintf(SMTP_ROOMS, SIZ, "%s", "");
cprintf("220 %s ESMTP Citadel/UX server ready.\r\n", config.c_fqdn);
}
* Called by smtp_do_procmsg() to attempt delivery to one SMTP host
*
*/
-void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
+void smtp_try(const char *key, const char *addr, int *status,
+ char *dsn, size_t n, long msgnum)
{
int sock = (-1);
char mxhosts[1024];
msg_fp = tmpfile();
if (msg_fp == NULL) {
*status = 4;
- sprintf(dsn, "Error creating temporary file");
+ snprintf(dsn, n, "Error creating temporary file");
return;
}
else {
--i;
--lines;
lprintf(9, "SMTP: Trying <%s>\n", addr);
- smtp_try(key, addr, &status, dsn, text_msgid);
+ smtp_try(key, addr, &status, dsn, sizeof dsn, text_msgid);
if (status != 2) {
if (results == NULL) {
results = mallok(1024);
results = reallok(results,
strlen(results) + 1024);
}
- sprintf(&results[strlen(results)],
+ snprintf(&results[strlen(results)], 1024,
"%s|%s|%d|%s\n",
key, addr, status, dsn);
}
int drop_root_perms = 1;
char *moddir;
struct worker_node *wnp;
+ size_t size;
/* specify default port name and trace file */
strcpy(tracefile, "");
* Load any server-side modules (plugins) available here.
*/
lprintf(7, "Initializing loadable modules\n");
- if ((moddir = malloc(strlen(bbs_home_directory) + 9)) != NULL) {
- sprintf(moddir, "%s/modules", bbs_home_directory);
+ size = strlen(bbs_home_directory) + 9;
+ if ((moddir = mallok(size)) != NULL) {
+ snprintf(moddir, size, "%s/modules", bbs_home_directory);
DLoader_Init(moddir);
free(moddir);
}
/*
* Return the number of occurances of character ch in string st
*/
-int haschar(char *st, int ch)
+int haschar(const char *st, int ch)
{
int a, b;
b = 0;
void encode_base64(char *dest, char *source);
int decode_base64(char *dest, char *source, size_t length);
void striplt(char *);
-int haschar(char *st, int ch);
+int haschar(const char *st, int ch);
int collapsed_strcmp(char *s1, char *s2);
void remove_token(char *source, int parmnum, char separator);
void fmt_date(char *buf, time_t thetime, int seconds);