aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/kdb/db2/libdb2/hash
diff options
context:
space:
mode:
authorRobbie Harwood <rharwood@redhat.com>2017-03-29 18:34:37 -0400
committerGreg Hudson <ghudson@mit.edu>2017-04-14 12:02:58 -0400
commitbb0100296dea0a3b2f4b80235c21a1ca19d006f6 (patch)
tree38a9a7c612204a502b779b82bed8c7ed46e0497b /src/plugins/kdb/db2/libdb2/hash
parent0822275972a3b5bf4c88ae13cd51a19b8f354aa1 (diff)
downloadkrb5-bb0100296dea0a3b2f4b80235c21a1ca19d006f6.zip
krb5-bb0100296dea0a3b2f4b80235c21a1ca19d006f6.tar.gz
krb5-bb0100296dea0a3b2f4b80235c21a1ca19d006f6.tar.bz2
Avoid using tmpnam(3) in db2's hash.c
As we do not rely on anonymous db2 databases, get rid of the code using tmpnam() for hash databases and reporting EINVAL if a filename is not specified. [ghudson@mit.edu: rewrote commit message; condensed conditionals]
Diffstat (limited to 'src/plugins/kdb/db2/libdb2/hash')
-rw-r--r--src/plugins/kdb/db2/libdb2/hash/hash.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/plugins/kdb/db2/libdb2/hash/hash.c b/src/plugins/kdb/db2/libdb2/hash/hash.c
index 76f5d47..862dbb1 100644
--- a/src/plugins/kdb/db2/libdb2/hash/hash.c
+++ b/src/plugins/kdb/db2/libdb2/hash/hash.c
@@ -103,26 +103,15 @@ __kdb2_hash_open(file, flags, mode, info, dflags)
DB *dbp;
DBT mpool_key;
HTAB *hashp;
- int32_t bpages, csize, new_table, save_errno, specified_file;
+ int32_t bpages, csize, new_table, save_errno;
- if ((flags & O_ACCMODE) == O_WRONLY) {
+ if (!file || (flags & O_ACCMODE) == O_WRONLY) {
errno = EINVAL;
return (NULL);
}
if (!(hashp = (HTAB *)calloc(1, sizeof(HTAB))))
return (NULL);
hashp->fp = -1;
-
- /* set this now, before file goes away... */
- specified_file = (file != NULL);
- if (!file) {
- file = tmpnam(NULL);
- /* store the file name so that we can unlink it later */
- hashp->fname = file;
-#ifdef DEBUG
- fprintf(stderr, "Using file name %s.\n", file);
-#endif
- }
/*
* Even if user wants write only, we need to be able to read
* the actual file, so we need to open it read/write. But, the
@@ -130,7 +119,7 @@ __kdb2_hash_open(file, flags, mode, info, dflags)
* we can check accesses.
*/
hashp->flags = flags;
- hashp->save_file = specified_file && (hashp->flags & O_RDWR);
+ hashp->save_file = hashp->flags & O_RDWR;
new_table = 0;
if (!file || (flags & O_TRUNC) ||
@@ -542,8 +531,6 @@ hdestroy(hashp)
/* we need to chmod the file to allow it to be deleted... */
chmod(hashp->fname, 0700);
unlink(hashp->fname);
- /* destroy the temporary name */
- tmpnam(NULL);
}
free(hashp);