~ubuntu-branches/ubuntu/dapper/clamav/dapper-updates

« back to all changes in this revision

Viewing changes to unit_tests/check_str.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Tautschnig, Michael Tautschnig
  • Date: 2009-03-25 16:02:18 UTC
  • mfrom: (0.12.1 upstream)
  • mto: (12.1.9 dapper-security)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20090325160218-forpco6d0ghp48br
Tags: 0.95+dfsg-1
[ Michael Tautschnig ]
* New upstream version, fixes:
  - License incompatibility with libgmp (closes: #512776)
  - wrong claim about all interception message methods (closes: #438455)
  - clamdscan fails to connect to clamd (closes: #515798)
  - clamav-milter dies after email scanning (sparc64) (closes: #339590)
  - VERSION reports wrong database version (closes: #323803)
  - memory footprint skyrockets (closes: #420391)
  - Virus not detected in RAR-archive inside email (closes: #484642)
  - clamav-milter ignores whitelist file (closes: #520353)
  - clamav-milter won't start when both local and tcp socket are in use 
    (closes: #505852)
  - ERROR: Can't find any clamd server (closes: #435007)
  - clamd: random SIGABRT (closes: #512720)
* Removed configure options that aren't supported anymore (--with-sendmail,
  --with-tcpwrappers, --with-dns)
* Bumped Standards-Version to 3.8.1 (added mkdir calls to ensure
  /var/run/clamav exists)
* Configure with --with-system-tommath to use Debian's libtommath-dev
  instead of the bundled one.
* Updated *Depends (dropped essential packages and removed versions where
  etch already satisfies the dependencies).
* SONAME bump: libclamav5 -> libclamav6
* Build-Depend on libltdl3-dev to avoid using the bundled libltdl, but still
  get support for runtime loading (nonfree) unrar code if the user so
  decides.
* Fixed watch file to deal with new versioning schema (+dfsg).
* Run make check unless nocheck is in DEB_BUILD_OPTIONS
* Changed Section of clamav-dbg to debug.
* Override lintian error stating that libclamav6 statically links to zlib
  (lintian is right, libclamav6 does indeed duplicate parts of the zlib
  code, but there is not way around that).
* Handle new option SafeBrowsing in freshclam.conf.
* Create symlinks to AUTHORS, not AUTHORS.gz (closes: #520172).
* clamav-milter got its own config file and logging options, handled via
  debconf, added logrotation (closes: #518628)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "../libclamav/clamav.h"
33
33
#include "../libclamav/others.h"
34
34
#include "../libclamav/str.h"
 
35
#include "../libclamav/mbox.h"
 
36
#include "../libclamav/message.h"
35
37
#include "../libclamav/jsparse/textbuf.h"
36
38
#include "checks.h"
37
39
 
162
164
}
163
165
END_TEST
164
166
 
 
167
#ifdef CHECK_HAVE_LOOPS
 
168
static struct base64lines {
 
169
    const char *line;
 
170
    const unsigned char *decoded;
 
171
    unsigned int   len;
 
172
} base64tests[] = {
 
173
    {"", "", 0},
 
174
    {"Zg==", "f", 1},
 
175
    {"Zm8=", "fo", 2},
 
176
    {"Zm9v", "foo", 3},
 
177
    {"Zm9vYg==", "foob", 4},
 
178
    {"Zm9vYmFy", "foobar", 6},
 
179
    /* with missing padding */
 
180
    {"Zg","f", 1},
 
181
    {"Zm8", "fo", 2},
 
182
    {"Zm9vYg", "foob", 4}
 
183
};
 
184
 
 
185
START_TEST (test_base64)
 
186
{
 
187
    unsigned char *ret, *ret2;
 
188
    unsigned len;
 
189
    unsigned char buf[1024];
 
190
    const struct base64lines *test = &base64tests[_i];
 
191
    message *m = messageCreate();
 
192
    fail_unless(!!m, "Unable to create message");
 
193
 
 
194
    ret = decodeLine(m, BASE64, test->line, buf, sizeof(buf));
 
195
    fail_unless(!!ret, "unable to decode line");
 
196
 
 
197
    ret2 = base64Flush(m, ret);
 
198
 
 
199
    if (!ret2)
 
200
        ret2 = ret;
 
201
    *ret2 = '\0';
 
202
    len = ret2 - buf;
 
203
    fail_unless_fmt(len == test->len, "invalid base64 decoded length: %u expected %u (%s)\n",
 
204
                    len, test->len, buf);
 
205
    fail_unless_fmt(!memcmp(buf, test->decoded, test->len),
 
206
                    "invalid base64 decoded data: %s, expected:%s\n",
 
207
                    buf, test->decoded);
 
208
    messageDestroy(m);
 
209
}
 
210
END_TEST
 
211
#endif
 
212
 
165
213
Suite *test_str_suite(void)
166
214
{
167
215
    Suite *s = suite_create("str");
168
 
    TCase *tc_cli_unescape, *tc_tbuf, *tc_str;
 
216
    TCase *tc_cli_unescape, *tc_tbuf, *tc_str, *tc_decodeline;
169
217
 
170
218
    tc_cli_unescape = tcase_create("cli_unescape");
171
219
    suite_add_tcase (s, tc_cli_unescape);
185
233
    suite_add_tcase (s, tc_str);
186
234
    tcase_add_test(tc_str, hex2str);
187
235
 
 
236
    tc_decodeline = tcase_create("decodeline");
 
237
    suite_add_tcase (s, tc_decodeline);
 
238
#ifdef CHECK_HAVE_LOOPS
 
239
    tcase_add_loop_test(tc_decodeline, test_base64, 0, sizeof(base64tests)/sizeof(base64tests[0]));
 
240
#endif
188
241
    return s;
189
242
}
190
243