diff options
author | 2015-10-02 09:51:54 +0000 | |
---|---|---|
committer | 2015-10-02 09:51:54 +0000 | |
commit | 59d9d0514b288ba47728fc5b162138769c8ce55b (patch) | |
tree | 029e2ef731555a3ea242bc71c8949c14067ebc3f | |
parent | Validate that midi and audio device numbers are integers. (diff) | |
download | wireguard-openbsd-59d9d0514b288ba47728fc5b162138769c8ce55b.tar.xz wireguard-openbsd-59d9d0514b288ba47728fc5b162138769c8ce55b.zip |
use macros for cookie path and temp file template instead
of hardcoded strings. no object change.
-rw-r--r-- | lib/libsndio/aucat.c | 8 |
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; } |