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

« back to all changes in this revision

Viewing changes to .pc/0004-Fix-compiling-on-Hurd.patch/libclamav/hostid.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
 
 *  Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
3
 
 *
4
 
 *  Author: Shawn Webb
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License version 2 as
8
 
 *  published by the Free Software Foundation.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 
 *  MA 02110-1301, USA.
19
 
 */
20
 
 
21
 
#if HAVE_CONFIG_H
22
 
#include "clamav-config.h"
23
 
#endif
24
 
 
25
 
#include <stdio.h>
26
 
#include <stdlib.h>
27
 
#include <string.h>
28
 
 
29
 
#if HAVE_UNISTD_H
30
 
#include <unistd.h>
31
 
#endif
32
 
 
33
 
#include <sys/types.h>
34
 
#include <fcntl.h>
35
 
 
36
 
#if !defined(_WIN32)
37
 
#include <sys/socket.h>
38
 
#include <netdb.h>
39
 
#include <sys/ioctl.h>
40
 
#endif
41
 
 
42
 
#if defined(HAVE_GETIFADDRS)
43
 
#include <net/if.h>
44
 
#if defined(HAVE_NET_IF_DL_H)
45
 
#include <net/if_dl.h>
46
 
#endif
47
 
#include <ifaddrs.h>
48
 
#endif
49
 
 
50
 
#if defined(SIOCGIFHWADDR)
51
 
#if defined(_AIX)
52
 
#include <sys/ndd_var.h>
53
 
#include <sys/kinfo.h>
54
 
#else
55
 
#include <linux/sockios.h>
56
 
#endif
57
 
#endif
58
 
 
59
 
#include <errno.h>
60
 
 
61
 
#include "clamav.h"
62
 
#include "hostid.h"
63
 
#include "libclamav/others.h"
64
 
 
65
 
struct device *get_device_entry(struct device *devices, size_t *ndevices, const char *name);
66
 
 
67
 
struct device *get_device_entry(struct device *devices, size_t *ndevices, const char *name)
68
 
{
69
 
    void *p;
70
 
    size_t i;
71
 
 
72
 
    if ((devices)) {
73
 
        int found = 0;
74
 
 
75
 
        for (i = 0; i < *ndevices; i++) {
76
 
            if (!strcmp(devices[i].name, name)) {
77
 
                found = 1;
78
 
                break;
79
 
            }
80
 
        }
81
 
 
82
 
        if (!found) {
83
 
            p = realloc(devices, sizeof(struct device) * (*ndevices + 1));
84
 
            if (!(p)) {
85
 
                for (i=0; i < *ndevices; i++)
86
 
                    free(devices[i].name);
87
 
                free(devices);
88
 
                return NULL;
89
 
            }
90
 
            devices = p;
91
 
 
92
 
            memset(devices + *ndevices, 0x00, sizeof(struct device));
93
 
            *ndevices = *ndevices + 1;
94
 
        }
95
 
    } else {
96
 
        devices = calloc(1, sizeof(struct device));
97
 
        if (!(devices))
98
 
            return NULL;
99
 
 
100
 
        *ndevices = 1;
101
 
    }
102
 
 
103
 
    if (*ndevices && !(devices[*ndevices - 1].name) && name)
104
 
        devices[*ndevices - 1].name = strdup(name);
105
 
 
106
 
    return devices;
107
 
}
108
 
 
109
 
#if HAVE_GETIFADDRS
110
 
struct device *get_devices(void)
111
 
