63
bool IsRelativeSymlinkSafe(const wchar *SrcName,const wchar *TargetName)
65
if (IsFullRootPath(SrcName))
70
if (IsPathDiv(SrcName[0]) && SrcName[1]!=0 && !IsPathDiv(SrcName[1]))
72
bool Dot=SrcName[1]=='.' && (IsPathDiv(SrcName[2]) || SrcName[2]==0);
73
bool Dot2=SrcName[1]=='.' && SrcName[2]=='.' && (IsPathDiv(SrcName[3]) || SrcName[3]==0);
79
if (IsFullRootPath(TargetName)) // Catch root dir based /path/file paths.
81
for (int Pos=0;*TargetName!=0;Pos++)
83
bool Dot2=TargetName[0]=='.' && TargetName[1]=='.' &&
84
(IsPathDiv(TargetName[2]) || TargetName[2]==0) &&
85
(Pos==0 || IsPathDiv(*(TargetName-1)));
90
return AllowedDepth>=0;
63
94
bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName)
65
96
#if defined(SAVE_LINKS) && defined(_UNIX)
66
97
// For RAR 3.x archives we process links even in test mode to skip link data.
67
98
if (Arc.Format==RARFMT15)
68
return ExtractUnixLink30(DataIO,Arc,LinkName);
99
return ExtractUnixLink30(Cmd,DataIO,Arc,LinkName);
69
100
if (Arc.Format==RARFMT50)
70
return ExtractUnixLink50(LinkName,&Arc.FileHead);
101
return ExtractUnixLink50(Cmd,LinkName,&Arc.FileHead);
71
102
#elif defined _WIN_ALL
72
103
// RAR 5.0 archives store link information in file header, so there is
73
104
// no need to additionally test it if we do not create a file.