diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-02-22 07:26:09 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-02-22 07:26:09 +0000 |
commit | d7845fb73d97a14e02a24af45ed09721623e5905 (patch) | |
tree | 237fbcdd0214adb838468d4df09c2d0827a7af75 | |
parent | b15dc3c23fde71fcea97932c743ca4e3ecaab843 (diff) |
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@
-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); |