{
112
 
    struct ifaddrs *addrs=NULL, *addr;
113
 
    struct device *devices=NULL;
114
 
    size_t ndevices=0, i, j;
115
 
    void *p;
116
 
    uint8_t *mac;
117
 
    int sock;
118
 
 
119
 
#if defined(SIOCGIFHWADDR)
120
 
    struct ifreq ifr;
121
 
#else
122
 
    struct sockaddr_dl *sdl;
123
 
#endif
124
 
 
125
 
    if (getifaddrs(&addrs))
126
 
        return NULL;
127
 
 
128
 
    for (addr = addrs; addr != NULL; addr = addr->ifa_next) {
129
 
        if (!(addr->ifa_addr))
130
 
            continue;
131
 
 
132
 
        /*
133
 
         * Even though POSIX (BSD) sockets define AF_LINK, Linux decided to be clever
134
 
         * and use AF_PACKET instead.
135
 
         */
136
 
#if defined(AF_PACKET)
137
 
        if (addr->ifa_addr->sa_family != AF_PACKET)
138
 
            continue;
139
 
#elif defined(AF_LINK)
140
 
        if (addr->ifa_addr->sa_family != AF_LINK)
141
 
            continue;
142
 
#else
143
 
        break; /* We don't support anything else */
144
 
#endif
145
 
 
146
 
        devices = get_device_entry(devices, &ndevices, addr->ifa_name);
147
 
        if (!(devices)) {
148
 
            freeifaddrs(addrs);
149
 
            return NULL;
150
 
        }
151
 
 
152
 
        /*
153
 
         * Grab the MAC address for all devices that have them.
154
 
         * Linux doesn't support (struct sockaddr_dl) as POSIX (BSD) sockets require.
155
 
         * Instead, Linux uses its own ioctl. This code only runs if we're not Linux,
156
 
         * Windows, or FreeBSD.
157
 
         */
158
 
#if !defined(SIOCGIFHWADDR)
159
 
        for (i=0; i < ndevices; i++) {
160
 
            if (!(strcmp(devices[i].name, addr->ifa_name))) {
161
 
                sdl = (struct sockaddr_dl *)(addr->ifa_addr);
162
 
 
163
 
#if defined(LLADDR)
164
 
                mac = LLADDR(sdl);
165
 
#else
166
 
                mac = ((uint8_t *)(sdl->sdl_data + sdl->sdl_nlen));
167
 
#endif
168
 
                for (j=0; j<6; j++)
169
 
                    snprintf(devices[i].mac+strlen(devices[i].mac), sizeof(devices[i].mac)-strlen(devices[i].mac)-1, "%02x:", mac[j]);
170
 
 
171
 
                break;
172
 
            }
173
 
        }
174
 
#endif
175
 
    }
176
 
 
177
 
    if (addrs) {
178
 
        freeifaddrs(addrs);
179
 
        addrs = NULL;
180
 
    }
181
 
 
182
 
    /* This is the Linux version of getting the MAC addresses */
183
 
#if defined(SIOCGIFHWADDR)
184
 
    for (i=0; i < ndevices; i++) {
185
 
        if (!(devices[i].name))
186
 
            continue;
187
 
 
188
 
        memset(&ifr, 0x00, sizeof(struct ifreq));
189
 
        memset(devices[i].mac, 0x00, sizeof(devices[i].mac));
190
 
 
191
 
        strcpy(ifr.ifr_name, devices[i].name);
192
 
 
193
 
        sock = socket(AF_INET, SOCK_DGRAM, 0);
194
 
        if (sock < 0)
195
 
            goto err;
196
 
 
197
 
        if (ioctl(sock, SIOCGIFHWADDR, &ifr)) {
198
 
            close(sock);
199
 
            goto err;
200
 
        }
201
 
        close(sock);
202
 
 
203
 
        mac = ((uint8_t *)(ifr.ifr_ifru.ifru_hwaddr.sa_data));
204
 
        if (!(mac))
205
 
            continue;
206
 
 
207
 
        for (j=0; j<6; j++)
208
 
            snprintf(devices[i].mac+strlen(devices[i].mac), sizeof(devices[i].mac)-strlen(devices[i].mac)-1, "%02x:", mac[j]);
209
 
    }
210
 
#endif
211
 
 
212
 
    p = realloc(devices, sizeof(struct device) * (ndevices + 1));
213
 
    if (!(p))
214
 
        goto err;
215
 
 
216
 
    devices = p;
217
 
    devices[ndevices].name =  NULL;
218
 
    memset(devices[ndevices].mac, 0x00, sizeof(devices[ndevices].mac));
219
 
 
220
 
    return devices;
221
 
 
222
 
err:
223
 
    if (devices) {
224
 
        for (i=0; i < ndevices; i++)
225
 
            if (devices[i].name)
226
 
                free(devices[i].name);
227
 
 
228
 
        free(devices);
229
 
    }
230
 
 
231
 
    return NULL;
232
 
}
233
 
#else
234
 
struct device *get_devices(void)
235
 
{
236
 
    return NULL;
237
 
}
238
 
#endif /* HAVE_GETIFADDRS */
239
 
 
240
 
#if !HAVE_SYSCTLBYNAME && !defined(_WIN32)
241
 
/*
242
 
 * Since we're getting potentially sensitive data (MAC addresses for all devices on the system),
243
 
 * hash all the MAC addresses to provide basic anonymity and security.
244
 
 */
245
 
char *internal_get_host_id(void)
246
 
{
247
 
    size_t i;
248
 
    unsigned char raw_md5[16];
249
 
    char *printable_md5;
250
 
    struct device *devices;
251
 
    void *ctx;
252
 
 
253
 
    devices = get_devices();
254
 
    if (!(devices))
255
 
        return NULL;
256
 
 
257
 
    printable_md5 = calloc(1, 37);
258
 
    if (!(printable_md5)) {
259
 
        free(devices);
260
 
        return NULL;
261
 
    }
262
 
 
263
 
    ctx = cl_hash_init("md5");
264
 
    if (!(ctx)) {
265
 
        for (i=0; devices[i].name != NULL; i++)
266
 
            free(devices[i].name);
267
 
 
268
 
        free(devices);
269
 
        free(printable_md5);
270
 
 
271
 
        return NULL;
272
 
    }
273
 
 
274
 
    for (i=0; devices[i].name != NULL; i++)
275
 
        cl_update_hash(ctx, devices[i].mac, sizeof(devices[i].mac));
276
 
 
277
 
    cl_finish_hash(ctx, raw_md5);
278
 
 
279
 
    for (i=0; devices[i].name != NULL; i++)
280
 
        free(devices[i].name);
281
 
    free(devices);
282
 
 
283
 
    for (i=0; i < sizeof(raw_md5); i++) {
284
 
        size_t len = strlen(printable_md5);
285
 
        switch (len) {
286
 
            case 8:
287
 
            case 13:
288
 
            case 18:
289
 
            case 23:
290
 
                printable_md5[len++] = '-';
291
 
                break;
292
 
        }
293
 
 
294
 
        sprintf(printable_md5+len, "%02x", raw_md5[i]);
295
 
    }
296
 
 
297
 
    return printable_md5;
298
 
}
299
 
#endif