diff options
author | 2006-02-22 07:26:08 +0000 | |
---|---|---|
committer | 2006-02-22 07:26:08 +0000 | |
commit | 09bddadd45fa67b808e0d0b8cdf4ca8c1450afac (patch) | |
tree | 6580052fc20e42ed66b719ab59181aceac4dec8d /usr.bin/diff/diffreg.c | |
parent | Avouid a race in atexit() handling by introducing a lock. Problem (diff) | |
download | wireguard-openbsd-09bddadd45fa67b808e0d0b8cdf4ca8c1450afac.tar.xz wireguard-openbsd-09bddadd45fa67b808e0d0b8cdf4ca8c1450afac.zip |
Append two string using strlcpy()/strlcat() instead of snprintf() to
avoid having to check for encoding errors returned by snprintf().
From Ray Lai; ok millert@ jaredy@
Diffstat (limited to 'usr.bin/diff/diffreg.c')
-rw-r--r-- | usr.bin/diff/diffreg.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 86ab79e53df..eaf587e52fd 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.63 2006/02/16 08:15:05 otto Exp $ */ +/* $OpenBSD: diffreg.c,v 1.64 2006/02/22 07:26:08 otto Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -65,7 +65,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.63 2006/02/16 08:15:05 otto Exp $"; +static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.64 2006/02/22 07:26:08 otto Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -511,8 +511,10 @@ opentemp(const char *file) if ((tempdir = getenv("TMPDIR")) == NULL) tempdir = _PATH_TMP; - if (snprintf(tempfile, sizeof(tempfile), "%s/diff.XXXXXXXX", - tempdir) >= sizeof(tempfile)) { + + if (strlcpy(tempfile, tempdir, sizeof(tempfile)) >= sizeof(tempfile) || + strlcat(tempfile, "/diff.XXXXXXXX", sizeof(tempfile)) >= + sizeof(tempfile)) { close(ifd); errno = ENAMETOOLONG; return (NULL); |