MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / ExtractUnixLink30

Function ExtractUnixLink30

Libraries/unrar/ulinks.cpp:48–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47
48bool ExtractUnixLink30(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName)
49{
50 char Target[NM];
51 if (IsLink(Arc.FileHead.FileAttr))
52 {
53 size_t DataSize=(size_t)Arc.FileHead.PackSize;
54 if (DataSize>ASIZE(Target)-1)
55 return false;
56 if ((size_t)DataIO.UnpRead((byte *)Target,DataSize)!=DataSize)
57 return false;
58 Target[DataSize]=0;
59
60 DataIO.UnpHash.Init(Arc.FileHead.FileHash.Type,1);
61 DataIO.UnpHash.Update(Target,strlen(Target));
62 DataIO.UnpHash.Result(&Arc.FileHead.FileHash);
63
64 // Return true in case of bad checksum, so link will be processed further
65 // and extraction routine will report the checksum error.
66 if (!DataIO.UnpHash.Cmp(&Arc.FileHead.FileHash,Arc.FileHead.UseHashKey ? Arc.FileHead.HashKey:NULL))
67 return true;
68
69 wchar TargetW[NM];
70 CharToWide(Target,TargetW,ASIZE(TargetW));
71 // Check for *TargetW==0 to catch CharToWide failure.
72 // Use Arc.FileHead.FileName instead of LinkName, since LinkName
73 // can include the destination path as a prefix, which can
74 // confuse IsRelativeSymlinkSafe algorithm.
75 if (!Cmd->AbsoluteLinks && (*TargetW==0 || IsFullPath(TargetW) ||
76 !IsRelativeSymlinkSafe(Cmd,Arc.FileHead.FileName,LinkName,TargetW)))
77 return false;
78 return UnixSymlink(Target,LinkName,&Arc.FileHead.mtime,&Arc.FileHead.atime);
79 }
80 return false;
81}
82
83
84bool ExtractUnixLink50(CommandData *Cmd,const wchar *Name,FileHeader *hd)

Callers 1

ExtractSymlinkFunction · 0.85

Calls 10

IsLinkFunction · 0.85
CharToWideFunction · 0.85
IsRelativeSymlinkSafeFunction · 0.85
UnixSymlinkFunction · 0.85
UnpReadMethod · 0.80
ResultMethod · 0.80
CmpMethod · 0.80
IsFullPathFunction · 0.70
InitMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected