dirs[1]=mallok(64);
strcpy(dirs[0],"messages");
strcpy(dirs[1],"help");
- mesg_locate(targ,buf,2,dirs);
+ mesg_locate(targ,sizeof targ,buf,2,(const char **)dirs);
phree(dirs[0]);
phree(dirs[1]);
dirs[1]=mallok(64);
strcpy(dirs[0],"messages");
strcpy(dirs[1],"help");
- mesg_locate(targ,buf,2,dirs);
+ mesg_locate(targ,sizeof targ,buf,2,(const char**)dirs);
phree(dirs[0]);
phree(dirs[1]);
putuser(&newus);
/* write the vcard */
- sprintf(vcard,
+ snprintf(vcard, sizeof vcard,
"Content-type: text/x-vcard\n\n"
"begin:vcard\n"
"n:%s\n"
* this will be handled by exporting the reference count, not by
* exporting the message multiple times.)
*/
- sprintf(cmd, "sort <%s >%s", artv_tempfilename1, artv_tempfilename2);
+ snprintf(cmd, sizeof cmd, "sort <%s >%s", artv_tempfilename1, artv_tempfilename2);
system(cmd);
- sprintf(cmd, "uniq <%s >%s", artv_tempfilename2, artv_tempfilename1);
+ snprintf(cmd, sizeof cmd, "uniq <%s >%s", artv_tempfilename2, artv_tempfilename1);
system(cmd);
}
/* write it in base64 */
strcpy(tempfile, tmpnam(NULL));
- sprintf(buf, "./base64 -e >%s", tempfile);
+ snprintf(buf, sizeof buf, "./base64 -e >%s", tempfile);
fp = popen(buf, "w");
fwrite(smr.ser, smr.len, 1, fp);
pclose(fp);
/* decode base64 message text */
strcpy(tempfile, tmpnam(NULL));
- sprintf(buf, "./base64 -d >%s", tempfile);
+ snprintf(buf, sizeof buf, "./base64 -d >%s", tempfile);
fp = popen(buf, "w");
while (client_gets(buf), strcasecmp(buf, END_OF_MESSAGE)) {
fprintf(fp, "%s\n", buf);
if (msg->cm_fields['A'] == NULL) return;
if (msg->cm_fields['N'] == NULL) return;
- sprintf(citadel_address, "%s @ %s",
+ snprintf(citadel_address, sizeof citadel_address, "%s @ %s",
msg->cm_fields['A'], msg->cm_fields['N']);
v = vcard_load(msg->cm_fields['M']);
if (msg->cm_fields['E'] != NULL)
phree(msg->cm_fields['E']);
- sprintf(buf, VCARD_EXT_FORMAT,
+ snprintf(buf, sizeof buf, VCARD_EXT_FORMAT,
msg->cm_fields['A'], NODENAME);
msg->cm_fields['E'] = strdoop(buf);
++a;
}
- sprintf(tmpaddress, ";;%s;%s;%s;%s;%s",
+ snprintf(tmpaddress, sizeof tmpaddress, ";;%s;%s;%s;%s;%s",
tmpaddr, tmpcity, tmpstate, tmpzip, tmpcountry);
vcard_set_prop(my_vcard, "adr", tmpaddress, 0);
vcard_write_user(&CC->usersupp, my_vcard);
cprintf("%s\n", s ? s : " "); /* name */
s = vcard_get_prop(v, "adr", 0, 0, 0);
- sprintf(adr, "%s", s ? s : " ");/* address... */
+ snprintf(adr, sizeof adr, "%s", s ? s : " ");/* address... */
extract_token(buf, adr, 2, ';');
cprintf("%s\n", buf); /* street */
s = vcard_get_prop(v, "email;internet", 0, 0, 0);
cprintf("%s\n", s ? s : " ");
s = vcard_get_prop(v, "adr", 0, 0, 0);
- sprintf(adr, "%s", s ? s : " ");/* address... */
+ snprintf(adr, sizeof adr, "%s", s ? s : " ");/* address... */
extract_token(buf, adr, 6, ';');
cprintf("%s\n", buf); /* country */
msg->cm_fields['N'] = strdoop(NODENAME);
msg->cm_fields['M'] = strdoop("Purge this vCard\n");
- sprintf(buf, VCARD_EXT_FORMAT, msg->cm_fields['A'], NODENAME);
+ snprintf(buf, sizeof buf, VCARD_EXT_FORMAT, msg->cm_fields['A'], NODENAME);
msg->cm_fields['E'] = strdoop(buf);
msg->cm_fields['S'] = strdoop("CANCEL");
char question[128];
FILE *sfp;
- sprintf(question,
+ snprintf(question, sizeof question,
"There is no '%s' entry in /etc/services. Would you like to add one?",
SERVICE_NAME);
char entryname[5];
/* Determine the fully qualified path name of citserver */
- sprintf(looking_for, "%s/citserver ", BBSDIR);
+ snprintf(looking_for, sizeof looking_for, "%s/citserver ", BBSDIR);
/* Pound through /etc/inittab line by line. Set have_entry to 1 if
* an entry is found which we believe starts citserver.
return;
/* Otherwise, prompt the user to create an entry. */
- sprintf(question,
+ snprintf(question, sizeof question,
"There is no '%s' entry in /etc/inittab.\n"
"Would you like to add one?",
looking_for);
return;
/* Generate a unique entry name for /etc/inittab */
- sprintf(entryname, "c0");
+ snprintf(entryname, sizeof entryname, "c0");
do {
++entryname[1];
if (entryname[1] > '9') {
return;
}
}
- sprintf(buf,
+ snprintf(buf, sizeof buf,
"grep %s: /etc/inittab >/dev/null 2>&1", entryname);
} while (system(buf) == 0);
void set_int_val(int msgpos, int *ip)
{
char buf[16];
- sprintf(buf, "%d", (int) *ip);
+ snprintf(buf, sizeof buf, "%d", (int) *ip);
set_str_val(msgpos, buf);
*ip = atoi(buf);
}
void set_char_val(int msgpos, char *ip)
{
char buf[16];
- sprintf(buf, "%d", (int) *ip);
+ snprintf(buf, sizeof buf, "%d", (int) *ip);
set_str_val(msgpos, buf);
*ip = (char) atoi(buf);
}
void set_long_val(int msgpos, long int *ip)
{
char buf[16];
- sprintf(buf, "%ld", *ip);
+ snprintf(buf, sizeof buf, "%ld", *ip);
set_str_val(msgpos, buf);
*ip = atol(buf);
}
progress("Setting file permissions", 1, 5);
chown("citadel.config", config.c_bbsuid, gid);
progress("Setting file permissions", 2, 5);
- sprintf(aaa,
+ snprintf(aaa, sizeof aaa,
"find . | grep -v chkpwd | xargs chown %ld:%ld 2>/dev/null",
(long)config.c_bbsuid, (long)gid);
system(aaa);
fakeargs[0] = "whobbs";
fakeargs[1] = "localhost";
fakeargs[2] = malloc(64);
- sprintf(fakeargs[2], "%d", config.c_port_number);
+ snprintf(fakeargs[2], 64, "%d", config.c_port_number);
fakeargs[3] = NULL;
attach_to_server(3, fakeargs, hostbuf, portbuf);
free(fakeargs[2]);
/*
* mesg_locate() - locate a message or help file, case insensitive
*/
-void mesg_locate(char *targ, char *searchfor, int numdirs, char **dirs)
+void mesg_locate(char *targ, size_t n, const char *searchfor,
+ int numdirs, const char * const *dirs)
{
int a;
char buf[SIZ];
FILE *ls;
for (a=0; a<numdirs; ++a) {
- sprintf(buf,"cd %s; exec ls",dirs[a]);
+ snprintf(buf, sizeof buf, "cd %s; exec ls",dirs[a]);
ls = (FILE *) popen(buf,"r");
if (ls != NULL) {
while(fgets(buf,sizeof buf,ls)!=NULL) {
buf[strlen(buf)-1] = 0;
if (!strcasecmp(buf,searchfor)) {
pclose(ls);
- sprintf(targ,"%s/%s",dirs[a],buf);
+ snprintf(targ,n,"%s/%s",dirs[a],buf);
return;
}
}
{
static char buf[32];
- sprintf(buf,"errno = %d",e);
+ snprintf(buf,sizeof buf,"errno = %d",e);
return(buf);
}
#endif
void strproc (char *string);
int getstring (FILE *fp, char *string);
int pattern2 (char *search, char *patn);
-void mesg_locate (char *targ, char *searchfor, int numdirs, char **dirs);
+void mesg_locate (char *targ, size_t n, const char *searchfor,
+ int numdirs, const char * const *dirs);