From: Art Cancro Date: Mon, 28 Nov 2005 02:28:33 +0000 (+0000) Subject: * Eliminated the use of tmpnam() to shut up compiler warnings. X-Git-Tag: v7.86~4423 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=9a1d57117b94d49407d113a08a3a76c2edceec24;p=citadel.git * Eliminated the use of tmpnam() to shut up compiler warnings. --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index f2d3cf07c..7d18df5a3 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,5 +1,8 @@ $Id$ +Sun Nov 27 21:28:03 EST 2005 ajc +* Eliminated the use of tmpnam() to shut up compiler warnings. + Sun Nov 27 18:42:15 CET 2005 dothebart * Detect locale from Browser Environment diff --git a/webcit/setup.c b/webcit/setup.c index b08e4b89a..cfdc7a9c4 100644 --- a/webcit/setup.c +++ b/webcit/setup.c @@ -231,7 +231,7 @@ void set_value(char *prompt, char str[]) int i; #endif char buf[SIZ]; - char *dialog_result; + char dialog_result[PATH_MAX]; char setupmsg[SIZ]; FILE *fp; @@ -250,7 +250,7 @@ void set_value(char *prompt, char str[]) 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"), "WebCit setup", diff --git a/webcit/tools.c b/webcit/tools.c index 2de3e881b..a4c7c2c20 100644 --- a/webcit/tools.c +++ b/webcit/tools.c @@ -465,3 +465,22 @@ void generate_uuid(char *buf) { (seq++) ); } + + +/* + * 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; + } + } +} diff --git a/webcit/webcit.h b/webcit/webcit.h index cbaa89b5f..996def547 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -544,6 +544,7 @@ void set_room_policy(void); void display_inetconf(void); void save_inetconf(void); void generate_uuid(char *); +void CtdlMakeTempFileName(char *, int); void display_preferences(void); void set_preferences(void); void recp_autocomplete(char *);