Canonicalize dirname(3) behavior.

This commit is contained in:
Matt Kraai
2001-08-24 19:51:54 +00:00
parent 2a953aed38
commit ac20ce1924
5 changed files with 25 additions and 13 deletions

View File

@@ -342,9 +342,11 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
if (extractFlag==TRUE && tostdoutFlag==FALSE) {
/* Create the path to the file, just in case it isn't there...
* This should not screw up path permissions or anything. */
char *dir = dirname (header->name);
char *buf, *dir;
buf = xstrdup (header->name);
dir = dirname (buf);
make_directory (dir, -1, FILEUTILS_RECUR);
free (dir);
free (buf);
if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY,
header->mode & ~S_IFMT)) < 0) {
error_msg(io_error, header->name, strerror(errno));