diff --git a/genext2fs.c b/genext2fs.c index 6bf0228..81db664 100644 --- a/genext2fs.c +++ b/genext2fs.c @@ -167,7 +167,7 @@ struct fslayer { }; #define TAR_BLOCKSIZE 512 -#define TAR_FULLFILENAME (100 + 155) +#define TAR_FULLFILENAME (100 + 155 + 1) struct tar_header { char filename[100]; @@ -2321,7 +2321,9 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids, path = longname; has_longname = 0; } else { - snprintf(pathbuf, sizeof pathbuf, "%s%s", tarhead->prefix, tarhead->filename); + strncpy(pathbuf, tarhead->prefix, sizeof tarhead->prefix); + strncpy(pathbuf+strnlen(pathbuf, sizeof pathbuf), tarhead->filename, sizeof tarhead->filename); + pathbuf[strnlen(pathbuf, sizeof pathbuf - 1)] = '\0'; path = pathbuf; } if (stats) @@ -2397,7 +2399,7 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids, fseek(fh, padding, SEEK_CUR); break; case '1': - if(!(hlnod = find_path(fs, this_nod, dir))) + if(!(hlnod = find_path(fs, this_nod, tarhead->linkedname))) { error_msg("tarball entry %s skipped: can't find hardlink destination '%s' to create '%s''", path, dir, name); fseek(fh, filesize + padding, SEEK_CUR); diff --git a/test.sh b/test.sh index d85d454..8dcafc4 100755 --- a/test.sh +++ b/test.sh @@ -86,4 +86,4 @@ ftest 3db16dd57bd15c1c80dd6bc900411c58 4096 default device_table.txt ltest c21b5a3cad405197e821ba7143b0ea9b 200 1024 123456789 device_table_link.txt ltest 18b04b4bea2f7ebf315a116be5b92589 200 1024 1234567890 device_table_link.txt ltest 8aaed693b75dbdf77607f376d661027a 200 4096 12345678901 device_table_link.txt -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 +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==