Skip to content

Commit 4741110

Browse files
authored
Merge pull request #24 from josch/tarhardlinks
fix support for hardlinks in tarballs
2 parents ce4de57 + 761e2a7 commit 4741110

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

genext2fs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct fslayer {
167167
};
168168

169169
#define TAR_BLOCKSIZE 512
170-
#define TAR_FULLFILENAME (100 + 155)
170+
#define TAR_FULLFILENAME (100 + 155 + 1)
171171

172172
struct tar_header {
173173
char filename[100];
@@ -2321,7 +2321,9 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids,
23212321
path = longname;
23222322
has_longname = 0;
23232323
} else {
2324-
snprintf(pathbuf, sizeof pathbuf, "%s%s", tarhead->prefix, tarhead->filename);
2324+
strncpy(pathbuf, tarhead->prefix, sizeof tarhead->prefix);
2325+
strncpy(pathbuf+strnlen(pathbuf, sizeof pathbuf), tarhead->filename, sizeof tarhead->filename);
2326+
pathbuf[strnlen(pathbuf, sizeof pathbuf - 1)] = '\0';
23252327
path = pathbuf;
23262328
}
23272329
if (stats)
@@ -2397,7 +2399,7 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids,
23972399
fseek(fh, padding, SEEK_CUR);
23982400
break;
23992401
case '1':
2400-
if(!(hlnod = find_path(fs, this_nod, dir)))
2402+
if(!(hlnod = find_path(fs, this_nod, tarhead->linkedname)))
24012403
{
24022404
error_msg("tarball entry %s skipped: can't find hardlink destination '%s' to create '%s''", path, dir, name);
24032405
fseek(fh, filesize + padding, SEEK_CUR);

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ ftest 3db16dd57bd15c1c80dd6bc900411c58 4096 default device_table.txt
8686
ltest c21b5a3cad405197e821ba7143b0ea9b 200 1024 123456789 device_table_link.txt
8787
ltest 18b04b4bea2f7ebf315a116be5b92589 200 1024 1234567890 device_table_link.txt
8888
ltest 8aaed693b75dbdf77607f376d661027a 200 4096 12345678901 device_table_link.txt
89-
atest 402860495b7e2e1f714e017ef37466c6 200 1024 H4sIAAAAAAACA+3VQQ6CMBCF4a49RU8AnZaZOY8sSIgNTRASj29FVyzUTQno+zYlwAL4M7SqTXEuU+ZlzdbrckxBlJga5SafV/ViLJsNzNfpPFprxpSmd/d9un5QVT3MMZbvL03zfX/yTpyx4Uj9n+9BrzUcp3/Xd2k//UVC7u9Y1FjB/G/QP/bDpZpuU9n+qvpVf9a8T1Bg8sb6LqW6PY9Fn+7v+z8+8n72f2ZZ5p8I+/92/csO2ef/P6/6e/fo79C/uDbO7ckAAAAAAAAAAAAAAAAAwC+4A2+TDLQAKAAA
89+
atest 994ca42d3179c88263af777bedec0c55 200 1024 H4sIAAAAAAAAA+3WTW6DMBAF4Fn3FD6B8fj3PKAqahQSSwSk9vY1uKssGiJliFretzECJAYeY1s3JM4UKYRlLG7H5ZhdTIHZGevK+ZTYkgrypRFN17EdlKIh5/G3++5d/6N004qbA47er8/fWVduV2aLD7D7/A85C88Ba/ufA/sQIhk25VdA/2+h5t+1gx4/pd7vfv+Hm/ytmfNH/8vr+ql7e3UR8DK6uUx9L/uMtev/3P8p+KX/oyHlZMuqntX/9T34Z9yk9Gco8//xkGWf8Uj+Mbpl/Y+JVJQtq9r5/K+bj3Z474+Xk9wG4JH86/rvyzxAirfYnOw+/+vXWTb+uv9PaV3+JfiSv/WOlJVPf/f5AwAAAAAAAAAAAMD/9A0cPbO/ACgAAA==

0 commit comments

Comments
 (0)