Accommodate POSIX basename(3) that takes a non-const parameter and
may in fact modify the string buffer.
ok?
Index: usr.bin/rcs/rlog.c
===================================================================
RCS file: /cvs/src/usr.bin/rcs/rlog.c,v
retrieving revision 1.74
diff -u -p -r1.74 rlog.c
--- usr.bin/rcs/rlog.c 16 Oct 2016 13:35:51 -0000 1.74
+++ usr.bin/rcs/rlog.c 14 Oct 2020 20:18:55 -0000
@@ -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, ch
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 *fi
} 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");
/*
--
Christian "naddy" Weisgerber [email protected]