aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/tar.c9
-rw-r--r--tar.c9
2 files changed, 4 insertions, 14 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 9e1270cca..f31859e33 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -382,8 +382,6 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
382static int 382static int
383tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) 383tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
384{ 384{
385 int result;
386
387 if (extractFlag==FALSE || tostdoutFlag==TRUE) 385 if (extractFlag==FALSE || tostdoutFlag==TRUE)
388 return( TRUE); 386 return( TRUE);
389 387
@@ -394,15 +392,12 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
394 /* make the final component, just in case it was 392 /* make the final component, just in case it was
395 * omitted by create_path() (which will skip the 393 * omitted by create_path() (which will skip the
396 * directory if it doesn't have a terminating '/') */ 394 * directory if it doesn't have a terminating '/') */
397 result = mkdir(header->name, header->mode); 395 if (mkdir(header->name, header->mode) < 0 && errno != EEXIST) {
398 /* Don't fix permissions on pre-existing directories */
399 if (result == 0) {
400 fixUpPermissions(header);
401 } else if (result < 0 && errno != EEXIST) {
402 perror_msg("%s", header->name); 396 perror_msg("%s", header->name);
403 return FALSE; 397 return FALSE;
404 } 398 }
405 399
400 fixUpPermissions(header);
406 return( TRUE); 401 return( TRUE);
407} 402}
408 403
diff --git a/tar.c b/tar.c
index 9e1270cca..f31859e33 100644
--- a/tar.c
+++ b/tar.c
@@ -382,8 +382,6 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
382static int 382static int
383tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) 383tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
384{ 384{
385 int result;
386
387 if (extractFlag==FALSE || tostdoutFlag==TRUE) 385 if (extractFlag==FALSE || tostdoutFlag==TRUE)
388 return( TRUE); 386 return( TRUE);
389 387
@@ -394,15 +392,12 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
394 /* make the final component, just in case it was 392 /* make the final component, just in case it was
395 * omitted by create_path() (which will skip the 393 * omitted by create_path() (which will skip the
396 * directory if it doesn't have a terminating '/') */ 394 * directory if it doesn't have a terminating '/') */
397 result = mkdir(header->name, header->mode); 395 if (mkdir(header->name, header->mode) < 0 && errno != EEXIST) {
398 /* Don't fix permissions on pre-existing directories */
399 if (result == 0) {
400 fixUpPermissions(header);
401 } else if (result < 0 && errno != EEXIST) {
402 perror_msg("%s", header->name); 396 perror_msg("%s", header->name);
403 return FALSE; 397 return FALSE;
404 } 398 }
405 399
400 fixUpPermissions(header);
406 return( TRUE); 401 return( TRUE);
407} 402}
408 403