$Id$
+Sun Nov 27 21:20:27 EST 2005 ajc
+* Eliminated the use of tmpnam() to shut up the compiler warnings.
+
Mon Nov 21 16:59:43 CET 2005 dothebart
* add some script to wrap the debian package build that does some magic about
the versioning in the package and the citadel system
* program. Don't mess with these once they've been set, because we
* will be unlinking them later on in the program and we don't
* want to delete something that we didn't create. */
- snprintf(temp, sizeof temp, tmpnam(NULL));
- snprintf(temp2, sizeof temp2, tmpnam(NULL));
- snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
+ CtdlMakeTempFileName(temp, sizeof temp);
+ CtdlMakeTempFileName(temp2, sizeof temp2);
+ CtdlMakeTempFileName(tempdir, sizeof tempdir);
/* Get screen dimensions. First we go to a default of 80x24. Then
* we try to get the user's actual screen dimensions off the server.
len = (size_t)extract_long(buf, 0);
progress(ipc, len, len);
scr_flush();
- snprintf(tmp, sizeof tmp, "%s.%s",
- tmpnam(NULL),
- ptr->filename);
+ CtdlMakeTempFileName(tmp, sizeof tmp);
+ strcat(tmp, ptr->filename);
save_buffer(file, len, tmp);
free(file);
do_image_view(tmp);
else
b = 0;
- strcpy(prtfile, tmpnam(NULL));
+ CtdlMakeTempFileName(prtfile, sizeof prtfile);
if (msg_arr) {
free(msg_arr);
char *encoded_message = NULL;
off_t raw_length = 0;
- if (is_mailbox != NULL)
+ if (is_mailbox != NULL) {
MailboxName(roomname, sizeof roomname, is_mailbox, req_room);
- else
+ }
+ else {
safestrncpy(roomname, req_room, sizeof(roomname));
- lprintf(CTDL_DEBUG, "CtdlWriteObject() to <%s> (flags=%d)\n", roomname, flags);
-
+ }
fp = fopen(tempfilename, "rb");
if (fp == NULL) {
char temp[PATH_MAX];
FILE *fp;
- strcpy(temp, tmpnam(NULL));
+ CtdlMakeTempFileName(temp, sizeof temp);
fp = fopen(temp, "w");
if (fp == NULL) return;
char tempfilename[PATH_MAX];
if (CtdlAccessCheck(ac_logged_in)) return;
- tmpnam(tempfilename);
+ CtdlMakeTempFileName(tempfilename, sizeof tempfilename);
getroom(&CC->room, CC->room.QRname);
getuser(&CC->user, CC->curr_user);
return;
}
- snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
- snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
+ CtdlMakeTempFileName(filename, sizeof filename);
+ CtdlMakeTempFileName(changefile, sizeof changefile);
tempfp = fopen(filename, "w");
if (tempfp == NULL) {
return;
}
- strcpy(temp, tmpnam(NULL));
+ CtdlMakeTempFileName(temp, sizeof temp);
ser = icalcomponent_as_ical_string(cal);
if (ser == NULL) return;
unbuffer_output();
if (CtdlAccessCheck(ac_room_aide)) return;
- safestrncpy(tempfilename, tmpnam(NULL), sizeof tempfilename);
+ CtdlMakeTempFileName(tempfilename, sizeof tempfilename);
assoc_file_name(filename, sizeof filename, &CC->room, "netconfigs");
fp = fopen(tempfilename, "w");
long plen;
FILE *fp;
- strcpy(tempfilename, tmpnam(NULL));
+ CtdlMakeTempFileName(tempfilename, sizeof tempfilename);
if (sock_puts(sock, "NDOP") < 0) return;
if (sock_gets(sock, buf) < 0) return;
lprintf(CTDL_DEBUG, "<%s\n", buf);
struct ser_ret smr;
FILE *fp;
char buf[SIZ];
- char tempfile[SIZ];
+ char tempfile[PATH_MAX];
msg = CtdlFetchMessage(msgnum, 1);
if (msg == NULL) return; /* fail silently */
CtdlFreeMessage(msg);
/* write it in base64 */
- strcpy(tempfile, tmpnam(NULL));
+ CtdlMakeTempFileName(tempfile, sizeof tempfile);
snprintf(buf, sizeof buf, "./base64 -e >%s", tempfile);
fp = popen(buf, "w");
fwrite(smr.ser, smr.len, 1, fp);
long msglen;
FILE *fp;
char buf[SIZ];
- char tempfile[SIZ];
+ char tempfile[PATH_MAX];
char *mbuf;
memset(&smi, 0, sizeof(struct MetaData));
lprintf(CTDL_INFO, "message #%ld\n", msgnum);
/* decode base64 message text */
- strcpy(tempfile, tmpnam(NULL));
+ CtdlMakeTempFileName(tempfile, sizeof tempfile);
snprintf(buf, sizeof buf, "./base64 -d >%s", tempfile);
fp = popen(buf, "w");
while (client_getln(buf, sizeof buf), strcasecmp(buf, END_OF_MESSAGE)) {
}
is_running = 1;
- strcpy(artv_tempfilename1, tmpnam(NULL));
- strcpy(artv_tempfilename2, tmpnam(NULL));
+ CtdlMakeTempFileName(artv_tempfilename1, sizeof artv_tempfilename1);
+ CtdlMakeTempFileName(artv_tempfilename2, sizeof artv_tempfilename2);
extract_token(cmd, cmdbuf, 0, '|', sizeof cmd);
if (!strcasecmp(cmd, "export")) artv_do_export();
FILE *fp;
char *ser;
- strcpy(temp, tmpnam(NULL));
+ CtdlMakeTempFileName(temp, sizeof temp);
ser = vcard_serialize(v);
fp = fopen(temp, "w");
#endif
char buf[SIZ];
char setupmsg[SIZ];
- char *dialog_result;
+ char dialog_result[PATH_MAX];
FILE *fp = NULL;
strcpy(setupmsg, "");
break;
case UI_DIALOG:
- dialog_result = tmpnam(NULL);
+ CtdlMakeTempFileName(dialog_result, sizeof dialog_result);
sprintf(buf, "exec %s --backtitle '%s' --inputbox '%s' 19 72 '%s' 2>%s",
getenv("CTDL_DIALOG"),
prompt_title,
+/*
+ * Local replacement for controversial C library function that generates
+ * names for temporary files. Included to shut up compiler warnings.
+ */
+void CtdlMakeTempFileName(char *name, int len) {
+ int i = 0;
+
+ while (i++, i < 100) {
+ snprintf(name, len, "/tmp/ctdl.%04x.%04x",
+ getpid(),
+ rand()
+ );
+ if (!access(name, F_OK)) {
+ return;
+ }
+ }
+}
char *ascmonths[12];
void generate_uuid(char *buf);
char *bmstrcasestr(char *text, char *pattern);
+void CtdlMakeTempFileName(char *name, int len);