summaryrefslogtreecommitdiffstats
path: root/discover/paths.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-11-14 14:54:34 +1100
committerJeremy Kerr <jk@ozlabs.org>2013-11-14 15:33:01 +1100
commit8c8fd93738a5d589b52a3791cd231e6661322b76 (patch)
tree7083b9bc96245bfa2f8061505e0059ec6eef7cad /discover/paths.c
parent059262751021d17ffa6d7f474cf25df0f297d23e (diff)
downloadtalos-petitboot-8c8fd93738a5d589b52a3791cd231e6661322b76.tar.gz
talos-petitboot-8c8fd93738a5d589b52a3791cd231e6661322b76.zip
discover: Use mkstemp rather than tempnam
We're getting warnings from some compilers about tempnam being unsafe. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/paths.c')
-rw-r--r--discover/paths.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/discover/paths.c b/discover/paths.c
index aa977fd..64b218e 100644
--- a/discover/paths.c
+++ b/discover/paths.c
@@ -46,15 +46,17 @@ char *join_paths(void *alloc_ctx, const char *a, const char *b)
static char *local_name(void *ctx)
{
- char *tmp, *ret;
+ char *ret, tmp[] = "/tmp/pb-XXXXXX";
+ int fd;
- tmp = tempnam(NULL, "pb-");
+ fd = mkstemp(tmp);
- if (!tmp)
+ if (fd < 0)
return NULL;
+ close(fd);
+
ret = talloc_strdup(ctx, tmp);
- free(tmp);
return ret;
}
OpenPOWER on IntegriCloud