summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2020-10-15 19:47:47 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2020-10-15 19:47:47 +0000
commitb09a19ebcaca9db3055b2d4097fbfc0636121c91 (patch)
treedba995581f561dd7a8f5fed50c2550cde16bece2 /usr.bin
parenta97745c49c816d2aca93c0fe72cb6e3b624c8446 (diff)
Accommodate POSIX basename(3) that takes a non-const parameter and
may modify the string buffer. ok martijn@ millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/rcs/rlog.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c
index b01830a867f..a66292ce64d 100644
--- a/usr.bin/rcs/rlog.c
+++ b/usr.bin/rcs/rlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlog.c,v 1.74 2016/10/16 13:35:51 okan Exp $ */
+/* $OpenBSD: rlog.c,v 1.75 2020/10/15 19:47:46 naddy Exp $ */
/*
* Copyright (c) 2005, 2009 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -28,6 +28,7 @@
#include <ctype.h>
#include <err.h>
#include <libgen.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -348,7 +349,7 @@ rlog_select_daterev(RCSFILE *rcsfile, char *date)
static void
rlog_file(const char *fname, RCSFILE *file)
{
- char numb[RCS_REV_BUFSZ];
+ char fnamebuf[PATH_MAX], numb[RCS_REV_BUFSZ];
u_int nrev;
struct rcs_sym *sym;
struct rcs_access *acp;
@@ -364,7 +365,10 @@ rlog_file(const char *fname, RCSFILE *file)
} else
nrev = file->rf_ndelta;
- if ((workfile = basename(fname)) == NULL)
+ if (strlcpy(fnamebuf, fname, sizeof(fnamebuf)) >= sizeof(fnamebuf))
+ errx(1, "rlog_file: truncation");
+
+ if ((workfile = basename(fnamebuf)) == NULL)
err(1, "basename");
/*