diff options
author | Martijn van Duren <martijn@cvs.openbsd.org> | 2020-10-13 06:07:55 +0000 |
---|---|---|
committer | Martijn van Duren <martijn@cvs.openbsd.org> | 2020-10-13 06:07:55 +0000 |
commit | 63f741035b773cfe162e3d168a3ce3284b0ec1e8 (patch) | |
tree | d8f5a0737bfc4573a074cfec720c26a630adb80b | |
parent | b925557a7826c549cb0e948374f68b2098628219 (diff) |
Un-const what we pass to dirname(3).
Original diff by and OK naddy@
-rw-r--r-- | usr.bin/sed/main.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index 62644543a43..a3b4e02c949 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.40 2018/12/08 23:11:24 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.41 2020/10/13 06:07:54 martijn Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -343,6 +343,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) { struct stat sb; size_t len; + char dirbuf[PATH_MAX]; char *p; int c, fd; static int firstfile; @@ -397,8 +398,9 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) if (len > sizeof(oldfname)) error(FATAL, "%s: name too long", fname); } - len = snprintf(tmpfname, sizeof(tmpfname), "%s/sedXXXXXXXXXX", - dirname(fname)); + strlcpy(dirbuf, fname, sizeof(dirbuf)); + len = snprintf(tmpfname, sizeof(tmpfname), + "%s/sedXXXXXXXXXX", dirname(dirbuf)); if (len >= sizeof(tmpfname)) error(FATAL, "%s: name too long", fname); if ((fd = mkstemp(tmpfname)) == -1) |