especially the one about gzFile vs gzFile*, gzopen returns gzFile!
Török Edvin authored on 2012/05/30 19:37:32... | ... |
@@ -1257,7 +1257,7 @@ static int buildcld(const char *tmpdir, const char *dbname, const char *newfile, |
1257 | 1257 |
char cwd[512], info[32], buff[513], *pt; |
1258 | 1258 |
struct dirent *dent; |
1259 | 1259 |
int fd, err = 0; |
1260 |
- gzFile *gzs = NULL; |
|
1260 |
+ gzFile gzs = NULL; |
|
1261 | 1261 |
|
1262 | 1262 |
if(!getcwd(cwd, sizeof(cwd))) { |
1263 | 1263 |
logg("!buildcld: Can't get path of current working directory\n"); |
... | ... |
@@ -93,23 +93,6 @@ |
93 | 93 |
|
94 | 94 |
#endif |
95 | 95 |
|
96 |
-/* Max size of any number in bits. Basically the largest size you will be multiplying |
|
97 |
- * should be half [or smaller] of FP_MAX_SIZE-four_digit |
|
98 |
- * |
|
99 |
- * You can externally define this or it defaults to 4096-bits [allowing multiplications upto 2048x2048 bits ] |
|
100 |
- */ |
|
101 |
-#ifndef FP_MAX_SIZE |
|
102 |
- #define FP_MAX_SIZE (8192+(8*DIGIT_BIT)) |
|
103 |
-#endif |
|
104 |
- |
|
105 |
-/* will this lib work? */ |
|
106 |
-#if (CHAR_BIT & 7) |
|
107 |
- #error CHAR_BIT must be a multiple of eight. |
|
108 |
-#endif |
|
109 |
-#if FP_MAX_SIZE % CHAR_BIT |
|
110 |
- #error FP_MAX_SIZE must be a multiple of CHAR_BIT |
|
111 |
-#endif |
|
112 |
- |
|
113 | 96 |
/* autodetect x86-64 and make sure we are using 64-bit digits with x86-64 asm */ |
114 | 97 |
#if defined(__x86_64__) |
115 | 98 |
#if defined(TFM_X86) || defined(TFM_SSE2) || defined(TFM_ARM) |
... | ... |
@@ -272,6 +255,20 @@ |
272 | 272 |
|
273 | 273 |
/* # of digits this is */ |
274 | 274 |
#define DIGIT_BIT (int)((CHAR_BIT) * sizeof(fp_digit)) |
275 |
+/* Max size of any number in bits. Basically the largest size you will be multiplying |
|
276 |
+ * should be half [or smaller] of FP_MAX_SIZE-four_digit |
|
277 |
+ * |
|
278 |
+ * You can externally define this or it defaults to 4096-bits [allowing multiplications upto 2048x2048 bits ] |
|
279 |
+ */ |
|
280 |
+#ifndef FP_MAX_SIZE |
|
281 |
+ #define FP_MAX_SIZE (8192+(8*DIGIT_BIT)) |
|
282 |
+#endif |
|
283 |
+ |
|
284 |
+/* will this lib work? */ |
|
285 |
+#if (CHAR_BIT & 7) |
|
286 |
+ #error CHAR_BIT must be a multiple of eight. |
|
287 |
+#endif |
|
288 |
+ |
|
275 | 289 |
#define FP_MASK (fp_digit)(-1) |
276 | 290 |
#define FP_SIZE (FP_MAX_SIZE/DIGIT_BIT) |
277 | 291 |
|
... | ... |
@@ -484,7 +484,7 @@ static inline void html_tag_contents_append(struct tag_contents *cont, const uns |
484 | 484 |
if (mbchar && (c < 0x80 || mbchar >= 0x10000)) { |
485 | 485 |
if (mbchar == 0xE38082 || mbchar == 0xEFBC8E |
486 | 486 |
|| mbchar == 0xEFB992 || |
487 |
- mbchar == 0xA1 && (c == 0x43 || c == 0x44 || c == 0x4F)) { |
|
487 |
+ (mbchar == 0xA1 && (c == 0x43 || c == 0x44 || c == 0x4F))) { |
|
488 | 488 |
cont->contents[i++] = '.'; |
489 | 489 |
if (mbchar == 0xA1) { |
490 | 490 |
--i; |
... | ... |
@@ -791,7 +791,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag |
791 | 791 |
if (*ptr < 0x80 || mbchar >= 0x10000) { |
792 | 792 |
if (mbchar == 0xE38082 || mbchar == 0xEFBC8E |
793 | 793 |
|| mbchar == 0xEFB992 || |
794 |
- mbchar == 0xA1 && (*ptr == 0x43 || *ptr == 0x44 || *ptr == 0x4F)) { |
|
794 |
+ (mbchar == 0xA1 && (*ptr == 0x43 || *ptr == 0x44 || *ptr == 0x4F))) { |
|
795 | 795 |
/* bb #4097 */ |
796 | 796 |
html_output_c(file_buff_o2, '.'); |
797 | 797 |
html_output_c(file_buff_text, '.'); |
... | ... |
@@ -1089,7 +1089,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag |
1089 | 1089 |
if (mbchar2 && (*ptr < 0x80 || mbchar2 >= 0x10000)) { |
1090 | 1090 |
if (mbchar2 == 0xE38082 || mbchar2 == 0xEFBC8E |
1091 | 1091 |
|| mbchar2 == 0xEFB992 || |
1092 |
- mbchar2 == 0xA1 && (*ptr == 0x43 || *ptr == 0x44 || *ptr == 0x4F)) { |
|
1092 |
+ (mbchar2 == 0xA1 && (*ptr == 0x43 || *ptr == 0x44 || *ptr == 0x4F))) { |
|
1093 | 1093 |
html_output_c(file_buff_o2, '.'); |
1094 | 1094 |
if (tag_val_length < HTML_STR_LENGTH) |
1095 | 1095 |
tag_val[tag_val_length++] = '.'; |
... | ... |
@@ -91,15 +91,15 @@ static int iso_scan_file(const iso9660_t *iso, unsigned int block, unsigned int |
91 | 91 |
static char *iso_string(iso9660_t *iso, const void *src, unsigned int len) { |
92 | 92 |
if(iso->joliet) { |
93 | 93 |
char *utf8; |
94 |
+ const char *uutf8; |
|
94 | 95 |
if(len > sizeof(iso->buf)) |
95 | 96 |
len = sizeof(iso->buf) - 2; |
96 | 97 |
memcpy(iso->buf, src, len); |
97 | 98 |
iso->buf[len] = '\0'; |
98 | 99 |
iso->buf[len+1] = '\0'; |
99 | 100 |
utf8 = cli_utf16_to_utf8(iso->buf, len, UTF16_BE); |
100 |
- if(!utf8) |
|
101 |
- utf8 = ""; |
|
102 |
- strncpy(iso->buf, utf8, sizeof(iso->buf)); |
|
101 |
+ uutf8 = utf8 ? utf8 : ""; |
|
102 |
+ strncpy(iso->buf, uutf8, sizeof(iso->buf)); |
|
103 | 103 |
iso->buf[sizeof(iso->buf)-1] = '\0'; |
104 | 104 |
free(utf8); |
105 | 105 |
} else { |
... | ... |
@@ -402,7 +402,7 @@ int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx) |
402 | 402 |
int have_sha1, have_sha256, do_dsig_check = 1; |
403 | 403 |
|
404 | 404 |
if(cli_hm_scan(digest, size, &virname, ctx->engine->hm_fp, CLI_HASH_MD5) == CL_VIRUS) { |
405 |
- cli_dbgmsg("cli_checkfp(md5): Found false positive detection (fp sig: %s), size: %d\n", virname, size); |
|
405 |
+ cli_dbgmsg("cli_checkfp(md5): Found false positive detection (fp sig: %s), size: %d\n", virname, (int)size); |
|
406 | 406 |
return CL_CLEAN; |
407 | 407 |
} |
408 | 408 |
|
... | ... |
@@ -601,9 +601,9 @@ static void aes_decrypt(const unsigned char *in, off_t *length, unsigned char *q |
601 | 601 |
unsigned char pad, i; |
602 | 602 |
int nrounds; |
603 | 603 |
|
604 |
- cli_dbgmsg("cli_pdf: aes_decrypt: key length: %d, data length: %d\n", key_n, *length); |
|
604 |
+ cli_dbgmsg("cli_pdf: aes_decrypt: key length: %d, data length: %d\n", key_n, (int)*length); |
|
605 | 605 |
if (key_n > 32) { |
606 |
- cli_dbgmsg("cli_pdf: aes_decrypt: key length is %s!\n", key_n*8); |
|
606 |
+ cli_dbgmsg("cli_pdf: aes_decrypt: key length is %d!\n", key_n*8); |
|
607 | 607 |
return; |
608 | 608 |
} |
609 | 609 |
if (len < 32) { |
... | ... |
@@ -650,7 +650,7 @@ static void aes_decrypt(const unsigned char *in, off_t *length, unsigned char *q |
650 | 650 |
len += pad; |
651 | 651 |
} |
652 | 652 |
*length -= len; |
653 |
- cli_dbgmsg("cli_pdf: aes_decrypt: length is %d\n", *length); |
|
653 |
+ cli_dbgmsg("cli_pdf: aes_decrypt: length is %d\n", (int)*length); |
|
654 | 654 |
} |
655 | 655 |
|
656 | 656 |
|
... | ... |
@@ -1046,7 +1046,7 @@ static int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj) |
1046 | 1046 |
break; |
1047 | 1047 |
} |
1048 | 1048 |
free(js); |
1049 |
- cli_dbgmsg("bytesleft: %d\n", bytesleft); |
|
1049 |
+ cli_dbgmsg("bytesleft: %d\n", (int)bytesleft); |
|
1050 | 1050 |
|
1051 | 1051 |
q2 = pdf_nextobject(q, bytesleft); |
1052 | 1052 |
if (!q2) q2 = q + bytesleft - 1; |
... | ... |
@@ -1666,7 +1666,7 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O, |
1666 | 1666 |
sha256_final(&sha256, result2); |
1667 | 1667 |
n = UE ? strlen(UE) : 0; |
1668 | 1668 |
if (n != 32) { |
1669 |
- cli_dbgmsg("cli_pdf: UE length is not 32: %d\n", n); |
|
1669 |
+ cli_dbgmsg("cli_pdf: UE length is not 32: %d\n", (int)n); |
|
1670 | 1670 |
noisy_warnmsg("cli_pdf: UE length is not 32: %d\n", n); |
1671 | 1671 |
} else { |
1672 | 1672 |
pdf->keylen = 32; |
... | ... |
@@ -137,7 +137,7 @@ cli_untar(const char *dir, unsigned int posix, cli_ctx *ctx) |
137 | 137 |
size_t nread; |
138 | 138 |
|
139 | 139 |
block = fmap_need_off_once_len(*ctx->fmap, pos, BLOCKSIZE, &nread); |
140 |
- cli_dbgmsg("cli_untar: pos = %d\n", pos); |
|
140 |
+ cli_dbgmsg("cli_untar: pos = %d\n", (int)pos); |
|
141 | 141 |
|
142 | 142 |
if(!in_block && !nread) |
143 | 143 |
break; |
... | ... |
@@ -757,7 +757,7 @@ int cdiff_apply(int fd, unsigned short mode) |
757 | 757 |
{ |
758 | 758 |
struct cdiff_ctx ctx; |
759 | 759 |
FILE *fh; |
760 |
- gzFile *gzh; |
|
760 |
+ gzFile gzh; |
|
761 | 761 |
char *line, *lbuf, buff[FILEBUFF], *dsig = NULL; |
762 | 762 |
unsigned int lines = 0, cmds = 0; |
763 | 763 |
unsigned int difflen, diffremain, line_size = CDIFF_LINE_SIZE; |
... | ... |
@@ -504,7 +504,7 @@ static int script2cdiff(const char *script, const char *builder, const struct op |
504 | 504 |
SHA256_CTX ctx; |
505 | 505 |
struct stat sb; |
506 | 506 |
FILE *scripth, *cdiffh; |
507 |
- gzFile *gzh; |
|
507 |
+ gzFile gzh; |
|
508 | 508 |
unsigned int ver, osize; |
509 | 509 |
int bytes; |
510 | 510 |
|
... | ... |
@@ -633,7 +633,7 @@ static int build(const struct optstruct *opts) |
633 | 633 |
const char *newcvd, *localdbdir = NULL; |
634 | 634 |
struct cl_engine *engine; |
635 | 635 |
FILE *cvd, *fh; |
636 |
- gzFile *tar; |
|
636 |
+ gzFile tar; |
|
637 | 637 |
time_t timet; |
638 | 638 |
struct tm *brokent; |
639 | 639 |
struct cl_cvd *oldcvd; |