color(BRIGHT_CYAN);
pprintf("\n Rooms with unread messages on %s:\n",
floorlist[(int) curr_floor]);
- sprintf(buf, "LKRN %d", curr_floor);
+ snprintf(buf, sizeof buf, "LKRN %d", curr_floor);
listrms(buf);
color(BRIGHT_CYAN);
pprintf("\n\n Rooms with no new messages on %s:\n",
floorlist[(int) curr_floor]);
- sprintf(buf, "LKRO %d", curr_floor);
+ snprintf(buf, sizeof buf, "LKRO %d", curr_floor);
listrms(buf);
color(BRIGHT_CYAN);
pprintf("\n\n Other floors:\n");
color(BRIGHT_CYAN);
pprintf("\n Rooms on %s:\n",
floorlist[a]);
- sprintf(buf, "LKRA %d", a);
+ snprintf(buf, sizeof buf, "LKRA %d", a);
listrms(buf);
pprintf("\n");
}
/* Angels and demons dancing in my head... */
do {
- sprintf(buf, "%d", expire_mode);
+ snprintf(buf, sizeof buf, "%d", expire_mode);
strprompt("Message expire policy (? for list)", buf, 1);
if (buf[0] == '?') {
scr_printf("\n"
/* ...lunatics and monsters underneath my bed */
if (expire_mode == 2) {
- sprintf(buf, "%d", expire_value);
+ snprintf(buf, sizeof buf, "%d", expire_value);
strprompt("Keep how many messages online?", buf, 10);
expire_value = atol(buf);
}
if (expire_mode == 3) {
- sprintf(buf, "%d", expire_value);
+ snprintf(buf, sizeof buf, "%d", expire_value);
strprompt("Keep messages for how many days?", buf, 10);
expire_value = atol(buf);
}
scr_printf("%s\n", &buf[4]);
return;
}
- sprintf(buf, "SLRP %ld", uglistlsn[uglistsize-1]);
+ snprintf(buf, sizeof buf, "SLRP %ld", uglistlsn[uglistsize-1]);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
while ((transmitted_bytes < total_bytes) && (broken == 0)) {
bb = total_bytes - transmitted_bytes;
aa = ((bb < 4096) ? bb : 4096);
- sprintf(buf, "READ %ld|%ld", transmitted_bytes, aa);
+ snprintf(buf, sizeof buf, "READ %ld|%ld", transmitted_bytes, aa);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '6') {
progress(transmitted_bytes, total_bytes);
bb = total_bytes - transmitted_bytes;
aa = ((bb < 4096) ? bb : 4096);
- sprintf(buf, "READ %ld|%ld", transmitted_bytes, aa);
+ snprintf(buf, sizeof buf, "READ %ld|%ld", transmitted_bytes, aa);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '6') {
}
if (proto == 0) {
- sprintf(transmit_cmd,
+ snprintf(transmit_cmd, sizeof transmit_cmd,
"SHELL=/dev/null; export SHELL; TERM=dumb; export TERM; exec more -d <%s",
tempname);
}
else if (proto == 1)
- sprintf(transmit_cmd, "exec sx %s", tempname);
+ snprintf(transmit_cmd, sizeof transmit_cmd, "exec sx %s", tempname);
else if (proto == 3)
- sprintf(transmit_cmd, "exec sb %s", tempname);
+ snprintf(transmit_cmd, sizeof transmit_cmd, "exec sb %s", tempname);
else if (proto == 4)
- sprintf(transmit_cmd, "exec sz %s", tempname);
+ snprintf(transmit_cmd, sizeof transmit_cmd, "exec sz %s", tempname);
else
- sprintf(transmit_cmd, "exec cat %s", tempname);
+ snprintf(transmit_cmd, sizeof transmit_cmd, "exec cat %s", tempname);
screen_reset();
sttybbs(SB_RESTORE);
{ /* read info file for current room */
char cmd[SIZ];
- sprintf(cmd, "RINF");
+ snprintf(cmd, sizeof cmd, "RINF");
serv_puts(cmd);
serv_gets(cmd);
/* Angels and demons dancing in my head... */
do {
- sprintf(buf, "%d", expire_mode);
+ snprintf(buf, sizeof buf, "%d", expire_mode);
strprompt
("Floor default essage expire policy (? for list)",
buf, 1);
/* ...lunatics and monsters underneath my bed */
if (expire_mode == 2) {
- sprintf(buf, "%d", expire_value);
+ snprintf(buf, sizeof buf, "%d", expire_value);
strprompt("Keep how many messages online?", buf, 10);
expire_value = atol(buf);
}
if (expire_mode == 3) {
- sprintf(buf, "%d", expire_value);
+ snprintf(buf, sizeof buf, "%d", expire_value);
strprompt("Keep messages for how many days?", buf, 10);
expire_value = atol(buf);
}
scr_printf("%s\n", &floorlist[a][0]);
}
} while (floornum_to_delete < 0);
- sprintf(buf, "KFLR %d|1", floornum_to_delete);
+ snprintf(buf, sizeof buf, "KFLR %d|1", floornum_to_delete);
serv_puts(buf);
serv_gets(buf);
scr_printf("%s\n", &buf[4]);
ok = 1;
strcpy(holdemail, tmpemail);
strprompt("Email address", tmpemail, 31);
- sprintf(buf, "QDIR %s", tmpemail);
+ snprintf(buf, sizeof buf, "QDIR %s", tmpemail);
serv_puts(buf);
serv_gets(buf);
if (buf[0]=='2') {
{
char buf[SIZ];
- sprintf(buf, "SLRP %ld", highest_msg_read);
+ snprintf(buf, sizeof buf, "SLRP %ld", highest_msg_read);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2')
do {
bytes_to_send = read(fd, tbuf, 4096);
if (bytes_to_send > 0) {
- sprintf(buf, "WRIT %d", bytes_to_send);
+ snprintf(buf, sizeof buf, "WRIT %d", bytes_to_send);
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '7') {
strcpy(buf, flnm);
while ((strlen(buf) > 0) && (haschar(buf, '/')))
strcpy(buf, &buf[1]);
- if (a > 0)
- sprintf(&buf[strlen(buf)], "%d", a);
- sprintf(tbuf, "UOPN %s|%s", buf, desc);
+ if (a > 0) {
+ size_t tmp = strlen(buf);
+ snprintf(&buf[tmp], sizeof buf - tmp, "%d", a);
+ }
+ snprintf(tbuf, sizeof tbuf, "UOPN %s|%s", buf, desc);
serv_puts(tbuf);
serv_gets(buf);
if (buf[0] != '2')
char buf[SIZ];
int fd;
- sprintf(buf, "UIMG 0|%s", keyname);
+ snprintf(buf, sizeof buf, "UIMG 0|%s", keyname);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
return;
}
- sprintf(buf, "UIMG 1|%s", keyname);
+ snprintf(buf, sizeof buf, "UIMG 1|%s", keyname);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
return;
}
scr_printf("\r*** Transfer successful. Sending file(s) to server...\n");
- sprintf(buf, "cd %s; ls", tempdir);
+ snprintf(buf, sizeof buf, "cd %s; ls", tempdir);
lsfp = popen(buf, "r");
if (lsfp != NULL) {
while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
flnm[strlen(flnm) - 1] = 0;
- sprintf(buf, "%s/%s", tempdir, flnm);
+ snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
fd = open(buf, O_RDONLY);
if (fd >= 0) {
a = 0;
do {
- sprintf(buf, "UOPN %s|%s", flnm, desc);
- if (a > 0)
- sprintf(&buf[strlen(buf)],
+ snprintf(buf, sizeof buf, "UOPN %s|%s", flnm, desc);
+ if (a > 0) {
+ size_t tmp = strlen(buf);
+ snprintf(&buf[tmp],
+ sizeof buf - tmp,
".%d", a);
+ }
++a;
serv_puts(buf);
serv_gets(buf);
do {
a = read(fd, tbuf, 4096);
if (a > 0) {
- sprintf(buf, "WRIT %d", a);
+ snprintf(buf, sizeof buf, "WRIT %d", a);
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '7')
char buf[SIZ];
int ax = 0;
- sprintf(cmd, "GREG %s", user);
+ snprintf(cmd, sizeof cmd, "GREG %s", user);
serv_puts(cmd);
serv_gets(cmd);
if (cmd[0] == '1') {
if (do_validate) {
/* now set the access level */
ax = intprompt("Access level", ax, 0, 6);
- sprintf(cmd, "VALI %s|%d", user, ax);
+ snprintf(cmd, sizeof cmd, "VALI %s|%d", user, ax);
serv_puts(cmd);
serv_gets(cmd);
if (cmd[0] != '2')
newprompt("Filename: ", filename, 31);
if (strlen(filename) == 0)
return;
- sprintf(cmd, "DELF %s", filename);
+ snprintf(cmd, sizeof cmd, "DELF %s", filename);
serv_puts(cmd);
serv_gets(cmd);
err_printf("%s\n", &cmd[4]);
if (strlen(filename) == 0)
return;
newprompt("System to send to: ", destsys, 19);
- sprintf(cmd, "NETF %s|%s", filename, destsys);
+ snprintf(cmd, sizeof cmd, "NETF %s|%s", filename, destsys);
serv_puts(cmd);
serv_gets(cmd);
err_printf("%s\n", &cmd[4]);
return;
newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
- sprintf(cmd, "MOVF %s|%s", filename, newroom);
+ snprintf(cmd, sizeof cmd, "MOVF %s|%s", filename, newroom);
serv_puts(cmd);
serv_gets(cmd);
err_printf("%s\n", &cmd[4]);
if (!strcmp(who, "?"))
list_bio();
} while (!strcmp(who, "?"));
- sprintf(buf, "RBIO %s", who);
+ snprintf(buf, sizeof buf, "RBIO %s", who);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '1') {
/* Security parameters */
- sprintf(&sc[7][0], "%d", (boolprompt(
+ snprintf(sc[7], sizeof sc[7], "%d", (boolprompt(
"Require registration for new users",
atoi(&sc[7][0]))));
- sprintf(&sc[29][0], "%d", (boolprompt(
+ snprintf(sc[29], sizeof sc[29], "%d", (boolprompt(
"Disable self-service user account creation",
atoi(&sc[29][0]))));
strprompt("Initial access level for new users", &sc[6][0], 1);
strprompt("Access level required to create rooms", &sc[19][0], 1);
- sprintf(&sc[4][0], "%d", (boolprompt(
+ snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
"Automatically give room aide privs to a user who creates a private room",
atoi(&sc[4][0]))));
- sprintf(&sc[8][0], "%d", (boolprompt(
+ snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
"Automatically move problem user messages to twit room",
atoi(&sc[8][0]))));
strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
- sprintf(&sc[11][0], "%d", (boolprompt(
+ snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
"Restrict Internet mail to only those with that privilege",
atoi(&sc[11][0]))));
- sprintf(&sc[26][0], "%d", (boolprompt(
+ snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
"Allow Aides to Zap (forget) rooms",
atoi(&sc[26][0]))));
/* Angels and demons dancing in my head... */
do {
- sprintf(buf, "%d", expire_mode);
+ snprintf(buf, sizeof buf, "%d", expire_mode);
strprompt("System default message expire policy (? for list)",
buf, 1);
if (buf[0] == '?') {
/* ...lunatics and monsters underneath my bed */
if (expire_mode == 2) {
- sprintf(buf, "%d", expire_value);
+ snprintf(buf, sizeof buf, "%d", expire_value);
strprompt("Keep how many messages online?", buf, 10);
expire_value = atol(buf);
}
if (expire_mode == 3) {
- sprintf(buf, "%d", expire_value);
+ snprintf(buf, sizeof buf, "%d", expire_value);
strprompt("Keep messages for how many days?", buf, 10);
expire_value = atol(buf);
}
int quitting = 0;
- sprintf(buf, "CONF getsys|%s", INTERNETCFG);
+ snprintf(buf, sizeof buf, "CONF getsys|%s", INTERNETCFG);
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
recs[j] = recs[j+1];
break;
case 's':
- sprintf(buf, "CONF putsys|%s",
+ snprintf(buf, sizeof buf, "CONF putsys|%s",
INTERNETCFG);
serv_puts(buf);
serv_gets(buf);
int quitting = 0;
- sprintf(buf, "CONF getsys|%s", IGNETCFG);
+ snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
recs[j] = recs[j+1];
break;
case 's':
- sprintf(buf, "CONF putsys|%s", IGNETCFG);
+ snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '4') {
int quitting = 0;
- sprintf(buf, "CONF getsys|%s", FILTERLIST);
+ snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
recs[j] = recs[j+1];
break;
case 's':
- sprintf(buf, "CONF putsys|%s", FILTERLIST);
+ snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '4') {