@@ -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
172172struct 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 );
0 commit comments