From 591c337e014fcc4ec5baf72cd1d5f41075b93107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Tue, 4 Nov 2003 22:39:25 +0000 Subject: [PATCH] Fix the case where the file is not in the current directory. Discovered by: Vladimir Kravchenko Pointy hat to: des --- usr.bin/sed/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index 216cd421bdab..77c89ae9e8cd 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -363,7 +363,8 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) errx(1, "%s: name too long", fname); } len = snprintf(tmpfname, sizeof(tmpfname), - ".!%ld!%s", (long)getpid(), fname); + "%s/.!%ld!%s", dirname(fname), (long)getpid(), + basename(fname)); if (len >= sizeof(tmpfname)) errx(1, "%s: name too long", fname); unlink(tmpfname);