}
}
else if (!strncasecmp(buf, "time=", 5)) {
- fmt_date(now, atol(&buf[5]), 0);
+ fmt_date(now, sizeof now, atol(&buf[5]), 0);
if (dest) {
fprintf(dest, "%s ", now);
} else {
mode = 0;
}
- fmt_date(datestr, time(NULL), 0);
+ fmt_date(datestr, sizeof datestr, time(NULL), 0);
header[0] = 0;
if (room_flags & QR_ANONONLY && !recipient) {
lprintf(9, "Delivering private local mail to <%s>\n",
recipient);
if (getuser(&userbuf, recipient) == 0) {
- MailboxName(actual_rm, &userbuf, MAILROOM);
+ MailboxName(actual_rm, sizeof actual_rm, &userbuf, MAILROOM);
CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0);
}
else {
size_t len;
if (is_mailbox != NULL)
- MailboxName(roomname, is_mailbox, req_room);
+ MailboxName(roomname, sizeof roomname, is_mailbox, req_room);
else
safestrncpy(roomname, req_room, sizeof(roomname));
lprintf(9, "CtdlWriteObject() to <%s> (flags=%d)\n", roomname, flags);
/* Then try a mailbox name match */
if (c != 0) {
- MailboxName(augmented_roomname, &CC->usersupp, towhere);
+ MailboxName(augmented_roomname, sizeof augmented_roomname,
+ &CC->usersupp, towhere);
c = getroom(&QRscratch, augmented_roomname);
if (c == 0)
strcpy(towhere, augmented_roomname);
* name accordingly (prepend the user number)
*/
if (new_room_type == 4) {
- MailboxName(qrbuf.QRname, &CC->usersupp, new_room_name);
+ MailboxName(qrbuf.QRname, sizeof qrbuf.QRname, &CC->usersupp, new_room_name);
}
else {
safestrncpy(qrbuf.QRname, new_room_name, sizeof qrbuf.QRname);
malloc(sizeof(struct savelist));
sptr->next = sl;
MailboxName(sptr->roomname,
+ sizeof sptr->roomname,
&ccptr->usersupp, PAGELOGROOM);
sl = sptr;
}
*/
/* First determine if this is our room */
- MailboxName(roomname, &CC->usersupp, USERCALENDARROOM);
+ MailboxName(roomname, sizeof roomname, &CC->usersupp, USERCALENDARROOM);
if (strncmp(roomname, msg->cm_fields['O'], ROOMNAMELEN))
return 0; /* It's not us... */
/* Then try a mailbox name match */
if (c != 0) {
- MailboxName(augmented_roomname, &CC->usersupp, towhere);
+ MailboxName(augmented_roomname, sizeof augmented_roomname,
+ &CC->usersupp, towhere);
c = getroom(&QRscratch, augmented_roomname);
if (c == 0)
strcpy(towhere, augmented_roomname);
/* Then try a mailbox name match */
if (c != 0) {
- MailboxName(augmented_roomname, &CC->usersupp, roomname);
+ MailboxName(augmented_roomname, sizeof augmented_roomname,
+ &CC->usersupp, roomname);
c = getroom(&QRscratch, augmented_roomname);
if (c == 0)
strcpy(roomname, augmented_roomname);
* to make changes to another user's vCard instead of
* assuming that it's always the user saving his own.
*/
- MailboxName(config_rm, &CC->usersupp, USERCONFIGROOM);
+ MailboxName(config_rm, sizeof config_rm,
+ &CC->usersupp, USERCONFIGROOM);
CtdlDeleteMessages(config_rm, 0L, "text/x-vcard");
/* Set the Extended-ID to a standardized one so the
struct vCard *v;
strcpy(hold_rm, CC->quickroom.QRname); /* save current room */
- MailboxName(config_rm, u, USERCONFIGROOM);
+ MailboxName(config_rm, sizeof config_rm, u, USERCONFIGROOM);
if (getroom(&CC->quickroom, config_rm) != 0) {
getroom(&CC->quickroom, hold_rm);
* Format a date/time stamp for output
* seconds is whether to print the seconds
*/
-void fmt_date(char *buf, time_t thetime, int seconds) {
+void fmt_date(char *buf, size_t n, time_t thetime, int seconds) {
struct tm *tm;
int hour;
else if (hour > 12) hour = hour - 12;
if (seconds) {
- sprintf(buf, "%s %d %4d %d:%02d:%02d%s",
+ snprintf(buf, n, "%s %d %4d %d:%02d:%02d%s",
ascmonths[tm->tm_mon],
tm->tm_mday,
tm->tm_year + 1900,
( (tm->tm_hour >= 12) ? "pm" : "am" )
);
} else {
- sprintf(buf, "%s %d %4d %d:%02d%s",
+ snprintf(buf, n, "%s %d %4d %d:%02d%s",
ascmonths[tm->tm_mon],
tm->tm_mday,
tm->tm_year + 1900,
if (num_tokens(setstr, ':') >= 2) {
extract_token(histr, setstr, 1, ':');
if (!strcmp(histr, "*")) {
- sprintf(histr, "%ld", LONG_MAX);
+ snprintf(histr, sizeof histr, "%ld", LONG_MAX);
}
}
else {
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);
+void fmt_date(char *buf, size_t n, time_t thetime, int seconds);
int is_msg_in_mset(char *mset, long msgnum);
char *memreadline(char *start, char *buf, int maxlen);
/* Set v_seen if necessary */
if (vbuf->v_seen[0] == 0) {
- sprintf(vbuf->v_seen, "*:%ld", vbuf->v_lastseen);
+ snprintf(vbuf->v_seen, sizeof vbuf->v_seen, "*:%ld", vbuf->v_lastseen);
}
}
-void MailboxName(char *buf, struct usersupp *who, char *prefix)
+void MailboxName(char *buf, size_t n, const struct usersupp *who, const char *prefix)
{
- sprintf(buf, "%010ld.%s", who->usernum, prefix);
+ snprintf(buf, n, "%010ld.%s", who->usernum, prefix);
}
putuser(&usbuf);
/* give the user a private mailbox */
- MailboxName(mailboxname, &usbuf, MAILROOM);
+ MailboxName(mailboxname, sizeof mailboxname, &usbuf, MAILROOM);
create_room(mailboxname, 5, "", 0, 1);
/*** Everything below this line can be bypassed if we are administratively
long *msglist = NULL;
int num_msgs = 0;
- MailboxName(mailboxname, &CC->usersupp, MAILROOM);
+ MailboxName(mailboxname, sizeof mailboxname, &CC->usersupp, MAILROOM);
if (getroom(&mailbox, mailboxname) != 0)
return (0);
CtdlGetRelationship(&vbuf, &CC->usersupp, &mailbox);
void CtdlSetRelationship(struct visit *newvisit,
struct usersupp *rel_user,
struct quickroom *rel_room);
-void MailboxName(char *buf, struct usersupp *who, char *prefix);
+void MailboxName(char *buf, size_t n, const struct usersupp *who,
+ const char *prefix);
int GenerateRelationshipIndex( char *IndexBuf,
long RoomID,
long RoomGen,
{
static char buf[32];
- sprintf(buf,"errno = %d",e);
+ snprintf(buf, sizeof buf, "errno = %d",e);
return(buf);
}
#endif