~ubuntu-branches/ubuntu/wily/unrar-nonfree/wily-proposed

« back to all changes in this revision

Viewing changes to archive.cpp

  • Committer: Package Import Robot
  • Author(s): Nick Andrik
  • Date: 2013-01-21 23:07:40 UTC
  • mfrom: (1.2.13)
  • Revision ID: package-import@ubuntu.com-20130121230740-yky1izwyj5x16wq1
Tags: 1:4.2.4-0.1
* Non-maintainer upload

* New upstream release (Closes: #687839)

* Add shared library binary and headers packages
  - Add entries into control file
  - Add libunrar0.{install,link,symbols} files
  - Add libunrar0-dev.install file
  - Patch missing binary object targets for library building
    (fix_missing_symbols)
  - Rename previous unrar-nonfree.{1,dirs,install,prerm,postint} file to
    unrar.* ones
  - Make sure libunrar.so is built (Closes: #485492, LP: #390263)
* Converted package to CDBS:
  - Simplified rules file
  - Added cdbs build-deps
* Added hardening support (Closes: #694611)
  - Updated compatibility version to 9
  - Added versioned dpkg-dev build-dep
* Updated copyright information:
  - Machine-readable format
  - Added missing files/licenses
* General maintentance:
  - Moved the homepage field in cortol file to the appropriate place
  - Bumped standards version to 3.9.4
  - Remove versioned conflict dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
}
53
53
 
54
54
 
 
55
 
55
56
#ifndef SHELL_EXT
56
57
void Archive::CheckArc(bool EnableBroken)
57
58
{
58
59
  if (!IsArchive(EnableBroken))
59
60
  {
60
61
    Log(FileName,St(MBadArc),FileName);
61
 
    ErrHandler.Exit(FATAL_ERROR);
 
62
    ErrHandler.Exit(RARX_FATAL);
62
63
  }
63
64
}
64
65
#endif
89
90
}
90
91
 
91
92
 
92
 
bool Archive::IsSignature(byte *D)
 
93
ARCSIGN_TYPE Archive::IsSignature(const byte *D,size_t Size)
93
94
{
94
 
  bool Valid=false;
95
 
  if (D[0]==0x52)
 
95
  ARCSIGN_TYPE Type=ARCSIGN_NONE;
 
96
  if (Size>=1 && D[0]==0x52)
96
97
#ifndef SFX_MODULE
97
 
    if (D[1]==0x45 && D[2]==0x7e && D[3]==0x5e)
98
 
    {
99
 
      OldFormat=true;
100
 
      Valid=true;
101
 
    }
 
98
    if (Size>=4 && D[1]==0x45 && D[2]==0x7e && D[3]==0x5e)
 
99
      Type=ARCSIGN_OLD;
102
100
    else
103
101
#endif
104
 
      if (D[1]==0x61 && D[2]==0x72 && D[3]==0x21 && D[4]==0x1a && D[5]==0x07 && D[6]==0x00)
 
102
      if (Size>=7 && D[1]==0x61 && D[2]==0x72 && D[3]==0x21 && D[4]==0x1a && D[5]==0x07)
105
103
      {
106
 
        OldFormat=false;
107
 
        Valid=true;
 
104
        // We check for non-zero last signature byte, so we can return
 
105
        // a sensible warning in case we'll want to change the archive
 
106
        // format sometimes in the future.
 
107
        Type=D[6]==0 ? ARCSIGN_CURRENT:ARCSIGN_FUTURE;
108
108
      }
109
 
  return(Valid);
 
109
  return Type;
110
110
}
111
111
 
112
112
 
125
125
  if (Read(MarkHead.Mark,SIZEOF_MARKHEAD)!=SIZEOF_MARKHEAD)
126
126
    return(false);
127
127
  SFXSize=0;
128
 
  if (IsSignature(MarkHead.Mark))
 
128
  
 
129
  ARCSIGN_TYPE Type;
 
130
  if ((Type=IsSignature(MarkHead.Mark,sizeof(MarkHead.Mark)))!=ARCSIGN_NONE)
129
131
  {
 
132
    OldFormat=(Type==ARCSIGN_OLD);
130
133
    if (OldFormat)
131
134
      Seek(0,SEEK_SET);
132
135
  }
136
139
    long CurPos=(long)Tell();
137
140
    int ReadSize=Read(&Buffer[0],Buffer.Size()-16);
138
141
    for (int I=0;I<ReadSize;I++)
139
 
      if (Buffer[I]==0x52 && IsSignature((byte *)&Buffer[I]))
 
142
      if (Buffer[I]==0x52 && (Type=IsSignature((byte *)&Buffer[I],ReadSize-I))!=ARCSIGN_NONE)
140
143
      {
 
144
        OldFormat=(Type==ARCSIGN_OLD);
141
145
        if (OldFormat && I>0 && CurPos<28 && ReadSize>31)
142
146
        {
143
147
          char *D=&Buffer[28-CurPos];
151
155
        break;
152
156
      }
153
157
    if (SFXSize==0)
154
 
      return(false);
 
158
      return false;
 
159
  }
 
160
  if (Type==ARCSIGN_FUTURE)
 
161
  {
 
162
#if !defined(SHELL_EXT) && !defined(SFX_MODULE)
 
163
    Log(FileName,St(MNewRarFormat));
 
164
#endif
 
165
    return false;
155
166
  }
156
167
  ReadHeader();
157
168
  SeekToNext();
187
198
#ifdef RARDLL
188
199
    Cmd->DllError=ERAR_UNKNOWN_FORMAT;
189
200
#else
190
 
    ErrHandler.SetErrorCode(WARNING);
 
201
    ErrHandler.SetErrorCode(RARX_WARNING);
191
202
  #if !defined(SILENT) && !defined(SFX_MODULE)
192
203
      Log(FileName,St(MUnknownMeth),FileName);
193
204
      Log(FileName,St(MVerRequired),NewMhd.EncryptVer/10,NewMhd.EncryptVer%10);