~ubuntu-branches/ubuntu/raring/clamav/raring

« back to all changes in this revision

Viewing changes to docs/html/node43.html

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran
  • Date: 2008-09-05 17:25:34 UTC
  • mfrom: (0.35.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080905172534-yi3f8fkye1o7u1r3
* New upstream version (closes: #497662, #497773)
  - lots of new options for clamd.conf
  - fixes CVEs CVE-2008-3912, CVE-2008-3913, CVE-2008-3914, and
    CVE-2008-1389
* No longer supports --unzip option, so typo is gone (closes: #496276)
* Translations:
  - sv (thanks Martin Bagge <brother@bsnet.se>) (closes: #491760)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
8
8
<HTML>
9
9
<HEAD>
10
 
<TITLE>Data scan functions</TITLE>
11
 
<META NAME="description" CONTENT="Data scan functions">
 
10
<TITLE>Engine structure</TITLE>
 
11
<META NAME="description" CONTENT="Engine structure">
12
12
<META NAME="keywords" CONTENT="clamdoc">
13
13
<META NAME="resource-type" CONTENT="document">
14
14
<META NAME="distribution" CONTENT="global">
18
18
 
19
19
<LINK REL="STYLESHEET" HREF="clamdoc.css">
20
20
 
21
 
<LINK REL="next" HREF="node44.html">
22
21
<LINK REL="previous" HREF="node42.html">
23
 
<LINK REL="up" HREF="node42.html">
 
22
<LINK REL="up" HREF="node39.html">
24
23
<LINK REL="next" HREF="node44.html">
25
24
</HEAD>
26
25
 
27
26
<BODY >
28
27
 
29
28
<DIV CLASS="navigation"><!--Navigation Panel-->
30
 
<A NAME="tex2html753"
 
29
<A NAME="tex2html759"
31
30
  HREF="node44.html">
32
31
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
33
 
<A NAME="tex2html749"
34
 
  HREF="node42.html">
 
32
<A NAME="tex2html755"
 
33
  HREF="node39.html">
35
34
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
36
 
<A NAME="tex2html743"
 
35
<A NAME="tex2html751"
37
36
  HREF="node42.html">
38
37
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
39
 
<A NAME="tex2html751"
 
38
<A NAME="tex2html757"
40
39
  HREF="node1.html">
41
40
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
42
41
<BR>
43
 
<B> Next:</B> <A NAME="tex2html754"
44
 
  HREF="node44.html">Memory</A>
45
 
<B> Up:</B> <A NAME="tex2html750"
46
 
  HREF="node42.html">Database reloading</A>
47
 
<B> Previous:</B> <A NAME="tex2html744"
48
 
  HREF="node42.html">Database reloading</A>
49
 
 &nbsp; <B>  <A NAME="tex2html752"
 
42
<B> Next:</B> <A NAME="tex2html760"
 
43
  HREF="node44.html">Database reloading</A>
 
44
<B> Up:</B> <A NAME="tex2html756"
 
45
  HREF="node39.html">API</A>
 
46
<B> Previous:</B> <A NAME="tex2html752"
 
47
  HREF="node42.html">Error handling</A>
 
48
 &nbsp; <B>  <A NAME="tex2html758"
50
49
  HREF="node1.html">Contents</A></B> 
51
50
<BR>
52
51
<BR></DIV>
53
52
<!--End of Navigation Panel-->
54
53
 
55
 
<H3><A NAME="SECTION00074100000000000000">
56
 
Data scan functions</A>
 
54
<H3><A NAME="SECTION00073400000000000000">
 
55
Engine structure</A>
57
56
</H3>
58
 
    It's possible to scan a file or descriptor using:
59
 
    <PRE>
60
 
        int cl_scanfile(const char *filename, const char **virname,
61
 
        unsigned long int *scanned, const struct cl_engine *engine,
62
 
        const struct cl_limits *limits, unsigned int options);
63
 
 
64
 
        int cl_scandesc(int desc, const char **virname, unsigned
65
 
        long int *scanned, const struct cl_engine *engine, const
66
 
        struct cl_limits *limits, unsigned int options);
67
 
</PRE>
68
 
    Both functions will store a virus name under the pointer <code>virname</code>,
69
 
    the virus name is part of the engine structure and must not be released
70
 
    directly. If the third argument (<code>scanned</code>) is not NULL, the
71
 
    functions will increase its value with the size of scanned data (in
72
 
    <code>CL_COUNT_PRECISION</code> units). Both functions have support for archive
73
 
    limits in order to protect against Denial of Service attacks.
74
 
    <PRE>
75
 
struct cl_limits {
76
 
    unsigned long int maxscansize;  /* during the scanning of archives this
77
 
                                     * size will never be exceeded
78
 
                                     */
79
 
    unsigned long int maxfilesize;  /* compressed files will only be
80
 
                                     * decompressed and scanned up to this size
81
 
                                     */
82
 
    unsigned int maxreclevel;       /* maximum recursion level for archives */
83
 
    unsigned int maxfiles;          /* maximum number of files to be scanned
84
 
                                     * within a single archive
85
 
                                     */
86
 
    unsigned short archivememlim;   /* limit memory usage for some unpackers */
87
 
};
88
 
</PRE>
89
 
    The last argument (<code>options</code>) configures the scan engine and supports
90
 
    the following flags (that can be combined using bit operators):
91
 
    
92
 
<UL>
93
 
<LI><SPAN  CLASS="textbf">CL_SCAN_STDOPT</SPAN>
94
 
<BR>
95
 
This is an alias for a recommended set of scan options. You
96
 
              should use it to make your software ready for new features
97
 
              in the future versions of libclamav.
98
 
</LI>
99
 
<LI><SPAN  CLASS="textbf">CL_SCAN_RAW</SPAN>
100
 
<BR>
101
 
Use it alone if you want to disable support for special files.
102
 
</LI>
103
 
<LI><SPAN  CLASS="textbf">CL_SCAN_ARCHIVE</SPAN>
104
 
<BR>
105
 
This flag enables transparent scanning of various archive formats.
106
 
</LI>
107
 
<LI><SPAN  CLASS="textbf">CL_SCAN_BLOCKENCRYPTED</SPAN>
108
 
<BR>
109
 
With this flag the library will mark encrypted archives as viruses
110
 
              (Encrypted.Zip, Encrypted.RAR).
111
 
</LI>
112
 
<LI><SPAN  CLASS="textbf">CL_SCAN_MAIL</SPAN>
113
 
<BR>
114
 
Enable support for mail files.
115
 
</LI>
116
 
<LI><SPAN  CLASS="textbf">CL_SCAN_MAILURL</SPAN>
117
 
<BR>
118
 
The mail scanner will download and scan URLs listed in a mail
119
 
              body. This flag should not be used on loaded servers. Due to
120
 
              potential problems please do not enable it by default but make
121
 
              it optional.
122
 
</LI>
123
 
<LI><SPAN  CLASS="textbf">CL_SCAN_OLE2</SPAN>
124
 
<BR>
125
 
Enables support for OLE2 containers (used by MS Office and .msi
126
 
              files).
127
 
</LI>
128
 
<LI><SPAN  CLASS="textbf">CL_SCAN_PDF</SPAN>
129
 
<BR>
130
 
Enables scanning within PDF files.
131
 
</LI>
132
 
<LI><SPAN  CLASS="textbf">CL_SCAN_PE</SPAN>
133
 
<BR>
134
 
This flag enables deep scanning of Portable Executable files and
135
 
              allows libclamav to unpack executables compressed with run-time
136
 
              unpackers.
137
 
</LI>
138
 
<LI><SPAN  CLASS="textbf">CL_SCAN_ELF</SPAN>
139
 
<BR>
140
 
Enable support for ELF files.
141
 
</LI>
142
 
<LI><SPAN  CLASS="textbf">CL_SCAN_BLOCKBROKEN</SPAN>
143
 
<BR>
144
 
libclamav will try to detect broken executables and mark them as
145
 
              Broken.Executable.
146
 
</LI>
147
 
<LI><SPAN  CLASS="textbf">CL_SCAN_HTML</SPAN>
148
 
<BR>
149
 
This flag enables HTML normalisation (including ScrEnc
150
 
              decryption).
151
 
</LI>
152
 
<LI><SPAN  CLASS="textbf">CL_SCAN_ALGORITHMIC</SPAN>
153
 
<BR>
154
 
Enable algorithmic detection of viruses.
155
 
</LI>
156
 
<LI><SPAN  CLASS="textbf">CL_SCAN_PHISHING_BLOCKSSL</SPAN>
157
 
<BR>
158
 
Phishing module: always block SSL mismatches in URLs.
159
 
</LI>
160
 
<LI><SPAN  CLASS="textbf">CL_SCAN_PHISHING_BLOCKCLOAK</SPAN>
161
 
<BR>
162
 
Phishing module: always block cloaked URLs.
163
 
    
164
 
</LI>
165
 
</UL>
166
 
    All functions return 0 (<code>CL_CLEAN</code>) when the file seems clean,
167
 
    <code>CL_VIRUS</code> when a virus is detected and another value on failure.
168
 
    <PRE>
169
 
            ...
170
 
            struct cl_limits limits;
171
 
            const char *virname;
172
 
 
173
 
        memset(&amp;limits, 0, sizeof(struct cl_limits));
174
 
        limits.maxfiles = 10000;
175
 
        limits.maxscansize = 100 * 1048576; /* 100 MB */
176
 
        limits.maxfilesize = 10 * 1048576; /* 10 MB */
177
 
        limits.maxreclevel = 16;
178
 
 
179
 
        if((ret = cl_scanfile("/tmp/test.exe", &amp;virname, NULL, engine,
180
 
        &amp;limits, CL_STDOPT)) == CL_VIRUS) {
181
 
            printf("Virus detected: %s\n", virname);
182
 
        } else {
183
 
            printf("No virus detected.\n");
184
 
            if(ret != CL_CLEAN)
185
 
                printf("Error: %s\n", cl_strerror(ret));
 
57
    When all required databases are loaded you should prepare the detection
 
58
    engine by calling <code>cl_build</code>. In the case of failure you should
 
59
    free the memory occupied by the engine with <code>cl_free</code>:
 
60
    <PRE>
 
61
        int cl_build(struct cl_engine *engine);
 
62
        void cl_free(struct cl_engine *engine);
 
63
</PRE>
 
64
    In our example:
 
65
    <PRE>
 
66
        if((ret = cl_build(engine))) {
 
67
            printf("cl_build() error: %s\n", cl_strerror(ret));
 
68
            cl_free(engine);
 
69
            exit(1);
186
70
        }
187
71
</PRE>
188
72
 
189
73
<P>
190
 
 
191
 
<DIV CLASS="navigation"><HR>
192
 
<!--Navigation Panel-->
193
 
<A NAME="tex2html753"
194
 
  HREF="node44.html">
195
 
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
196
 
<A NAME="tex2html749"
197
 
  HREF="node42.html">
198
 
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
199
 
<A NAME="tex2html743"
200
 
  HREF="node42.html">
201
 
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
202
 
<A NAME="tex2html751"
203
 
  HREF="node1.html">
204
 
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
205
 
<BR>
206
 
<B> Next:</B> <A NAME="tex2html754"
207
 
  HREF="node44.html">Memory</A>
208
 
<B> Up:</B> <A NAME="tex2html750"
209
 
  HREF="node42.html">Database reloading</A>
210
 
<B> Previous:</B> <A NAME="tex2html744"
211
 
  HREF="node42.html">Database reloading</A>
212
 
 &nbsp; <B>  <A NAME="tex2html752"
213
 
  HREF="node1.html">Contents</A></B> </DIV>
214
 
<!--End of Navigation Panel-->
 
74
<BR><HR>
215
75
<ADDRESS>
216
76
Tomasz Kojm
217
 
2008-07-07
 
77
2008-09-01
218
78
</ADDRESS>
219
79
</BODY>
220
80
</HTML>