~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/message.c

  • 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:
480
480
                const char *key, *cptr;
481
481
                char *data, *field;
482
482
 
483
 
                if(isspace(*string) || (*string == ';')) {
 
483
                if(isspace(*string & 0xff) || (*string == ';')) {
484
484
                        string++;
485
485
                        continue;
486
486
                }
1707
1707
        return NULL;
1708
1708
}
1709
1709
 
 
1710
int messageSavePartial(message *m, const char *dir, const char *md5id, unsigned part)
 
1711
{
 
1712
        char fullname[1024];
 
1713
        fileblob *fb;
 
1714
        unsigned long time_val;
 
1715
 
 
1716
        cli_dbgmsg("messageSavePartial\n");
 
1717
        time_val  = time(NULL);
 
1718
        snprintf(fullname, 1024, "%s/clamav-partial-%lu_%s-%u", dir, time_val, md5id, part);
 
1719
 
 
1720
        fb = messageExport(m, fullname,
 
1721
                (void *(*)(void))fileblobCreate,
 
1722
                (void(*)(void *))fileblobDestroy,
 
1723
                (void(*)(void *, const char *, const char *))fileblobPartialSet,
 
1724
                (void(*)(void *, const unsigned char *, size_t))fileblobAddData,
 
1725
                (void *(*)(text *, void *, int))textToFileblob,
 
1726
                (void(*)(void *, cli_ctx *))fileblobSetCTX,
 
1727
                0);
 
1728
        if(!fb)
 
1729
                return CL_EFORMAT;
 
1730
        fileblobDestroy(fb);
 
1731
        return CL_SUCCESS;
 
1732
}
 
1733
 
1710
1734
/*
1711
1735
 * Decode and transfer the contents of the message into a fileblob
1712
1736
 * The caller must free the returned fileblob
1819
1843
                                for(t_line = messageGetBody(m); t_line; t_line = t_line->t_next) {
1820
1844
                                        if(first == NULL)
1821
1845
                                                first = last = cli_malloc(sizeof(text));
1822
 
                                        else {
 
1846
                                        else if (last) {
1823
1847
                                                last->t_next = cli_malloc(sizeof(text));
1824
1848
                                                last = last->t_next;
1825
1849
                                        }
1826
1850
 
1827
1851
                                        if(last == NULL) {
1828
1852
                                                if(first) {
1829
 
                                                        last->t_next = NULL;
1830
1853
                                                        textDestroy(first);
1831
1854
                                                }
1832
1855
                                                return NULL;
1840
1863
                        case UUENCODE:
1841
1864
                                cli_errmsg("messageToText: Unexpected attempt to handle uuencoded file - report to http://bugs.clamav.net\n");
1842
1865
                                if(first) {
1843
 
                                        last->t_next = NULL;
 
1866
                                        if(last)
 
1867
                                                last->t_next = NULL;
1844
1868
                                        textDestroy(first);
1845
1869
                                }
1846
1870
                                return NULL;
1850
1874
                                if(t_line == NULL) {
1851
1875
                                        /*cli_warnmsg("YENCODED attachment is missing begin statement\n");*/
1852
1876
                                        if(first) {
1853
 
                                                last->t_next = NULL;
 
1877
                                                if(last)
 
1878
                                                        last->t_next = NULL;
1854
1879
                                                textDestroy(first);
1855
1880
                                        }
1856
1881
                                        return NULL;
1886
1911
 
1887
1912
                        if(first == NULL)
1888
1913
                                first = last = cli_malloc(sizeof(text));
1889
 
                        else {
 
1914
                        else if (last) {
1890
1915
                                last->t_next = cli_malloc(sizeof(text));
1891
1916
                                last = last->t_next;
1892
1917
                        }
1924
1949
                        if(decode(m, NULL, data, base64, FALSE) && data[0]) {
1925
1950
                                if(first == NULL)
1926
1951
                                        first = last = cli_malloc(sizeof(text));
1927
 
                                else {
 
1952
                                else if (last) {
1928
1953
                                        last->t_next = cli_malloc(sizeof(text));
1929
1954
                                        last = last->t_next;
1930
1955
                                }