git-svn: trunk@2704
Tomasz Kojm authored on 2007/02/12 19:47:01... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Mon Feb 12 11:44:21 CET 2007 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav/md5.c: revert problematic cleanup changes and rename functions |
|
4 |
+ to prevent possible namespace clashes with other libraries |
|
5 |
+ |
|
1 | 6 |
Sun Feb 11 11:19:57 CET 2007 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* freshclam: add option ScriptedUpdates, requested by Luca |
... | ... |
@@ -298,7 +298,7 @@ int cli_ncore_scanbuff(const char *buffer, unsigned int length, const char **vir |
298 | 298 |
return ret; |
299 | 299 |
} |
300 | 300 |
|
301 |
-int cli_ncore_scandesc(int desc, cli_ctx *ctx, unsigned short ftype, int *cont, unsigned int *targettab, MD5_CTX *md5ctx) |
|
301 |
+int cli_ncore_scandesc(int desc, cli_ctx *ctx, unsigned short ftype, int *cont, unsigned int *targettab, cli_md5_ctx *md5ctx) |
|
302 | 302 |
{ |
303 | 303 |
void *streamhandle; |
304 | 304 |
void *resulthandle; |
... | ... |
@@ -25,7 +25,7 @@ |
25 | 25 |
|
26 | 26 |
int cli_ncore_scanbuff(const char *buffer, unsigned int length, const char **virname, const struct cl_engine *engine, unsigned short ftype, unsigned int *targettab); |
27 | 27 |
|
28 |
-int cli_ncore_scandesc(int desc, cli_ctx *ctx, unsigned short ftype, int *cont, unsigned int *targettab, MD5_CTX *md5ctx); |
|
28 |
+int cli_ncore_scandesc(int desc, cli_ctx *ctx, unsigned short ftype, int *cont, unsigned int *targettab, cli_md5_ctx *md5ctx); |
|
29 | 29 |
|
30 | 30 |
int cli_ncore_load(const char *filename, struct cl_engine **engine, unsigned int *signo, unsigned int options); |
31 | 31 |
|
... | ... |
@@ -282,7 +282,7 @@ int cli_scandesc(int desc, cli_ctx *ctx, unsigned short otfrec, cli_file_t ftype |
282 | 282 |
unsigned int buffersize, length, maxpatlen, shift = 0; |
283 | 283 |
unsigned long int offset = 0; |
284 | 284 |
struct cli_ac_data gdata, tdata; |
285 |
- MD5_CTX md5ctx; |
|
285 |
+ cli_md5_ctx md5ctx; |
|
286 | 286 |
unsigned char digest[16]; |
287 | 287 |
struct cli_md5_node *md5_node; |
288 | 288 |
struct cli_matcher *groot = NULL, *troot = NULL; |
... | ... |
@@ -343,7 +343,7 @@ int cli_scandesc(int desc, cli_ctx *ctx, unsigned short otfrec, cli_file_t ftype |
343 | 343 |
} |
344 | 344 |
|
345 | 345 |
if(!ftonly && ctx->engine->md5_hlist) |
346 |
- MD5_Init(&md5ctx); |
|
346 |
+ cli_md5_init(&md5ctx); |
|
347 | 347 |
|
348 | 348 |
buff = buffer; |
349 | 349 |
buff += maxpatlen; /* pointer to read data block */ |
... | ... |
@@ -400,7 +400,7 @@ int cli_scandesc(int desc, cli_ctx *ctx, unsigned short otfrec, cli_file_t ftype |
400 | 400 |
} |
401 | 401 |
|
402 | 402 |
if(ctx->engine->md5_hlist) |
403 |
- MD5_Update(&md5ctx, buff + shift, bytes); |
|
403 |
+ cli_md5_update(&md5ctx, buff + shift, bytes); |
|
404 | 404 |
} |
405 | 405 |
|
406 | 406 |
if(bytes + shift == SCANBUFF) { |
... | ... |
@@ -427,7 +427,7 @@ int cli_scandesc(int desc, cli_ctx *ctx, unsigned short otfrec, cli_file_t ftype |
427 | 427 |
cli_ac_freedata(&tdata); |
428 | 428 |
|
429 | 429 |
if(!ftonly && ctx->engine->md5_hlist) { |
430 |
- MD5_Final(digest, &md5ctx); |
|
430 |
+ cli_md5_final(digest, &md5ctx); |
|
431 | 431 |
|
432 | 432 |
if((md5_node = cli_vermd5(digest, ctx->engine)) && !md5_node->fp) { |
433 | 433 |
struct stat sb; |
... | ... |
@@ -49,16 +49,16 @@ |
49 | 49 |
*/ |
50 | 50 |
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) |
51 | 51 |
#define SET(n) \ |
52 |
- (*(const MD5_u32plus *)(&ptr[(n) * 4])) |
|
52 |
+ (*(MD5_u32plus *)&ptr[(n) * 4]) |
|
53 | 53 |
#define GET(n) \ |
54 | 54 |
SET(n) |
55 | 55 |
#else |
56 | 56 |
#define SET(n) \ |
57 | 57 |
(ctx->block[(n)] = \ |
58 |
- (const MD5_u32plus)ptr[(n) * 4] | \ |
|
59 |
- ((const MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ |
|
60 |
- ((const MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ |
|
61 |
- ((const MD5_u32plus)ptr[(n) * 4 + 3] << 24)) |
|
58 |
+ (MD5_u32plus)ptr[(n) * 4] | \ |
|
59 |
+ ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ |
|
60 |
+ ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ |
|
61 |
+ ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) |
|
62 | 62 |
#define GET(n) \ |
63 | 63 |
(ctx->block[(n)]) |
64 | 64 |
#endif |
... | ... |
@@ -67,9 +67,9 @@ |
67 | 67 |
* This processes one or more 64-byte data blocks, but does NOT update |
68 | 68 |
* the bit counters. There are no alignment requirements. |
69 | 69 |
*/ |
70 |
-static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) |
|
70 |
+static void *body(cli_md5_ctx *ctx, void *data, unsigned long size) |
|
71 | 71 |
{ |
72 |
- const unsigned char *ptr; |
|
72 |
+ unsigned char *ptr; |
|
73 | 73 |
MD5_u32plus a, b, c, d; |
74 | 74 |
MD5_u32plus saved_a, saved_b, saved_c, saved_d; |
75 | 75 |
|
... | ... |
@@ -174,7 +174,7 @@ static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) |
174 | 174 |
return ptr; |
175 | 175 |
} |
176 | 176 |
|
177 |
-void MD5_Init(MD5_CTX *ctx) |
|
177 |
+void cli_md5_init(cli_md5_ctx *ctx) |
|
178 | 178 |
{ |
179 | 179 |
ctx->a = 0x67452301; |
180 | 180 |
ctx->b = 0xefcdab89; |
... | ... |
@@ -185,7 +185,7 @@ void MD5_Init(MD5_CTX *ctx) |
185 | 185 |
ctx->hi = 0; |
186 | 186 |
} |
187 | 187 |
|
188 |
-void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) |
|
188 |
+void cli_md5_update(cli_md5_ctx *ctx, void *data, unsigned long size) |
|
189 | 189 |
{ |
190 | 190 |
MD5_u32plus saved_lo; |
191 | 191 |
unsigned long used, free; |
... | ... |
@@ -206,7 +206,7 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) |
206 | 206 |
} |
207 | 207 |
|
208 | 208 |
memcpy(&ctx->buffer[used], data, free); |
209 |
- data = (const unsigned char *)data + free; |
|
209 |
+ data = (unsigned char *)data + free; |
|
210 | 210 |
size -= free; |
211 | 211 |
body(ctx, ctx->buffer, 64); |
212 | 212 |
} |
... | ... |
@@ -219,7 +219,7 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) |
219 | 219 |
memcpy(ctx->buffer, data, size); |
220 | 220 |
} |
221 | 221 |
|
222 |
-void MD5_Final(unsigned char *result, MD5_CTX *ctx) |
|
222 |
+void cli_md5_final(unsigned char *result, cli_md5_ctx *ctx) |
|
223 | 223 |
{ |
224 | 224 |
unsigned long used, free; |
225 | 225 |
|
... | ... |
@@ -19,10 +19,10 @@ typedef struct { |
19 | 19 |
MD5_u32plus a, b, c, d; |
20 | 20 |
unsigned char buffer[64]; |
21 | 21 |
MD5_u32plus block[16]; |
22 |
-} MD5_CTX; |
|
22 |
+} cli_md5_ctx; |
|
23 | 23 |
|
24 |
-extern void MD5_Init(MD5_CTX *ctx); |
|
25 |
-extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); |
|
26 |
-extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); |
|
24 |
+extern void cli_md5_init(cli_md5_ctx *ctx); |
|
25 |
+extern void cli_md5_update(cli_md5_ctx *ctx, void *data, unsigned long size); |
|
26 |
+extern void cli_md5_final(unsigned char *result, cli_md5_ctx *ctx); |
|
27 | 27 |
|
28 | 28 |
#endif |
... | ... |
@@ -234,19 +234,19 @@ unsigned char *cli_md5digest(int desc) |
234 | 234 |
{ |
235 | 235 |
unsigned char *digest; |
236 | 236 |
char buff[FILEBUFF]; |
237 |
- MD5_CTX ctx; |
|
237 |
+ cli_md5_ctx ctx; |
|
238 | 238 |
int bytes; |
239 | 239 |
|
240 | 240 |
|
241 | 241 |
if(!(digest = cli_malloc(16))) |
242 | 242 |
return NULL; |
243 | 243 |
|
244 |
- MD5_Init(&ctx); |
|
244 |
+ cli_md5_init(&ctx); |
|
245 | 245 |
|
246 | 246 |
while((bytes = cli_readn(desc, buff, FILEBUFF))) |
247 |
- MD5_Update(&ctx, buff, bytes); |
|
247 |
+ cli_md5_update(&ctx, buff, bytes); |
|
248 | 248 |
|
249 |
- MD5_Final(digest, &ctx); |
|
249 |
+ cli_md5_final(digest, &ctx); |
|
250 | 250 |
|
251 | 251 |
return digest; |
252 | 252 |
} |
... | ... |
@@ -255,17 +255,17 @@ char *cli_md5stream(FILE *fs, unsigned char *digcpy) |
255 | 255 |
{ |
256 | 256 |
unsigned char digest[16]; |
257 | 257 |
char buff[FILEBUFF]; |
258 |
- MD5_CTX ctx; |
|
258 |
+ cli_md5_ctx ctx; |
|
259 | 259 |
char *md5str, *pt; |
260 | 260 |
int i, bytes; |
261 | 261 |
|
262 | 262 |
|
263 |
- MD5_Init(&ctx); |
|
263 |
+ cli_md5_init(&ctx); |
|
264 | 264 |
|
265 | 265 |
while((bytes = fread(buff, 1, FILEBUFF, fs))) |
266 |
- MD5_Update(&ctx, buff, bytes); |
|
266 |
+ cli_md5_update(&ctx, buff, bytes); |
|
267 | 267 |
|
268 |
- MD5_Final(digest, &ctx); |
|
268 |
+ cli_md5_final(digest, &ctx); |
|
269 | 269 |
|
270 | 270 |
if(!(md5str = (char *) cli_calloc(32 + 1, sizeof(char)))) |
271 | 271 |
return NULL; |
... | ... |
@@ -303,13 +303,13 @@ static char *cli_md5buff(const char *buffer, unsigned int len, unsigned char *di |
303 | 303 |
{ |
304 | 304 |
unsigned char digest[16]; |
305 | 305 |
char *md5str, *pt; |
306 |
- MD5_CTX ctx; |
|
306 |
+ cli_md5_ctx ctx; |
|
307 | 307 |
int i; |
308 | 308 |
|
309 | 309 |
|
310 |
- MD5_Init(&ctx); |
|
311 |
- MD5_Update(&ctx, (const unsigned char *) buffer, len); |
|
312 |
- MD5_Final(digest, &ctx); |
|
310 |
+ cli_md5_init(&ctx); |
|
311 |
+ cli_md5_update(&ctx, (const unsigned char *) buffer, len); |
|
312 |
+ cli_md5_final(digest, &ctx); |
|
313 | 313 |
|
314 | 314 |
if(dig) |
315 | 315 |
memcpy(dig, digest, 16); |
... | ... |
@@ -198,7 +198,7 @@ static unsigned int cli_md5sect(int fd, uint32_t offset, uint32_t size, unsigned |
198 | 198 |
size_t bread, sum = 0; |
199 | 199 |
off_t pos; |
200 | 200 |
char buff[FILEBUFF]; |
201 |
- MD5_CTX md5ctx; |
|
201 |
+ cli_md5_ctx md5ctx; |
|
202 | 202 |
|
203 | 203 |
|
204 | 204 |
if((pos = lseek(fd, 0, SEEK_CUR)) == -1) { |
... | ... |
@@ -212,19 +212,19 @@ static unsigned int cli_md5sect(int fd, uint32_t offset, uint32_t size, unsigned |
212 | 212 |
return 0; |
213 | 213 |
} |
214 | 214 |
|
215 |
- MD5_Init(&md5ctx); |
|
215 |
+ cli_md5_init(&md5ctx); |
|
216 | 216 |
|
217 | 217 |
while((bread = cli_readn(fd, buff, FILEBUFF)) > 0) { |
218 | 218 |
if(sum + bread >= size) { |
219 |
- MD5_Update(&md5ctx, buff, size - sum); |
|
219 |
+ cli_md5_update(&md5ctx, buff, size - sum); |
|
220 | 220 |
break; |
221 | 221 |
} else { |
222 |
- MD5_Update(&md5ctx, buff, bread); |
|
222 |
+ cli_md5_update(&md5ctx, buff, bread); |
|
223 | 223 |
sum += bread; |
224 | 224 |
} |
225 | 225 |
} |
226 | 226 |
|
227 |
- MD5_Final(digest, &md5ctx); |
|
227 |
+ cli_md5_final(digest, &md5ctx); |
|
228 | 228 |
lseek(fd, pos, SEEK_SET); |
229 | 229 |
return 1; |
230 | 230 |
} |