diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/tar.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/archival/tar.c b/archival/tar.c index f3594f685..5b7c1425a 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -42,12 +42,8 @@ | |||
42 | #ifdef CONFIG_FEATURE_TAR_CREATE | 42 | #ifdef CONFIG_FEATURE_TAR_CREATE |
43 | 43 | ||
44 | /* Tar file constants */ | 44 | /* Tar file constants */ |
45 | # define TAR_MAGIC "ustar" /* ustar and a null */ | ||
46 | # define TAR_VERSION " " /* Be compatible with GNU tar format */ | ||
47 | 45 | ||
48 | #define TAR_BLOCK_SIZE 512 | 46 | #define TAR_BLOCK_SIZE 512 |
49 | #define TAR_MAGIC_LEN 6 | ||
50 | #define TAR_VERSION_LEN 2 | ||
51 | 47 | ||
52 | /* POSIX tar Header Block, from POSIX 1003.1-1990 */ | 48 | /* POSIX tar Header Block, from POSIX 1003.1-1990 */ |
53 | #define NAME_SIZE 100 | 49 | #define NAME_SIZE 100 |
@@ -208,15 +204,14 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo, | |||
208 | 204 | ||
209 | memset(&header, 0, size); | 205 | memset(&header, 0, size); |
210 | 206 | ||
211 | strncpy(header.name, header_name, sizeof(header.name)); | 207 | safe_strncpy(header.name, header_name, sizeof(header.name)); |
212 | 208 | ||
213 | putOctal(header.mode, sizeof(header.mode), statbuf->st_mode); | 209 | putOctal(header.mode, sizeof(header.mode), statbuf->st_mode); |
214 | putOctal(header.uid, sizeof(header.uid), statbuf->st_uid); | 210 | putOctal(header.uid, sizeof(header.uid), statbuf->st_uid); |
215 | putOctal(header.gid, sizeof(header.gid), statbuf->st_gid); | 211 | putOctal(header.gid, sizeof(header.gid), statbuf->st_gid); |
216 | putOctal(header.size, sizeof(header.size), 0); /* Regular file size is handled later */ | 212 | putOctal(header.size, sizeof(header.size), 0); /* Regular file size is handled later */ |
217 | putOctal(header.mtime, sizeof(header.mtime), statbuf->st_mtime); | 213 | putOctal(header.mtime, sizeof(header.mtime), statbuf->st_mtime); |
218 | strncpy(header.magic, TAR_MAGIC TAR_VERSION, | 214 | strcpy(header.magic, "ustar "); |
219 | TAR_MAGIC_LEN + TAR_VERSION_LEN); | ||
220 | 215 | ||
221 | /* Enter the user and group names (default to root if it fails) */ | 216 | /* Enter the user and group names (default to root if it fails) */ |
222 | if (bb_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL) | 217 | if (bb_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL) |