Fix the case where the file is not in the current directory.

Discovered by:	Vladimir Kravchenko <jimson@mostcom.ru>
Pointy hat to:	des
This commit is contained in:
Dag-Erling Smørgrav 2003-11-04 22:39:25 +00:00
parent 8b42c60645
commit 591c337e01
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=122084

View File

@ -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);