projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c134c04
)
more sprintf removals
author
Nathan Bryant
<loanshark@uncensored.citadel.org>
Tue, 12 Mar 2002 00:03:43 +0000
(
00:03
+0000)
committer
Nathan Bryant
<loanshark@uncensored.citadel.org>
Tue, 12 Mar 2002 00:03:43 +0000
(
00:03
+0000)
citadel/ChangeLog
patch
|
blob
|
history
citadel/file_ops.c
patch
|
blob
|
history
citadel/imap_misc.c
patch
|
blob
|
history
citadel/msgbase.c
patch
|
blob
|
history
citadel/msgbase.h
patch
|
blob
|
history
citadel/msgform.c
patch
|
blob
|
history
citadel/netsetup.c
patch
|
blob
|
history
citadel/room_ops.c
patch
|
blob
|
history
citadel/room_ops.h
patch
|
blob
|
history
citadel/serv_network.c
patch
|
blob
|
history
diff --git
a/citadel/ChangeLog
b/citadel/ChangeLog
index 410c75f04f42b84074424084b20c1b80efc40546..5b1627b96e305582233cb39ba645831218ee8830 100644
(file)
--- a/
citadel/ChangeLog
+++ b/
citadel/ChangeLog
@@
-1,4
+1,7
@@
$Log$
$Log$
+ Revision 590.139 2002/03/12 00:03:43 nbryant
+ more sprintf removals
+
Revision 590.138 2002/03/11 06:00:21 nbryant
use <db.h> before <db3/db.h> or <db4/db.h>
this is the only way i can think of to make it work everywhere; people on
Revision 590.138 2002/03/11 06:00:21 nbryant
use <db.h> before <db3/db.h> or <db4/db.h>
this is the only way i can think of to make it work everywhere; people on
@@
-3434,4
+3437,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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
diff --git
a/citadel/file_ops.c
b/citadel/file_ops.c
index f1536050725fde00f6fb0ed8e0f2e665554367be..f6b3c90fcb3a83629e92492299eb9121f523d03a 100644
(file)
--- a/
citadel/file_ops.c
+++ b/
citadel/file_ops.c
@@
-425,7
+425,7
@@
void cmd_oimg(char *cmdbuf)
snprintf(pathname, sizeof pathname,
"./images/floor.%d.gif", which_floor);
} else if (!strcasecmp(filename, "_roompic_")) {
snprintf(pathname, sizeof pathname,
"./images/floor.%d.gif", which_floor);
} else if (!strcasecmp(filename, "_roompic_")) {
- assoc_file_name(pathname, &CC->quickroom, "images");
+ assoc_file_name(pathname,
sizeof pathname,
&CC->quickroom, "images");
} else {
for (a = 0; a < strlen(filename); ++a) {
filename[a] = tolower(filename[a]);
} else {
for (a = 0; a < strlen(filename); ++a) {
filename[a] = tolower(filename[a]);
@@
-557,7
+557,7
@@
void cmd_uimg(char *cmdbuf)
}
if ((!strcasecmp(basenm, "_roompic_")) && (is_room_aide())) {
}
if ((!strcasecmp(basenm, "_roompic_")) && (is_room_aide())) {
- assoc_file_name(CC->upl_path, &CC->quickroom, "images");
+ assoc_file_name(CC->upl_path,
sizeof CC->upl_path,
&CC->quickroom, "images");
}
if (strlen(CC->upl_path) == 0) {
}
if (strlen(CC->upl_path) == 0) {
diff --git
a/citadel/imap_misc.c
b/citadel/imap_misc.c
index b5b42d60c6a9d0f624a8dd628dea3f3a463e7b58..6468e3f9c89e24aaabf4f7700d51e8f6f261b040 100644
(file)
--- a/
citadel/imap_misc.c
+++ b/
citadel/imap_misc.c
@@
-273,7
+273,7
@@
void imap_append(int num_parms, char *parms[]) {
/*
* Can we post here?
*/
/*
* Can we post here?
*/
- ret = CtdlDoIHavePermissionToPostInThisRoom(buf);
+ ret = CtdlDoIHavePermissionToPostInThisRoom(buf
, sizeof buf
);
if (ret) {
/* Nope ... print an error message */
if (ret) {
/* Nope ... print an error message */
diff --git
a/citadel/msgbase.c
b/citadel/msgbase.c
index 0cd11884316994fa95a8731c3e023b80d8642d61..edafb1a6df69b3d5194920d2a5df711bb1132122 100644
(file)
--- a/
citadel/msgbase.c
+++ b/
citadel/msgbase.c
@@
-336,17
+336,24
@@
void CtdlSetSeen(long target_msgnum, int target_setting) {
}
if ( ((is_seen == 0) && (was_seen == 1))
|| ((is_seen == 1) && (i == num_msgs-1)) ) {
}
if ( ((is_seen == 0) && (was_seen == 1))
|| ((is_seen == 1) && (i == num_msgs-1)) ) {
+ size_t tmp;
+
if ( (strlen(newseen) + 20) > SIZ) {
strcpy(newseen, &newseen[20]);
newseen[0] = '*';
}
if ( (strlen(newseen) + 20) > SIZ) {
strcpy(newseen, &newseen[20]);
newseen[0] = '*';
}
- if (strlen(newseen) > 0) strcat(newseen, ",");
+ tmp = strlen(newseen);
+ if (tmp > 0) {
+ strcat(newseen, ",");
+ tmp++;
+ }
if (lo == hi) {
if (lo == hi) {
- sprintf(&newseen[strlen(newseen)], "%ld", lo);
+ snprintf(&newseen[tmp], sizeof newseen - tmp,
+ "%ld", lo);
}
else {
}
else {
- s
printf(&newseen[strlen(newseen)], "%ld:%ld"
,
- lo, hi);
+ s
nprintf(&newseen[tmp], sizeof newseen - tmp
,
+
"%ld:%ld",
lo, hi);
}
lo = (-1L);
hi = (-1L);
}
lo = (-1L);
hi = (-1L);
@@
-576,11
+583,11
@@
void do_help_subst(char *buffer)
help_subst(buffer, "^humannode", config.c_humannode);
help_subst(buffer, "^fqdn", config.c_fqdn);
help_subst(buffer, "^username", CC->usersupp.fullname);
help_subst(buffer, "^humannode", config.c_humannode);
help_subst(buffer, "^fqdn", config.c_fqdn);
help_subst(buffer, "^username", CC->usersupp.fullname);
- s
printf(
buf2, "%ld", CC->usersupp.usernum);
+ s
nprintf(buf2, sizeof
buf2, "%ld", CC->usersupp.usernum);
help_subst(buffer, "^usernum", buf2);
help_subst(buffer, "^sysadm", config.c_sysadm);
help_subst(buffer, "^variantname", CITADEL);
help_subst(buffer, "^usernum", buf2);
help_subst(buffer, "^sysadm", config.c_sysadm);
help_subst(buffer, "^variantname", CITADEL);
- s
printf(
buf2, "%d", config.c_maxsessions);
+ s
nprintf(buf2, sizeof
buf2, "%d", config.c_maxsessions);
help_subst(buffer, "^maxsessions", buf2);
}
help_subst(buffer, "^maxsessions", buf2);
}
@@
-1002,7
+1009,7
@@
int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
char datestamp[SIZ];
/* */
char datestamp[SIZ];
/* */
- s
printf(
mid, "%ld", msg_num);
+ s
nprintf(mid, sizeof
mid, "%ld", msg_num);
nl = (crlf ? "\r\n" : "\n");
if (!is_valid_message(TheMessage)) {
nl = (crlf ? "\r\n" : "\n");
if (!is_valid_message(TheMessage)) {
@@
-1080,8
+1087,10
@@
int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
if ((is_room_aide())
&& ((TheMessage->cm_anon_type == MES_ANONONLY)
|| (TheMessage->cm_anon_type == MES_ANONOPT))) {
if ((is_room_aide())
&& ((TheMessage->cm_anon_type == MES_ANONONLY)
|| (TheMessage->cm_anon_type == MES_ANONOPT))) {
- sprintf(&display_name[strlen(display_name)],
- " [%s]", buf);
+ size_t tmp = strlen(display_name);
+ snprintf(&display_name[tmp],
+ sizeof display_name - tmp,
+ " [%s]", buf);
}
}
}
}
@@
-1541,7
+1550,7
@@
long send_message(struct CtdlMessage *msg, /* pointer to buffer */
/* Get a new message number */
newmsgid = get_new_message_number();
/* Get a new message number */
newmsgid = get_new_message_number();
- s
printf(
msgidbuf, "%ld@%s", newmsgid, config.c_fqdn);
+ s
nprintf(msgidbuf, sizeof
msgidbuf, "%ld@%s", newmsgid, config.c_fqdn);
/* Generate an ID if we don't have one already */
if (msg->cm_fields['I']==NULL) {
/* Generate an ID if we don't have one already */
if (msg->cm_fields['I']==NULL) {
@@
-1733,7
+1742,7
@@
long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */
*/
if (msg->cm_fields['T'] == NULL) {
lprintf(9, "Generating timestamp\n");
*/
if (msg->cm_fields['T'] == NULL) {
lprintf(9, "Generating timestamp\n");
- s
printf(
aaa, "%ld", (long)time(NULL));
+ s
nprintf(aaa, sizeof
aaa, "%ld", (long)time(NULL));
msg->cm_fields['T'] = strdoop(aaa);
}
msg->cm_fields['T'] = strdoop(aaa);
}
@@
-1929,7
+1938,7
@@
long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */
serialize_message(&smr, msg);
if (smr.len > 0) {
serialize_message(&smr, msg);
if (smr.len > 0) {
- s
printf(
aaa,
+ s
nprintf(aaa, sizeof
aaa,
"./network/spoolin/netmail.%04lx.%04x.%04x",
(long) getpid(), CC->cs_pid, ++seqnum);
network_fp = fopen(aaa, "wb+");
"./network/spoolin/netmail.%04lx.%04x.%04x",
(long) getpid(), CC->cs_pid, ++seqnum);
network_fp = fopen(aaa, "wb+");
@@
-1960,7
+1969,7
@@
long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */
if (recps->num_internet > 0) {
lprintf(9, "Generating delivery instructions\n");
instr = mallok(SIZ * 2);
if (recps->num_internet > 0) {
lprintf(9, "Generating delivery instructions\n");
instr = mallok(SIZ * 2);
- s
printf(instr
,
+ s
nprintf(instr, SIZ * 2
,
"Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
"bounceto|%s@%s\n",
SPOOLMIME, newmsgid, (long)time(NULL),
"Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
"bounceto|%s@%s\n",
SPOOLMIME, newmsgid, (long)time(NULL),
@@
-1968,9
+1977,10
@@
long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */
);
for (i=0; i<num_tokens(recps->recp_internet, '|'); ++i) {
);
for (i=0; i<num_tokens(recps->recp_internet, '|'); ++i) {
+ size_t tmp = strlen(instr);
extract(recipient, recps->recp_internet, i);
extract(recipient, recps->recp_internet, i);
- s
printf(&instr[strlen(instr)]
,
- "remote|%s|0||\n", recipient);
+ s
nprintf(&instr[tmp], SIZ * 2 - tmp
,
+
"remote|%s|0||\n", recipient);
}
imsg = mallok(sizeof(struct CtdlMessage));
}
imsg = mallok(sizeof(struct CtdlMessage));
@@
-2127,10
+2137,10
@@
static struct CtdlMessage *make_message(
striplt(recipient);
striplt(recipient);
- s
printf(buf, "cit%ld", author->usernum);
/* Path */
+ s
nprintf(buf, sizeof buf, "cit%ld", author->usernum);
/* Path */
msg->cm_fields['P'] = strdoop(buf);
msg->cm_fields['P'] = strdoop(buf);
- s
printf(buf, "%ld", (long)time(NULL));
/* timestamp */
+ s
nprintf(buf, sizeof buf, "%ld", (long)time(NULL));
/* timestamp */
msg->cm_fields['T'] = strdoop(buf);
if (fake_name[0]) /* author */
msg->cm_fields['T'] = strdoop(buf);
if (fake_name[0]) /* author */
@@
-2178,29
+2188,29
@@
static struct CtdlMessage *make_message(
* room. Returns a *CITADEL ERROR CODE* and puts a message in errmsgbuf, or
* returns 0 on success.
*/
* room. Returns a *CITADEL ERROR CODE* and puts a message in errmsgbuf, or
* returns 0 on success.
*/
-int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf) {
+int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf
, size_t n
) {
if (!(CC->logged_in)) {
if (!(CC->logged_in)) {
- s
printf(errmsgbuf
, "Not logged in.");
+ s
nprintf(errmsgbuf, n
, "Not logged in.");
return (ERROR + NOT_LOGGED_IN);
}
if ((CC->usersupp.axlevel < 2)
&& ((CC->quickroom.QRflags & QR_MAILBOX) == 0)) {
return (ERROR + NOT_LOGGED_IN);
}
if ((CC->usersupp.axlevel < 2)
&& ((CC->quickroom.QRflags & QR_MAILBOX) == 0)) {
- s
printf(errmsgbuf
, "Need to be validated to enter "
+ s
nprintf(errmsgbuf, n
, "Need to be validated to enter "
"(except in %s> to sysop)", MAILROOM);
return (ERROR + HIGHER_ACCESS_REQUIRED);
}
if ((CC->usersupp.axlevel < 4)
&& (CC->quickroom.QRflags & QR_NETWORK)) {
"(except in %s> to sysop)", MAILROOM);
return (ERROR + HIGHER_ACCESS_REQUIRED);
}
if ((CC->usersupp.axlevel < 4)
&& (CC->quickroom.QRflags & QR_NETWORK)) {
- s
printf(errmsgbuf
, "Need net privileges to enter here.");
+ s
nprintf(errmsgbuf, n
, "Need net privileges to enter here.");
return (ERROR + HIGHER_ACCESS_REQUIRED);
}
if ((CC->usersupp.axlevel < 6)
&& (CC->quickroom.QRflags & QR_READONLY)) {
return (ERROR + HIGHER_ACCESS_REQUIRED);
}
if ((CC->usersupp.axlevel < 6)
&& (CC->quickroom.QRflags & QR_READONLY)) {
- s
printf(errmsgbuf
, "Sorry, this is a read-only room.");
+ s
nprintf(errmsgbuf, n
, "Sorry, this is a read-only room.");
return (ERROR + HIGHER_ACCESS_REQUIRED);
}
return (ERROR + HIGHER_ACCESS_REQUIRED);
}
@@
-2330,13
+2340,13
@@
struct recptypes *validate_recipients(char *recipients) {
}
if (invalid) {
if (strlen(ret->errormsg) == 0) {
}
if (invalid) {
if (strlen(ret->errormsg) == 0) {
- s
printf(
append,
- "Invalid recipient: %s",
- this_recp);
+ s
nprintf(append, sizeof
append,
+
"Invalid recipient: %s",
+
this_recp);
}
else {
}
else {
- s
printf(append,
- ", %s", this_recp);
+ s
nprintf(append, sizeof append,
+
", %s", this_recp);
}
if ( (strlen(ret->errormsg) + strlen(append)) < SIZ) {
strcat(ret->errormsg, append);
}
if ( (strlen(ret->errormsg) + strlen(append)) < SIZ) {
strcat(ret->errormsg, append);
@@
-2347,7
+2357,8
@@
struct recptypes *validate_recipients(char *recipients) {
strcpy(append, this_recp);
}
else {
strcpy(append, this_recp);
}
else {
- sprintf(append, ", %s", this_recp);
+ snprintf(append, sizeof append, ", %s",
+ this_recp);
}
if ( (strlen(ret->display_recp)+strlen(append)) < SIZ) {
strcat(ret->display_recp, append);
}
if ( (strlen(ret->display_recp)+strlen(append)) < SIZ) {
strcat(ret->display_recp, append);
@@
-2399,7
+2410,7
@@
void cmd_ent0(char *entargs)
/* first check to make sure the request is valid. */
/* first check to make sure the request is valid. */
- err = CtdlDoIHavePermissionToPostInThisRoom(errmsg);
+ err = CtdlDoIHavePermissionToPostInThisRoom(errmsg
, sizeof errmsg
);
if (err) {
cprintf("%d %s\n", err, errmsg);
return;
if (err) {
cprintf("%d %s\n", err, errmsg);
return;
@@
-2863,7
+2874,7
@@
void CtdlWriteObject(char *req_room, /* Room to stuff it in */
fprintf(fp, "Content-transfer-encoding: base64\n\n");
fclose(tempfp);
fclose(fp);
fprintf(fp, "Content-transfer-encoding: base64\n\n");
fclose(tempfp);
fclose(fp);
- s
printf(
cmdbuf, "./base64 -e <%s >>%s",
+ s
nprintf(cmdbuf, sizeof
cmdbuf, "./base64 -e <%s >>%s",
tempfilename, filename);
system(cmdbuf);
}
tempfilename, filename);
system(cmdbuf);
}
diff --git
a/citadel/msgbase.h
b/citadel/msgbase.h
index b42b3025bda2e50afd777ac0161f5e2f72c4e40f..fd9389ba4c58541108dd1ea0089f91d51d538db9 100644
(file)
--- a/
citadel/msgbase.h
+++ b/
citadel/msgbase.h
@@
-115,6
+115,6
@@
int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
int crlf);
int CtdlCopyMsgToRoom(long msgnum, char *dest);
int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
int crlf);
int CtdlCopyMsgToRoom(long msgnum, char *dest);
int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
-int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf);
+int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf
, size_t n
);
void CtdlSetSeen(long target_msgnum, int target_setting);
struct recptypes *validate_recipients(char *recipients);
void CtdlSetSeen(long target_msgnum, int target_setting);
struct recptypes *validate_recipients(char *recipients);
diff --git
a/citadel/msgform.c
b/citadel/msgform.c
index f24bf8801b5ad5759da027f8845cd23511dbfabb..26de208eb009c31c0e943b1d902773f000003a38 100644
(file)
--- a/
citadel/msgform.c
+++ b/
citadel/msgform.c
@@
-47,7
+47,7
@@
char *strerror(int e)
{
static char buf[32];
{
static char buf[32];
- s
printf(buf,
"errno = %d",e);
+ s
nprintf(buf, sizeof buf,
"errno = %d",e);
return(buf);
}
#endif
return(buf);
}
#endif
diff --git
a/citadel/netsetup.c
b/citadel/netsetup.c
index 92710f021cdc82d1a9c92f4a6c4064d55d1dad25..a213ce6e13b496c36be2ccef43a49daf6efccefd 100644
(file)
--- a/
citadel/netsetup.c
+++ b/
citadel/netsetup.c
@@
-38,7
+38,7
@@
struct netnode *load_node(char *nodename)
struct netnode *newnn;
struct roomshare *newrs;
struct netnode *newnn;
struct roomshare *newrs;
- s
printf(
filename, "./network/systems/%s", nodename);
+ s
nprintf(filename, sizeof
filename, "./network/systems/%s", nodename);
fp = fopen(filename, "r");
if (fp == NULL) {
return NULL;
fp = fopen(filename, "r");
if (fp == NULL) {
return NULL;
@@
-76,7
+76,7
@@
void save_node(struct netnode *nnptr)
char filename[SIZ];
struct roomshare *rsptr = NULL;
char filename[SIZ];
struct roomshare *rsptr = NULL;
- s
printf(
filename, "./network/systems/%s", nnptr->nn_nodename);
+ s
nprintf(filename, sizeof
filename, "./network/systems/%s", nnptr->nn_nodename);
fp = fopen(filename, "w");
if (fp == NULL) {
fprintf(stderr, "%s\n", strerror(errno));
fp = fopen(filename, "w");
if (fp == NULL) {
fprintf(stderr, "%s\n", strerror(errno));
@@
-143,7
+143,7
@@
void add_node(char *NewNodeName)
FILE *fp;
char sysfilename[SIZ];
FILE *fp;
char sysfilename[SIZ];
- s
printf(
sysfilename, "./network/systems/%s", NewNodeName);
+ s
nprintf(sysfilename, sizeof
sysfilename, "./network/systems/%s", NewNodeName);
fp = fopen(sysfilename, "r");
if (fp != NULL) {
fp = fopen(sysfilename, "r");
if (fp != NULL) {
@@
-172,8
+172,8
@@
void delete_node(char *NodeName)
char sysfilename[SIZ];
char spooloutfilename[SIZ];
char sysfilename[SIZ];
char spooloutfilename[SIZ];
- s
printf(
sysfilename, "./network/systems/%s", NodeName);
- s
printf(
spooloutfilename, "./network/spoolout/%s", NodeName);
+ s
nprintf(sysfilename, sizeof
sysfilename, "./network/systems/%s", NodeName);
+ s
nprintf(spooloutfilename, sizeof
spooloutfilename, "./network/spoolout/%s", NodeName);
fp = fopen(sysfilename, "r");
if (fp == NULL) {
fp = fopen(sysfilename, "r");
if (fp == NULL) {
@@
-200,7
+200,7
@@
void do_roomlist(char *NodeName)
char sysfilename[SIZ];
char buf[SIZ];
char sysfilename[SIZ];
char buf[SIZ];
- s
printf(
sysfilename, "./network/systems/%s", NodeName);
+ s
nprintf(sysfilename, sizeof
sysfilename, "./network/systems/%s", NodeName);
fp = fopen(sysfilename, "r");
if (fp == NULL) {
fp = fopen(sysfilename, "r");
if (fp == NULL) {
@@
-228,7
+228,7
@@
void show_spool_cmd(char *NodeName)
char sysfilename[SIZ];
char buf[SIZ];
char sysfilename[SIZ];
char buf[SIZ];
- s
printf(
sysfilename, "./network/systems/%s", NodeName);
+ s
nprintf(sysfilename, sizeof
sysfilename, "./network/systems/%s", NodeName);
fp = fopen(sysfilename, "r");
if (fp == NULL) {
fp = fopen(sysfilename, "r");
if (fp == NULL) {
diff --git
a/citadel/room_ops.c
b/citadel/room_ops.c
index 5ebefc703c85728e869c23ff6e7c5822f4a915b3..ecaf8d84b0d4192daccca9f8e34ed23605b37ea7 100644
(file)
--- a/
citadel/room_ops.c
+++ b/
citadel/room_ops.c
@@
-192,8
+192,9
@@
int getroom(struct quickroom *qrbuf, char *room_name)
/* If that didn't work, try the user's personal namespace */
if (cdbqr == NULL) {
/* If that didn't work, try the user's personal namespace */
if (cdbqr == NULL) {
- sprintf(personal_lowercase_name, "%010ld.%s",
- CC->usersupp.usernum, lowercase_name);
+ snprintf(personal_lowercase_name,
+ sizeof personal_lowercase_name, "%010ld.%s",
+ CC->usersupp.usernum, lowercase_name);
cdbqr = cdb_fetch(CDB_QUICKROOM,
personal_lowercase_name,
strlen(personal_lowercase_name));
cdbqr = cdb_fetch(CDB_QUICKROOM,
personal_lowercase_name,
strlen(personal_lowercase_name));
@@
-918,11
+919,11
@@
void cmd_rdir(void)
cprintf("%d %s|%s/files/%s\n",
LISTING_FOLLOWS, config.c_fqdn, BBSDIR, CC->quickroom.QRdirname);
cprintf("%d %s|%s/files/%s\n",
LISTING_FOLLOWS, config.c_fqdn, BBSDIR, CC->quickroom.QRdirname);
- s
printf(
buf, "ls %s/files/%s >%s 2> /dev/null",
+ s
nprintf(buf, sizeof
buf, "ls %s/files/%s >%s 2> /dev/null",
BBSDIR, CC->quickroom.QRdirname, CC->temp);
system(buf);
BBSDIR, CC->quickroom.QRdirname, CC->temp);
system(buf);
- s
printf(
buf, "%s/files/%s/filedir", BBSDIR, CC->quickroom.QRdirname);
+ s
nprintf(buf, sizeof
buf, "%s/files/%s/filedir", BBSDIR, CC->quickroom.QRdirname);
fd = fopen(buf, "r");
if (fd == NULL)
fd = fopen("/dev/null", "r");
fd = fopen(buf, "r");
if (fd == NULL)
fd = fopen("/dev/null", "r");
@@
-931,7
+932,7
@@
void cmd_rdir(void)
while (fgets(flnm, sizeof flnm, ls) != NULL) {
flnm[strlen(flnm) - 1] = 0;
if (strcasecmp(flnm, "filedir")) {
while (fgets(flnm, sizeof flnm, ls) != NULL) {
flnm[strlen(flnm) - 1] = 0;
if (strcasecmp(flnm, "filedir")) {
- s
printf(
buf, "%s/files/%s/%s",
+ s
nprintf(buf, sizeof
buf, "%s/files/%s/%s",
BBSDIR, CC->quickroom.QRdirname, flnm);
stat(buf, &statbuf);
strcpy(comment, "");
BBSDIR, CC->quickroom.QRdirname, flnm);
stat(buf, &statbuf);
strcpy(comment, "");
@@
-1081,12
+1082,12
@@
void cmd_setr(char *args)
/* create a room directory if necessary */
if (CC->quickroom.QRflags & QR_DIRECTORY) {
/* create a room directory if necessary */
if (CC->quickroom.QRflags & QR_DIRECTORY) {
- s
printf(
buf,
+ s
nprintf(buf, sizeof
buf,
"mkdir ./files/%s </dev/null >/dev/null 2>/dev/null",
CC->quickroom.QRdirname);
system(buf);
}
"mkdir ./files/%s </dev/null >/dev/null 2>/dev/null",
CC->quickroom.QRdirname);
system(buf);
}
- s
printf(
buf, "%s> edited by %s\n", CC->quickroom.QRname, CC->curr_user);
+ s
nprintf(buf, sizeof
buf, "%s> edited by %s\n", CC->quickroom.QRname, CC->curr_user);
aide_message(buf);
cprintf("%d Ok\n", OK);
}
aide_message(buf);
cprintf("%d Ok\n", OK);
}
@@
-1145,7
+1146,7
@@
void cmd_seta(char *new_ra)
* the room table, otherwise it would deadlock!
*/
if (post_notice == 1) {
* the room table, otherwise it would deadlock!
*/
if (post_notice == 1) {
- s
printf(
buf, "%s is now room aide for %s>\n",
+ s
nprintf(buf, sizeof
buf, "%s is now room aide for %s>\n",
usbuf.fullname, CC->quickroom.QRname);
aide_message(buf);
}
usbuf.fullname, CC->quickroom.QRname);
aide_message(buf);
}
@@
-1155,9
+1156,10
@@
void cmd_seta(char *new_ra)
/*
* Generate an associated file name for a room
*/
/*
* Generate an associated file name for a room
*/
-void assoc_file_name(char *buf, struct quickroom *qrbuf, char *prefix)
+void assoc_file_name(char *buf, size_t n,
+ struct quickroom *qrbuf, const char *prefix)
{
{
- s
printf(buf
, "./%s/%ld", prefix, qrbuf->QRnumber);
+ s
nprintf(buf, n
, "./%s/%ld", prefix, qrbuf->QRnumber);
}
/*
}
/*
@@
-1169,7
+1171,7
@@
void cmd_rinf(void)
char buf[SIZ];
FILE *info_fp;
char buf[SIZ];
FILE *info_fp;
- assoc_file_name(filename, &CC->quickroom, "info");
+ assoc_file_name(filename,
sizeof filename,
&CC->quickroom, "info");
info_fp = fopen(filename, "r");
if (info_fp == NULL) {
info_fp = fopen(filename, "r");
if (info_fp == NULL) {
@@
-1197,15
+1199,15
@@
void delete_room(struct quickroom *qrbuf)
lprintf(9, "Deleting room <%s>\n", qrbuf->QRname);
/* Delete the info file */
lprintf(9, "Deleting room <%s>\n", qrbuf->QRname);
/* Delete the info file */
- assoc_file_name(filename, qrbuf, "info");
+ assoc_file_name(filename,
sizeof filename,
qrbuf, "info");
unlink(filename);
/* Delete the image file */
unlink(filename);
/* Delete the image file */
- assoc_file_name(filename, qrbuf, "images");
+ assoc_file_name(filename,
sizeof filename,
qrbuf, "images");
unlink(filename);
/* Delete the room's network config file */
unlink(filename);
/* Delete the room's network config file */
- assoc_file_name(filename, qrbuf, "netconfigs");
+ assoc_file_name(filename,
sizeof filename,
qrbuf, "netconfigs");
unlink(filename);
/* Delete the messages in the room
unlink(filename);
/* Delete the messages in the room
@@
-1292,8
+1294,8
@@
void cmd_kill(char *argbuf)
usergoto(BASEROOM, 0, NULL, NULL); /* Return to the Lobby */
/* tell the world what we did */
usergoto(BASEROOM, 0, NULL, NULL); /* Return to the Lobby */
/* tell the world what we did */
- s
printf(
aaa, "%s> killed by %s\n",
- deleted_room_name, CC->curr_user);
+ s
nprintf(aaa, sizeof
aaa, "%s> killed by %s\n",
+
deleted_room_name, CC->curr_user);
aide_message(aaa);
cprintf("%d '%s' deleted.\n", OK, deleted_room_name);
} else {
aide_message(aaa);
cprintf("%d '%s' deleted.\n", OK, deleted_room_name);
} else {
@@
-1505,7
+1507,7
@@
void cmd_einf(char *ok)
cprintf("%d Ok.\n", OK);
return;
}
cprintf("%d Ok.\n", OK);
return;
}
- assoc_file_name(infofilename, &CC->quickroom, "info");
+ assoc_file_name(infofilename,
sizeof infofilename,
&CC->quickroom, "info");
lprintf(9, "opening\n");
fp = fopen(infofilename, "w");
lprintf(9, "checking\n");
lprintf(9, "opening\n");
fp = fopen(infofilename, "w");
lprintf(9, "checking\n");
diff --git
a/citadel/room_ops.h
b/citadel/room_ops.h
index 5adab90c45325ddf9478e4b86cd3185ff8fda5ea..573644320018a01a154daecc2f035f16b2085ce8 100644
(file)
--- a/
citadel/room_ops.h
+++ b/
citadel/room_ops.h
@@
-45,7
+45,8
@@
void cmd_kflr (char *argbuf);
void cmd_eflr (char *argbuf);
void ForEachRoom(void (*CallBack)(struct quickroom *EachRoom, void *out_data),
void *in_data);
void cmd_eflr (char *argbuf);
void ForEachRoom(void (*CallBack)(struct quickroom *EachRoom, void *out_data),
void *in_data);
-void assoc_file_name(char *buf, struct quickroom *qrbuf, char *prefix);
+void assoc_file_name(char *buf, size_t n,
+ struct quickroom *qrbuf, const char *prefix);
void delete_room(struct quickroom *qrbuf);
void list_roomname(struct quickroom *qrbuf);
int is_noneditable(struct quickroom *qrbuf);
void delete_room(struct quickroom *qrbuf);
void list_roomname(struct quickroom *qrbuf);
int is_noneditable(struct quickroom *qrbuf);
diff --git
a/citadel/serv_network.c
b/citadel/serv_network.c
index e8c5256152be100225373debe343d80f0e4bbfb2..164e890c9d9ecd75078c42785b279741f7e25326 100644
(file)
--- a/
citadel/serv_network.c
+++ b/
citadel/serv_network.c
@@
-322,7
+322,7
@@
void cmd_gnet(char *argbuf) {
FILE *fp;
if (CtdlAccessCheck(ac_room_aide)) return;
FILE *fp;
if (CtdlAccessCheck(ac_room_aide)) return;
- assoc_file_name(filename, &CC->quickroom, "netconfigs");
+ assoc_file_name(filename,
sizeof filename,
&CC->quickroom, "netconfigs");
cprintf("%d Network settings for room #%ld <%s>\n",
LISTING_FOLLOWS,
CC->quickroom.QRnumber, CC->quickroom.QRname);
cprintf("%d Network settings for room #%ld <%s>\n",
LISTING_FOLLOWS,
CC->quickroom.QRnumber, CC->quickroom.QRname);
@@
-348,7
+348,7
@@
void cmd_snet(char *argbuf) {
if (CtdlAccessCheck(ac_room_aide)) return;
safestrncpy(tempfilename, tmpnam(NULL), sizeof tempfilename);
if (CtdlAccessCheck(ac_room_aide)) return;
safestrncpy(tempfilename, tmpnam(NULL), sizeof tempfilename);
- assoc_file_name(filename, &CC->quickroom, "netconfigs");
+ assoc_file_name(filename,
sizeof filename,
&CC->quickroom, "netconfigs");
fp = fopen(tempfilename, "w");
if (fp == NULL) {
fp = fopen(tempfilename, "w");
if (fp == NULL) {
@@
-571,7
+571,7
@@
void network_spoolout_room(char *room_to_spool) {
}
memset(&sc, 0, sizeof(struct SpoolControl));
}
memset(&sc, 0, sizeof(struct SpoolControl));
- assoc_file_name(filename, &CC->quickroom, "netconfigs");
+ assoc_file_name(filename,
sizeof filename,
&CC->quickroom, "netconfigs");
fp = fopen(filename, "r");
if (fp == NULL) {
fp = fopen(filename, "r");
if (fp == NULL) {