Commit a451f17c authored by Roland Haas's avatar Roland Haas
Browse files

mpitar: fix broken support for PAX type long link names

parent 5920b862
......@@ -226,10 +226,14 @@ void tarentry::make_ustar_header_block(ustar_hdr &hdr, const int xtype,
memset(&hdr, 0, BLOCKSIZE);
if(S_ISLNK(statbuf.st_mode))
{
// TODO: maybe look up how PAX handles long link names
assert(strlen(ln) <= sizeof(hdr.linkname));
strncpy(hdr.linkname, ln, sizeof(hdr.linkname));
hdr.linkname[statbuf.st_size] = '\0';
// this is functionally identical to what strncpy alreday does but avoids
// warnings from over-eager compilers about possible string truncation (given
// that I am using strncpy exactly as designed this is just sad).
if(strlen(ln) <= sizeof(hdr.linkname)) {
strncpy(hdr.linkname, ln, sizeof(hdr.linkname));
} else {
memcpy(hdr.linkname, ln, sizeof(hdr.linkname));
}
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment