~ubuntu-branches/ubuntu/vivid/unrar-nonfree/vivid

« back to all changes in this revision

Viewing changes to extinfo.cpp

  • Committer: Package Import Robot
  • Author(s): Martin Meredith
  • Date: 2015-02-03 12:58:01 UTC
  • mfrom: (1.1.18) (5.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20150203125801-od6ev8cqy1er51vz
Tags: 1:5.2.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
 
61
61
 
62
62
 
 
63
bool IsRelativeSymlinkSafe(const wchar *SrcName,const wchar *TargetName)
 
64
{
 
65
  if (IsFullRootPath(SrcName))
 
66
    return false;
 
67
  int AllowedDepth=0;
 
68
  while (*SrcName!=0)
 
69
  {
 
70
    if (IsPathDiv(SrcName[0]) && SrcName[1]!=0 && !IsPathDiv(SrcName[1]))
 
71
    {
 
72
      bool Dot=SrcName[1]=='.' && (IsPathDiv(SrcName[2]) || SrcName[2]==0);
 
73
      bool Dot2=SrcName[1]=='.' && SrcName[2]=='.' && (IsPathDiv(SrcName[3]) || SrcName[3]==0);
 
74
      if (!Dot && !Dot2)
 
75
        AllowedDepth++;
 
76
    }
 
77
    SrcName++;
 
78
  }
 
79
  if (IsFullRootPath(TargetName)) // Catch root dir based /path/file paths.
 
80
    return false;
 
81
  for (int Pos=0;*TargetName!=0;Pos++)
 
82
  {
 
83
    bool Dot2=TargetName[0]=='.' && TargetName[1]=='.' && 
 
84
              (IsPathDiv(TargetName[2]) || TargetName[2]==0) &&
 
85
              (Pos==0 || IsPathDiv(*(TargetName-1)));
 
86
    if (Dot2)
 
87
      AllowedDepth--;
 
88
    TargetName++;
 
89
  }
 
90
  return AllowedDepth>=0;
 
91
}
 
92
 
 
93
 
63
94
bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName)
64
95
{
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.