... | ... |
@@ -183,7 +183,7 @@ static int print_chain(struct metachain *c, char *str, size_t len) |
183 | 183 |
static cl_error_t post(int fd, int result, const char *virname, void *context) |
184 | 184 |
{ |
185 | 185 |
struct clamscan_cb_data *d = context; |
186 |
- struct metachain *c; |
|
186 |
+ struct metachain *c = NULL; |
|
187 | 187 |
char str[128]; |
188 | 188 |
|
189 | 189 |
UNUSEDPARAM(fd); |
... | ... |
@@ -2485,7 +2485,7 @@ downloadmanager (const struct optstruct *opts, const char *hostname, |
2485 | 2485 |
unsigned int attempt) |
2486 | 2486 |
{ |
2487 | 2487 |
time_t currtime; |
2488 |
- int ret, custret, updated = 0, outdated = 0, signo = 0, logerr; |
|
2488 |
+ int ret, custret = 0, updated = 0, outdated = 0, signo = 0, logerr; |
|
2489 | 2489 |
unsigned int ttl; |
2490 | 2490 |
char ipaddr[46], *dnsreply = NULL, *pt, *localip = NULL, *newver = NULL; |
2491 | 2491 |
const struct optstruct *opt; |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
2 |
+ * Copyright (C) 2015, 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
3 | 3 |
* Copyright (C) 2010 Sourcefire, Inc. |
4 | 4 |
* |
5 | 5 |
* Authors: aCaB <acab@clamav.net> |
... | ... |
@@ -50,11 +50,11 @@ static const uint8_t hqxtbl[] = { |
50 | 50 |
|
51 | 51 |
int cli_binhex(cli_ctx *ctx) { |
52 | 52 |
fmap_t *map = *ctx->fmap; |
53 |
- const uint8_t *encoded; |
|
54 |
- uint8_t decoded[BUFSIZ], spare_bits, last_byte=0, this_byte, offset=0; |
|
53 |
+ const uint8_t *encoded = NULL; |
|
54 |
+ uint8_t decoded[BUFSIZ], spare_bits = 0, last_byte = 0, this_byte = 0, offset = 0; |
|
55 | 55 |
size_t enc_done=0, enc_todo=map->len; |
56 | 56 |
unsigned int dec_done=0, chunksz = 0, chunkoff=0; |
57 |
- uint32_t datalen, reslen; |
|
57 |
+ uint32_t datalen = 0, reslen = 0; |
|
58 | 58 |
int in_data = 0, in_run = 0, datafd, resfd, ret = CL_CLEAN; |
59 | 59 |
enum binhex_phase { IN_BANNER, IN_HEADER, IN_DATA, IN_LIMBO1, IN_LIMBO2, IN_RES } write_phase = IN_BANNER; |
60 | 60 |
char *dname, *rname; |
... | ... |
@@ -188,7 +188,10 @@ int cli_binhex(cli_ctx *ctx) { |
188 | 188 |
} |
189 | 189 |
} |
190 | 190 |
|
191 |
- if(!chunksz) { |
|
191 |
+ // 'chunksz' must be 0 the first iteration, |
|
192 |
+ // so that 'encoded' will be initialized before first dereference. |
|
193 |
+ if(!chunksz) |
|
194 |
+ { |
|
192 | 195 |
chunksz = MIN(enc_todo, map->pgsz); |
193 | 196 |
encoded = fmap_need_off_once(map, enc_done, chunksz); |
194 | 197 |
if(!encoded) { |
... | ... |
@@ -553,7 +553,7 @@ static inline char *readData(const unsigned char *p, unsigned *off, unsigned len |
553 | 553 |
|
554 | 554 |
static inline char *readString(const unsigned char *p, unsigned *off, unsigned len, char *ok) |
555 | 555 |
{ |
556 |
- unsigned stringlen; |
|
556 |
+ unsigned stringlen = 0; |
|
557 | 557 |
char *str = readData(p, off, len, ok, &stringlen); |
558 | 558 |
if (*ok && stringlen && str[stringlen-1] != '\0') { |
559 | 559 |
str[stringlen-1] = '\0'; |
... | ... |
@@ -3199,7 +3199,7 @@ void cli_bytetype_describe(const struct cli_bc *bc) |
3199 | 3199 |
|
3200 | 3200 |
void cli_bytevalue_describe(const struct cli_bc *bc, unsigned funcid) |
3201 | 3201 |
{ |
3202 |
- unsigned i, j, total = 0; |
|
3202 |
+ unsigned i, total = 0; |
|
3203 | 3203 |
const struct cli_bc_func *func; |
3204 | 3204 |
|
3205 | 3205 |
if (funcid >= bc->num_func) { |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
/* |
2 | 2 |
* Support for matcher using PCRE |
3 | 3 |
* |
4 |
- * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
4 |
+ * Copyright (C) 2015, 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
5 | 5 |
* Copyright (C) 2007-2013 Sourcefire, Inc. |
6 | 6 |
* All Rights Reserved. |
7 | 7 |
* |
... | ... |
@@ -593,7 +593,7 @@ int cli_pcre_scanbuf(const unsigned char *buffer, uint32_t length, const char ** |
593 | 593 |
unsigned int i, evalcnt = 0; |
594 | 594 |
uint64_t maxfilesize, evalids = 0; |
595 | 595 |
uint32_t global, encompass, rolling; |
596 |
- int rc, offset, ret = CL_SUCCESS, options=0; |
|
596 |
+ int rc = 0, offset = 0, ret = CL_SUCCESS, options=0; |
|
597 | 597 |
uint8_t viruses_found = 0; |
598 | 598 |
|
599 | 599 |
if ((root->pcre_metas == 0) || (!root->pcre_metatable) || (ctx && ctx->dconf && !(ctx->dconf->pcre & PCRE_CONF_SUPPORT))) |
... | ... |
@@ -1338,7 +1338,7 @@ void pdf_parseobj(struct pdf_struct *pdf, struct pdf_obj *obj) |
1338 | 1338 |
/* enough to hold common pdf names, we don't need all the names */ |
1339 | 1339 |
char pdfname[64]; |
1340 | 1340 |
const char *q2, *q3; |
1341 |
- const char *nextobj, *nextopen, *nextclose; |
|
1341 |
+ const char *nextobj = NULL, *nextopen = NULL, *nextclose = NULL; |
|
1342 | 1342 |
const char *q = obj->start + pdf->map; |
1343 | 1343 |
const char *dict, *enddict, *start; |
1344 | 1344 |
off_t dict_length, full_dict_length; |
... | ... |
@@ -271,8 +271,8 @@ static void |
271 | 271 |
p_ere(struct parse *p, int stop) /* character this ERE should end at */ |
272 | 272 |
{ |
273 | 273 |
char c; |
274 |
- sopno prevback; |
|
275 |
- sopno prevfwd; |
|
274 |
+ sopno prevback = 0; |
|
275 |
+ sopno prevfwd = 0; |
|
276 | 276 |
sopno conc; |
277 | 277 |
int first = 1; /* is this the first alternative? */ |
278 | 278 |
|
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved. |
|
2 |
+ * Copyright (C) 2014, 2017 Cisco and/or its affiliates. All rights reserved. |
|
3 | 3 |
* |
4 | 4 |
* Author: Shawn Webb |
5 | 5 |
* |
... | ... |
@@ -56,9 +56,9 @@ |
56 | 56 |
|
57 | 57 |
int connect_host(const char *host, const char *port, uint32_t timeout, int useAsync) |
58 | 58 |
{ |
59 |
- int sockfd; |
|
60 |
- struct addrinfo hints, *servinfo, *p; |
|
61 |
- int flags, error; |
|
59 |
+ int sockfd = -1; |
|
60 |
+ struct addrinfo hints, *servinfo = NULL, *p = NULL; |
|
61 |
+ int flags = 0, error; |
|
62 | 62 |
socklen_t len; |
63 | 63 |
fd_set read_fds, write_fds; |
64 | 64 |
struct timeval tv; |
... | ... |
@@ -144,7 +144,7 @@ int connect_host(const char *host, const char *port, uint32_t timeout, int useAs |
144 | 144 |
freeaddrinfo(servinfo); |
145 | 145 |
|
146 | 146 |
/* Return to using a synchronous socket to make Linux happy */ |
147 |
- if (useAsync) { |
|
147 |
+ if (useAsync && (sockfd >= 0)) { |
|
148 | 148 |
if (fcntl(sockfd, F_SETFL, flags) < 0) { |
149 | 149 |
closesocket(sockfd); |
150 | 150 |
return -1; |