diff options
author | jedgar <jedgar@FreeBSD.org> | 2001-02-08 02:27:06 +0800 |
---|---|---|
committer | jedgar <jedgar@FreeBSD.org> | 2001-02-08 02:27:06 +0800 |
commit | ea07a36f1d5dfc0043ed5a8040ff38de3be64c73 (patch) | |
tree | 468abd719152ce67606b1b9d06ce91da606ade93 /databases/dbf2mysql | |
parent | 1c7865d06d51c0449076d913ed9d635a05d9ba92 (diff) | |
download | freebsd-ports-gnome-ea07a36f1d5dfc0043ed5a8040ff38de3be64c73.tar.gz freebsd-ports-gnome-ea07a36f1d5dfc0043ed5a8040ff38de3be64c73.tar.zst freebsd-ports-gnome-ea07a36f1d5dfc0043ed5a8040ff38de3be64c73.zip |
Use mkstemp() instead of tempnam()
Diffstat (limited to 'databases/dbf2mysql')
-rw-r--r-- | databases/dbf2mysql/files/patch-ab | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/databases/dbf2mysql/files/patch-ab b/databases/dbf2mysql/files/patch-ab new file mode 100644 index 000000000000..c005452471e8 --- /dev/null +++ b/databases/dbf2mysql/files/patch-ab @@ -0,0 +1,46 @@ +--- dbf2mysql.c.orig Fri Jul 7 04:55:02 2000 ++++ dbf2mysql.c Wed Feb 7 13:19:42 2001 +@@ -17,8 +17,13 @@ + #include <string.h> + #include <ctype.h> + #include <mysql.h> ++#include <paths.h> + #include "dbf.h" + ++#if !defined(_PATH_TMP) ++#define _PATH_TMP "/tmp/" ++#endif ++ + int verbose=0, upper=0, lower=0, create=0, fieldlow=0, var_chars=1; + int express=0; + int null_fields=0, trim=0, quick=0; +@@ -319,7 +324,7 @@ + /* Patched by GLC to fix quick mode Numeric fields */ + void do_inserts(MYSQL *SQLsock, char *table, dbhead *dbh) + { +- int result, i, j, nc = 0, h; ++ int result, i, j, nc = 0, h, fd; + field *fields; + char *query, *vpos, *pos; + char str[257], *cvt = NULL, *s; +@@ -395,9 +400,17 @@ + strcat(query, "NULL,NULL,"); + else /* if specified -q create file for 'LOAD DATA' */ + { +- datafile = tempnam ("/tmp", "d2my"); +- tempfile = fopen (datafile, "wt"); +- if (tempfile == NULL || datafile == NULL) ++ if (asprintf(&datafile, "%s/d2myXXXXXXXX", ++ getenv("TMPDIR") ? getenv("TMPDIR") : _PATH_TMP) == -1) { ++ fprintf (stderr, "asprintf() failed"); ++ return; ++ } ++ if ((fd = mkstemp(datafile)) == -1) { ++ fprintf (stderr, "mkstemp() failed"); ++ return; ++ } ++ tempfile = fdopen (fd, "w"); ++ if (tempfile == NULL) + { + fprintf (stderr, "Cannot open file '%s' for writing\n", datafile); + return; |