diff options
-rw-r--r-- | archival/tar.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/archival/tar.c b/archival/tar.c index 11f5ebac0..bbda52d14 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -386,6 +386,20 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, | |||
386 | const char *header_name; | 386 | const char *header_name; |
387 | int inputFileFd = -1; | 387 | int inputFileFd = -1; |
388 | 388 | ||
389 | header_name = fileName; | ||
390 | while (header_name[0] == '/') { | ||
391 | static smallint warned; | ||
392 | |||
393 | if (!warned) { | ||
394 | bb_error_msg("removing leading '/' from member names"); | ||
395 | warned = 1; | ||
396 | } | ||
397 | header_name++; | ||
398 | } | ||
399 | |||
400 | if (header_name[0] == '\0') | ||
401 | return TRUE; | ||
402 | |||
389 | /* | 403 | /* |
390 | * Check to see if we are dealing with a hard link. | 404 | * Check to see if we are dealing with a hard link. |
391 | * If so - | 405 | * If so - |
@@ -397,7 +411,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, | |||
397 | if (statbuf->st_nlink > 1) { | 411 | if (statbuf->st_nlink > 1) { |
398 | tbInfo->hlInfo = findHardLinkInfo(tbInfo->hlInfoHead, statbuf); | 412 | tbInfo->hlInfo = findHardLinkInfo(tbInfo->hlInfoHead, statbuf); |
399 | if (tbInfo->hlInfo == NULL) | 413 | if (tbInfo->hlInfo == NULL) |
400 | addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, fileName); | 414 | addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, header_name); |
401 | } | 415 | } |
402 | 416 | ||
403 | /* It is against the rules to archive a socket */ | 417 | /* It is against the rules to archive a socket */ |
@@ -409,36 +423,23 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, | |||
409 | /* It is a bad idea to store the archive we are in the process of creating, | 423 | /* It is a bad idea to store the archive we are in the process of creating, |
410 | * so check the device and inode to be sure that this particular file isn't | 424 | * so check the device and inode to be sure that this particular file isn't |
411 | * the new tarball */ | 425 | * the new tarball */ |
412 | if (tbInfo->statBuf.st_dev == statbuf->st_dev && | 426 | if (tbInfo->statBuf.st_dev == statbuf->st_dev |
413 | tbInfo->statBuf.st_ino == statbuf->st_ino) { | 427 | && tbInfo->statBuf.st_ino == statbuf->st_ino |
428 | ) { | ||
414 | bb_error_msg("%s: file is the archive; skipping", fileName); | 429 | bb_error_msg("%s: file is the archive; skipping", fileName); |
415 | return TRUE; | 430 | return TRUE; |
416 | } | 431 | } |
417 | 432 | ||
418 | header_name = fileName; | 433 | if (exclude_file(tbInfo->excludeList, header_name)) |
419 | while (header_name[0] == '/') { | 434 | return SKIP; |
420 | static smallint warned; | ||
421 | |||
422 | if (!warned) { | ||
423 | bb_error_msg("removing leading '/' from member names"); | ||
424 | warned = 1; | ||
425 | } | ||
426 | header_name++; | ||
427 | } | ||
428 | 435 | ||
429 | #if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS | 436 | #if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS |
430 | if (strlen(fileName) >= NAME_SIZE) { | 437 | if (strlen(header_name) >= NAME_SIZE) { |
431 | bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported"); | 438 | bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported"); |
432 | return TRUE; | 439 | return TRUE; |
433 | } | 440 | } |
434 | #endif | 441 | #endif |
435 | 442 | ||
436 | if (header_name[0] == '\0') | ||
437 | return TRUE; | ||
438 | |||
439 | if (exclude_file(tbInfo->excludeList, header_name)) | ||
440 | return SKIP; | ||
441 | |||
442 | /* Is this a regular file? */ | 443 | /* Is this a regular file? */ |
443 | if (tbInfo->hlInfo == NULL && S_ISREG(statbuf->st_mode)) { | 444 | if (tbInfo->hlInfo == NULL && S_ISREG(statbuf->st_mode)) { |
444 | /* open the file we want to archive, and make sure all is well */ | 445 | /* open the file we want to archive, and make sure all is well */ |