diff options
-rw-r--r-- | archival/tar.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/archival/tar.c b/archival/tar.c index bbda52d14..18b626701 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -386,6 +386,7 @@ 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 | /* Strip leading '/' (must be before memorizing hardlink's name) */ | ||
389 | header_name = fileName; | 390 | header_name = fileName; |
390 | while (header_name[0] == '/') { | 391 | while (header_name[0] == '/') { |
391 | static smallint warned; | 392 | static smallint warned; |
@@ -400,6 +401,12 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, | |||
400 | if (header_name[0] == '\0') | 401 | if (header_name[0] == '\0') |
401 | return TRUE; | 402 | return TRUE; |
402 | 403 | ||
404 | /* It is against the rules to archive a socket */ | ||
405 | if (S_ISSOCK(statbuf->st_mode)) { | ||
406 | bb_error_msg("%s: socket ignored", fileName); | ||
407 | return TRUE; | ||
408 | } | ||
409 | |||
403 | /* | 410 | /* |
404 | * Check to see if we are dealing with a hard link. | 411 | * Check to see if we are dealing with a hard link. |
405 | * If so - | 412 | * If so - |
@@ -414,12 +421,6 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, | |||
414 | addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, header_name); | 421 | addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, header_name); |
415 | } | 422 | } |
416 | 423 | ||
417 | /* It is against the rules to archive a socket */ | ||
418 | if (S_ISSOCK(statbuf->st_mode)) { | ||
419 | bb_error_msg("%s: socket ignored", fileName); | ||
420 | return TRUE; | ||
421 | } | ||
422 | |||
423 | /* It is a bad idea to store the archive we are in the process of creating, | 424 | /* It is a bad idea to store the archive we are in the process of creating, |
424 | * so check the device and inode to be sure that this particular file isn't | 425 | * so check the device and inode to be sure that this particular file isn't |
425 | * the new tarball */ | 426 | * the new tarball */ |