summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2015-10-02 09:51:55 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2015-10-02 09:51:55 +0000
commit55ff591369a0061cbb2b5588a30ff3c6af252874 (patch)
treec8291729c03ead802e5e37c8bd9ac22ecb2fa927
parent72848d18a1c539f961f9f8d2c65ace2b6ce42fef (diff)
use macros for cookie path and temp file template instead
of hardcoded strings. no object change.
-rw-r--r--lib/libsndio/aucat.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c
index 62d1044e44d..644938f25d0 100644
--- a/lib/libsndio/aucat.c
+++ b/lib/libsndio/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.66 2015/10/02 09:36:24 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.67 2015/10/02 09:51:54 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -205,6 +205,8 @@ _aucat_wdata(struct aucat *hdl, const void *buf, size_t len,
static int
aucat_mkcookie(unsigned char *cookie)
{
+#define COOKIE_SUFFIX "/.aucat_cookie"
+#define TEMPL_SUFFIX ".XXXXXXXX"
struct stat sb;
char *home, path[PATH_MAX], tmp[PATH_MAX];
ssize_t len;
@@ -216,7 +218,7 @@ aucat_mkcookie(unsigned char *cookie)
home = issetugid() ? NULL : getenv("HOME");
if (home == NULL)
goto bad_gen;
- snprintf(path, PATH_MAX, "%s/.aucat_cookie", home);
+ snprintf(path, PATH_MAX, "%s" COOKIE_SUFFIX, home);
fd = open(path, O_RDONLY);
if (fd < 0) {
if (errno != ENOENT)
@@ -256,7 +258,7 @@ bad_gen:
if (home == NULL)
return 1;
if (strlcpy(tmp, path, PATH_MAX) >= PATH_MAX ||
- strlcat(tmp, ".XXXXXXXX", PATH_MAX) >= PATH_MAX) {
+ strlcat(tmp, TEMPL_SUFFIX, PATH_MAX) >= PATH_MAX) {
DPRINTF("%s: too long\n", path);
return 1;
}