* Eliminated the use of tmpnam() to shut up compiler warnings.
authorArt Cancro <ajc@citadel.org>
Mon, 28 Nov 2005 02:28:33 +0000 (02:28 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 28 Nov 2005 02:28:33 +0000 (02:28 +0000)
webcit/ChangeLog
webcit/setup.c
webcit/tools.c
webcit/webcit.h

index f2d3cf07cdbffc8c83c704a64da6ee394e9c2e29..7d18df5a36475817a2658b1c12c64ed1746a3021 100644 (file)
@@ -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
 
index b08e4b89aef506dbed980e653d00f23e5120b3cd..cfdc7a9c4079785d04e8e51d5d01cb43d3c52f5d 100644 (file)
@@ -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",
index 2de3e881b61a37ebfa822d648f592dcda601d388..a4c7c2c20dfa98e8aff0034e4b4f28b13f3bf3ff 100644 (file)
@@ -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;
+               }
+       }
+}
index cbaa89b5fcefc166ec19e670893a3a804e2caefa..996def547be482eb99128457370a0962196bc39a 100644 (file)
@@ -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 *);