~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/Support/regerror.c

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Sebastian Andrzej Siewior, Andreas Cadhalpun, Scott Kitterman, Javier Fernández-Sanguino
  • Date: 2015-01-28 00:25:13 UTC
  • mfrom: (0.48.14 sid)
  • Revision ID: package-import@ubuntu.com-20150128002513-lil2oi74cooy4lzr
Tags: 0.98.6+dfsg-1
[ Sebastian Andrzej Siewior ]
* update "fix-ssize_t-size_t-off_t-printf-modifier", include of misc.h was
  missing but was pulled in via the systemd patch.
* Don't leak return codes from libmspack to clamav API. (Closes: #774686).

[ Andreas Cadhalpun ]
* Add patch to avoid emitting incremental progress messages when not
  outputting to a terminal. (Closes: #767350)
* Update lintian-overrides for unused-file-paragraph-in-dep5-copyright.
* clamav-base.postinst: always chown /var/log/clamav and /var/lib/clamav
  to clamav:clamav, not only on fresh installations. (Closes: #775400)
* Adapt the clamav-daemon and clamav-freshclam logrotate scripts,
  so that they correctly work under systemd.
* Move the PidFile variable from the clamd/freshclam configuration files
  to the init scripts. This makes the init scripts more robust against
  misconfiguration and avoids error messages with systemd. (Closes: #767353)
* debian/copyright: drop files from Files-Excluded only present in github
  tarballs
* Drop Workaround-a-bug-in-libc-on-Hurd.patch, because hurd got fixed.
  (see #752237)
* debian/rules: Remove useless --with-system-tommath --without-included-ltdl
  configure options.

[ Scott Kitterman ]
* Stop stripping llvm when repacking the tarball as the system llvm on some
  releases is too old to use
* New upstream bugfix release
  - Library shared object revisions.
  - Includes a patch from Sebastian Andrzej Siewior making ClamAV pid files
    compatible with systemd.
  - Fix a heap out of bounds condition with crafted Yoda's crypter files.
    This issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted mew packer files. This
    issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted upx packer files. This
    issue was discovered by Kevin Szkudlapski of Quarkslab.
  - Fix a heap out of bounds condition with crafted upack packer files. This
    issue was discovered by Sebastian Andrzej Siewior. CVE-2014-9328.
  - Compensate a crash due to incorrect compiler optimization when handling
    crafted petite packer files. This issue was discovered by Sebastian
    Andrzej Siewior.
* Update lintian override for embedded zlib to match new so version

[ Javier Fernández-Sanguino ]
* Updated Spanish Debconf template translation (Closes: #773563)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-
 
2
 * This code is derived from OpenBSD's libc/regex, original license follows:
 
3
 *
 
4
 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
 
5
 * Copyright (c) 1992, 1993, 1994
 
6
 *      The Regents of the University of California.  All rights reserved.
 
7
 *
 
8
 * This code is derived from software contributed to Berkeley by
 
9
 * Henry Spencer.
 
10
 *
 
11
 * Redistribution and use in source and binary forms, with or without
 
12
 * modification, are permitted provided that the following conditions
 
13
 * are met:
 
14
 * 1. Redistributions of source code must retain the above copyright
 
15
 *    notice, this list of conditions and the following disclaimer.
 
16
 * 2. Redistributions in binary form must reproduce the above copyright
 
17
 *    notice, this list of conditions and the following disclaimer in the
 
18
 *    documentation and/or other materials provided with the distribution.
 
19
 * 3. Neither the name of the University nor the names of its contributors
 
20
 *    may be used to endorse or promote products derived from this software
 
21
 *    without specific prior written permission.
 
22
 *
 
23
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 
24
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
25
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
26
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
27
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
28
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
29
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
30
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
31
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
32
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
33
 * SUCH DAMAGE.
 
34
 *
 
35
 *      @(#)regerror.c  8.4 (Berkeley) 3/20/94
 
36
 */
 
37
 
 
38
#include <sys/types.h>
 
39
#include <stdio.h>
 
40
#include <string.h>
 
41
#include <ctype.h>
 
42
#include <limits.h>
 
43
#include <stdlib.h>
 
44
#include "regex_impl.h"
 
45
 
 
46
#include "regutils.h"
 
47
 
 
48
#ifdef _MSC_VER
 
49
#define snprintf _snprintf
 
50
#endif
 
51
 
 
52
static const char *regatoi(const llvm_regex_t *, char *, int);
 
53
 
 
54
static struct rerr {
 
55
        int code;
 
56
        const char *name;
 
57
        const char *explain;
 
58
} rerrs[] = {
 
59
        { REG_NOMATCH,  "REG_NOMATCH",  "llvm_regexec() failed to match" },
 
60
        { REG_BADPAT,   "REG_BADPAT",   "invalid regular expression" },
 
61
        { REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element" },
 
62
        { REG_ECTYPE,   "REG_ECTYPE",   "invalid character class" },
 
63
        { REG_EESCAPE,  "REG_EESCAPE",  "trailing backslash (\\)" },
 
64
        { REG_ESUBREG,  "REG_ESUBREG",  "invalid backreference number" },
 
65
        { REG_EBRACK,   "REG_EBRACK",   "brackets ([ ]) not balanced" },
 
66
        { REG_EPAREN,   "REG_EPAREN",   "parentheses not balanced" },
 
67
        { REG_EBRACE,   "REG_EBRACE",   "braces not balanced" },
 
68
        { REG_BADBR,    "REG_BADBR",    "invalid repetition count(s)" },
 
69
        { REG_ERANGE,   "REG_ERANGE",   "invalid character range" },
 
70
        { REG_ESPACE,   "REG_ESPACE",   "out of memory" },
 
71
        { REG_BADRPT,   "REG_BADRPT",   "repetition-operator operand invalid" },
 
72
        { REG_EMPTY,    "REG_EMPTY",    "empty (sub)expression" },
 
73
        { REG_ASSERT,   "REG_ASSERT",   "\"can't happen\" -- you found a bug" },
 
74
        { REG_INVARG,   "REG_INVARG",   "invalid argument to regex routine" },
 
75
        { 0,            "",             "*** unknown regexp error code ***" }
 
76
};
 
77
 
 
78
/*
 
79
 - llvm_regerror - the interface to error numbers
 
80
 = extern size_t llvm_regerror(int, const llvm_regex_t *, char *, size_t);
 
81
 */
 
82
/* ARGSUSED */
 
83
size_t
 
84
llvm_regerror(int errcode, const llvm_regex_t *preg, char *errbuf, size_t errbuf_size)
 
85
{
 
86
        struct rerr *r;
 
87
        size_t len;
 
88
        int target = errcode &~ REG_ITOA;
 
89
        const char *s;
 
90
        char convbuf[50];
 
91
 
 
92
        if (errcode == REG_ATOI)
 
93
                s = regatoi(preg, convbuf, sizeof convbuf);
 
94
        else {
 
95
                for (r = rerrs; r->code != 0; r++)
 
96
                        if (r->code == target)
 
97
                                break;
 
98
        
 
99
                if (errcode&REG_ITOA) {
 
100
                        if (r->code != 0) {
 
101
                                assert(strlen(r->name) < sizeof(convbuf));
 
102
                                (void) llvm_strlcpy(convbuf, r->name, sizeof convbuf);
 
103
                        } else
 
104
                                (void)snprintf(convbuf, sizeof convbuf,
 
105
                                    "REG_0x%x", target);
 
106
                        s = convbuf;
 
107
                } else
 
108
                        s = r->explain;
 
109
        }
 
110
 
 
111
        len = strlen(s) + 1;
 
112
        if (errbuf_size > 0) {
 
113
                llvm_strlcpy(errbuf, s, errbuf_size);
 
114
        }
 
115
 
 
116
        return(len);
 
117
}
 
118
 
 
119
/*
 
120
 - regatoi - internal routine to implement REG_ATOI
 
121
 */
 
122
static const char *
 
123
regatoi(const llvm_regex_t *preg, char *localbuf, int localbufsize)
 
124
{
 
125
        struct rerr *r;
 
126
 
 
127
        for (r = rerrs; r->code != 0; r++)
 
128
                if (strcmp(r->name, preg->re_endp) == 0)
 
129
                        break;
 
130
        if (r->code == 0)
 
131
                return("0");
 
132
 
 
133
        (void)snprintf(localbuf, localbufsize, "%d", r->code);
 
134
        return(localbuf);
 
135
}