~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/7z/Bra.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Bra.c -- Converters for RISC code
 
2
2008-10-04 : Igor Pavlov : Public domain */
 
3
 
 
4
#include "Bra.h"
 
5
 
 
6
SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
 
7
{
 
8
  SizeT i;
 
9
  if (size < 4)
 
10
    return 0;
 
11
  size -= 4;
 
12
  ip += 8;
 
13
  for (i = 0; i <= size; i += 4)
 
14
  {
 
15
    if (data[i + 3] == 0xEB)
 
16
    {
 
17
      UInt32 dest;
 
18
      UInt32 src = ((UInt32)data[i + 2] << 16) | ((UInt32)data[i + 1] << 8) | (data[i + 0]);
 
19
      src <<= 2;
 
20
      if (encoding)
 
21
        dest = ip + (UInt32)i + src;
 
22
      else
 
23
        dest = src - (ip + (UInt32)i);
 
24
      dest >>= 2;
 
25
      data[i + 2] = (Byte)(dest >> 16);
 
26
      data[i + 1] = (Byte)(dest >> 8);
 
27
      data[i + 0] = (Byte)dest;
 
28
    }
 
29
  }
 
30
  return i;
 
31
}
 
32
 
 
33
SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
 
34
{
 
35
  SizeT i;
 
36
  if (size < 4)
 
37
    return 0;
 
38
  size -= 4;
 
39
  ip += 4;
 
40
  for (i = 0; i <= size; i += 2)
 
41
  {
 
42
    if ((data[i + 1] & 0xF8) == 0xF0 &&
 
43
        (data[i + 3] & 0xF8) == 0xF8)
 
44
    {
 
45
      UInt32 dest;
 
46
      UInt32 src =
 
47
        (((UInt32)data[i + 1] & 0x7) << 19) |
 
48
        ((UInt32)data[i + 0] << 11) |
 
49
        (((UInt32)data[i + 3] & 0x7) << 8) |
 
50
        (data[i + 2]);
 
51
      
 
52
      src <<= 1;
 
53
      if (encoding)
 
54
        dest = ip + (UInt32)i + src;
 
55
      else
 
56
        dest = src - (ip + (UInt32)i);
 
57
      dest >>= 1;
 
58
      
 
59
      data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7));
 
60
      data[i + 0] = (Byte)(dest >> 11);
 
61
      data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7));
 
62
      data[i + 2] = (Byte)dest;
 
63
      i += 2;
 
64
    }
 
65
  }
 
66
  return i;
 
67
}
 
68
 
 
69
SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
 
70
{
 
71
  SizeT i;
 
72
  if (size < 4)
 
73
    return 0;
 
74
  size -= 4;
 
75
  for (i = 0; i <= size; i += 4)
 
76
  {
 
77
    if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1)
 
78
    {
 
79
      UInt32 src = ((UInt32)(data[i + 0] & 3) << 24) |
 
80
        ((UInt32)data[i + 1] << 16) |
 
81
        ((UInt32)data[i + 2] << 8) |
 
82
        ((UInt32)data[i + 3] & (~3));
 
83
      
 
84
      UInt32 dest;
 
85
      if (encoding)
 
86
        dest = ip + (UInt32)i + src;
 
87
      else
 
88
        dest = src - (ip + (UInt32)i);
 
89
      data[i + 0] = (Byte)(0x48 | ((dest >> 24) &  0x3));
 
90
      data[i + 1] = (Byte)(dest >> 16);
 
91
      data[i + 2] = (Byte)(dest >> 8);
 
92
      data[i + 3] &= 0x3;
 
93
      data[i + 3] |= dest;
 
94
    }
 
95
  }
 
96
  return i;
 
97
}
 
98
 
 
99
SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
 
100
{
 
101
  UInt32 i;
 
102
  if (size < 4)
 
103
    return 0;
 
104
  size -= 4;
 
105
  for (i = 0; i <= size; i += 4)
 
106
  {
 
107
    if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) ||
 
108
        (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0))
 
109
    {
 
110
      UInt32 src =
 
111
        ((UInt32)data[i + 0] << 24) |
 
112
        ((UInt32)data[i + 1] << 16) |
 
113
        ((UInt32)data[i + 2] << 8) |
 
114
        ((UInt32)data[i + 3]);
 
115
      UInt32 dest;
 
116
      
 
117
      src <<= 2;
 
118
      if (encoding)
 
119
        dest = ip + i + src;
 
120
      else
 
121
        dest = src - (ip + i);
 
122
      dest >>= 2;
 
123
      
 
124
      dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000;
 
125
 
 
126
      data[i + 0] = (Byte)(dest >> 24);
 
127
      data[i + 1] = (Byte)(dest >> 16);
 
128
      data[i + 2] = (Byte)(dest >> 8);
 
129
      data[i + 3] = (Byte)dest;
 
130
    }
 
131
  }
 
132
  return i;
 
133
}