~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to contrib/Windows/Projects/clamAV/patches

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
*** /home/njh/src/clamav-devel/./libclamav/readdb.c     2007-02-11 16:28:20.000000000 +0000
 
2
--- ./libclamav/readdb.c        2007-02-11 16:29:00.000000000 +0000
 
3
***************
 
4
*** 16,21 ****
 
5
--- 16,24 ----
 
6
   *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
7
   *  MA 02110-1301, USA.
 
8
   */
 
9
+ #ifdef        _MSC_VER
 
10
+ #include <winsock.h>  /* for Sleep() */
 
11
+ #endif
 
12
  
 
13
  #if HAVE_CONFIG_H
 
14
  #include "clamav-config.h"
 
15
***************
 
16
*** 1315,1321 ****
 
17
--- 1318,1328 ----
 
18
  
 
19
      cli_dbgmsg("cli_loaddbdir: Acquiring dbdir lock\n");
 
20
      while((lock = cli_readlockdb(dirname, 0)) == CL_ELOCKDB) {
 
21
+ #ifdef C_WINDOWS
 
22
+       Sleep(5);
 
23
+ #else
 
24
        sleep(5);
 
25
+ #endif
 
26
        if(try++ > 24) {
 
27
            cli_errmsg("cl_load(): Unable to lock database directory: %s\n", dirname);
 
28
            return CL_ELOCKDB;
 
29
*** /home/njh/src/clamav-devel/./libclamav/blob.c       2007-02-10 21:13:23.000000000 +0000
 
30
--- ./libclamav/blob.c  2007-02-10 14:22:00.000000000 +0000
 
31
***************
 
32
*** 272,278 ****
 
33
                        free(b->data);
 
34
                        b->data = NULL;
 
35
                        cli_dbgmsg("blobClose: recovered all %lu bytes\n",
 
36
!                               (unsigned long)b->size);
 
37
                        b->size = 0;
 
38
                } else {
 
39
                        unsigned char *ptr = cli_realloc(b->data, b->len);
 
40
--- 272,278 ----
 
41
                        free(b->data);
 
42
                        b->data = NULL;
 
43
                        cli_dbgmsg("blobClose: recovered all %lu bytes\n",
 
44
!                               b->size);
 
45
                        b->size = 0;
 
46
                } else {
 
47
                        unsigned char *ptr = cli_realloc(b->data, b->len);
 
48
***************
 
49
*** 281,288 ****
 
50
                                return;
 
51
  
 
52
                        cli_dbgmsg("blobClose: recovered %lu bytes from %lu\n",
 
53
!                               (unsigned long)(b->size - b->len),
 
54
!                               (unsigned long)b->size);
 
55
                        b->size = b->len;
 
56
                        b->data = ptr;
 
57
                }
 
58
--- 281,287 ----
 
59
                                return;
 
60
  
 
61
                        cli_dbgmsg("blobClose: recovered %lu bytes from %lu\n",
 
62
!                               b->size - b->len, b->size);
 
63
                        b->size = b->len;
 
64
                        b->data = ptr;
 
65
                }
 
66
***************
 
67
*** 391,398 ****
 
68
                        cli_errmsg("fileblobDestroy: %s not saved: refer to http://www.clamav.net/bugs.html#pagestart\n", fb->b.name);
 
69
                        free(fb->b.name);
 
70
                } else
 
71
!                       cli_errmsg("fileblobDestroy: file not saved (%lu bytes): report to http://bugs.clamav.net\n",
 
72
!                               (unsigned long)fb->b.len);
 
73
        }
 
74
  #ifdef        CL_DEBUG
 
75
        fb->b.magic = INVALIDCLASS;
 
76
--- 390,396 ----
 
77
                        cli_errmsg("fileblobDestroy: %s not saved: refer to http://www.clamav.net/bugs.html#pagestart\n", fb->b.name);
 
78
                        free(fb->b.name);
 
79
                } else
 
80
!                       cli_errmsg("fileblobDestroy: file not saved (%lu bytes): report to http://bugs.clamav.net\n", fb->b.len);
 
81
        }
 
82
  #ifdef        CL_DEBUG
 
83
        fb->b.magic = INVALIDCLASS;
 
84
***************
 
85
*** 470,477 ****
 
86
  
 
87
        if(fd < 0) {
 
88
                cli_errmsg("Can't create temporary file %s: %s\n", fullname, strerror(errno));
 
89
!               cli_dbgmsg("%lu %lu\n", (unsigned long)sizeof(fullname),
 
90
!                       (unsigned long)strlen(fullname));
 
91
                return;
 
92
        }
 
93
  
 
94
--- 468,474 ----
 
95
  
 
96
        if(fd < 0) {
 
97
                cli_errmsg("Can't create temporary file %s: %s\n", fullname, strerror(errno));
 
98
!               cli_dbgmsg("%d %d\n", sizeof(fullname), strlen(fullname));
 
99
                return;
 
100
        }
 
101
  
 
102
***************
 
103
*** 481,488 ****
 
104
  
 
105
        if(fb->fp == NULL) {
 
106
                cli_errmsg("Can't create file %s: %s\n", fullname, strerror(errno));
 
107
!               cli_dbgmsg("%lu %lu\n", (unsigned long)sizeof(fullname),
 
108
!                       (unsigned long)strlen(fullname));
 
109
                close(fd);
 
110
  
 
111
                return;
 
112
--- 478,484 ----
 
113
  
 
114
        if(fb->fp == NULL) {
 
115
                cli_errmsg("Can't create file %s: %s\n", fullname, strerror(errno));
 
116
!               cli_dbgmsg("%d %d\n", sizeof(fullname), strlen(fullname));
 
117
                close(fd);
 
118
  
 
119
                return;
 
120
***************
 
121
*** 532,539 ****
 
122
  #endif
 
123
  
 
124
                if(fwrite(data, len, 1, fb->fp) != 1) {
 
125
!                       cli_errmsg("fileblobAddData: Can't write %lu bytes to temporary file %s: %s\n",
 
126
!                               (unsigned long)len, fb->b.name, strerror(errno));
 
127
                        return -1;
 
128
                }
 
129
                fb->isNotEmpty = 1;
 
130
--- 528,534 ----
 
131
  #endif
 
132
  
 
133
                if(fwrite(data, len, 1, fb->fp) != 1) {
 
134
!                       cli_errmsg("fileblobAddData: Can't write %u bytes to temporary file %s: %s\n", len, fb->b.name, strerror(errno));
 
135
                        return -1;
 
136
                }
 
137
                fb->isNotEmpty = 1;
 
138
*** /home/njh/src/clamav-devel/./libclamav/message.c    2007-02-10 21:02:53.000000000 +0000
 
139
--- ./libclamav/message.c       2007-02-10 14:22:00.000000000 +0000
 
140
***************
 
141
*** 510,529 ****
 
142
                        continue;
 
143
  
 
144
                if(*cptr == '"') {
 
145
!                       char *ptr, *kcopy;
 
146
  
 
147
                        /*
 
148
                         * The field is in quotes, so look for the
 
149
                         * closing quotes
 
150
                         */
 
151
!                       kcopy = cli_strdup(key);
 
152
  
 
153
!                       if(kcopy == NULL)
 
154
                                return;
 
155
  
 
156
!                       ptr = strchr(kcopy, '=');
 
157
                        if(ptr == NULL)
 
158
!                               ptr = strchr(kcopy, ':');
 
159
                        *ptr = '\0';
 
160
  
 
161
                        string = strchr(++cptr, '"');
 
162
--- 510,529 ----
 
163
                        continue;
 
164
  
 
165
                if(*cptr == '"') {
 
166
!                       char *ptr;
 
167
  
 
168
                        /*
 
169
                         * The field is in quotes, so look for the
 
170
                         * closing quotes
 
171
                         */
 
172
!                       key = cli_strdup(key);
 
173
  
 
174
!                       if(key == NULL)
 
175
                                return;
 
176
  
 
177
!                       ptr = strchr(key, '=');
 
178
                        if(ptr == NULL)
 
179
!                               ptr = strchr(key, ':');
 
180
                        *ptr = '\0';
 
181
  
 
182
                        string = strchr(++cptr, '"');
 
183
***************
 
184
*** 534,541 ****
 
185
                        } else
 
186
                                string++;
 
187
  
 
188
!                       if(!usefulArg(kcopy)) {
 
189
!                               free(kcopy);
 
190
                                continue;
 
191
                        }
 
192
  
 
193
--- 534,541 ----
 
194
                        } else
 
195
                                string++;
 
196
  
 
197
!                       if(!usefulArg(key)) {
 
198
!                               free((char *)key);
 
199
                                continue;
 
200
                        }
 
201
  
 
202
***************
 
203
*** 557,574 ****
 
204
                                cli_dbgmsg("Can't parse header \"%s\" - if you believe this file contains a virus, submit it to www.clamav.net\n", s);
 
205
                                if(data)
 
206
                                        free(data);
 
207
!                               free(kcopy);
 
208
                                return;
 
209
                        }
 
210
  
 
211
                        *ptr = '\0';
 
212
  
 
213
!                       field = cli_realloc(kcopy, strlen(kcopy) + strlen(data) + 2);
 
214
                        if(field) {
 
215
                                strcat(field, "=");
 
216
                                strcat(field, data);
 
217
                        } else
 
218
!                               free(kcopy);
 
219
                        free(data);
 
220
                } else {
 
221
                        size_t len;
 
222
--- 557,574 ----
 
223
                                cli_dbgmsg("Can't parse header \"%s\" - if you believe this file contains a virus, submit it to www.clamav.net\n", s);
 
224
                                if(data)
 
225
                                        free(data);
 
226
!                               free((char *)key);
 
227
                                return;
 
228
                        }
 
229
  
 
230
                        *ptr = '\0';
 
231
  
 
232
!                       field = cli_realloc((char *)key, strlen(key) + strlen(data) + 2);
 
233
                        if(field) {
 
234
                                strcat(field, "=");
 
235
                                strcat(field, data);
 
236
                        } else
 
237
!                               free((char *)key);
 
238
                        free(data);
 
239
                } else {
 
240
                        size_t len;
 
241
***************
 
242
*** 614,620 ****
 
243
   * Find a MIME variable from the header and return a COPY to the value of that
 
244
   * variable. The caller must free the copy
 
245
   */
 
246
! char *
 
247
  messageFindArgument(const message *m, const char *variable)
 
248
  {
 
249
        int i;
 
250
--- 614,620 ----
 
251
   * Find a MIME variable from the header and return a COPY to the value of that
 
252
   * variable. The caller must free the copy
 
253
   */
 
254
! const char *
 
255
  messageFindArgument(const message *m, const char *variable)
 
256
  {
 
257
        int i;
 
258
***************
 
259
*** 632,639 ****
 
260
                if((ptr == NULL) || (*ptr == '\0'))
 
261
                        continue;
 
262
  #ifdef        CL_DEBUG
 
263
!               cli_dbgmsg("messageFindArgument: compare %lu bytes of %s with %s\n",
 
264
!                       (unsigned long)len, variable, ptr);
 
265
  #endif
 
266
                if(strncasecmp(ptr, variable, len) == 0) {
 
267
                        ptr = &ptr[len];
 
268
--- 632,639 ----
 
269
                if((ptr == NULL) || (*ptr == '\0'))
 
270
                        continue;
 
271
  #ifdef        CL_DEBUG
 
272
!               cli_dbgmsg("messageFindArgument: compare %d bytes of %s with %s\n",
 
273
!                       len, variable, ptr);
 
274
  #endif
 
275
                if(strncasecmp(ptr, variable, len) == 0) {
 
276
                        ptr = &ptr[len];
 
277
***************
 
278
*** 1222,1228 ****
 
279
                                                blobAddData(u, &c, 1);
 
280
                                        } else {
 
281
  #ifdef        CL_DEBUG
 
282
!                                               cli_dbgmsg("uncompress HQX7 at 0x%06lu: %d repetitive bytes\n", l, count);
 
283
  #endif
 
284
                                                blobGrow(u, count);
 
285
                                                while(--count > 0)
 
286
--- 1222,1228 ----
 
287
                                                blobAddData(u, &c, 1);
 
288
                                        } else {
 
289
  #ifdef        CL_DEBUG
 
290
!                                               cli_dbgmsg("uncompress HQX7 at 0x%06x: %d repetitive bytes\n", l, count);
 
291
  #endif
 
292
                                                blobGrow(u, count);
 
293
                                                while(--count > 0)
 
294
***************
 
295
*** 1385,1399 ****
 
296
                 * Find the filename to decode
 
297
                 */
 
298
                if(((enctype == YENCODE) && yEncBegin(m)) || ((i == 0) && yEncBegin(m))) {
 
299
-                       const char *f;
 
300
 
301
                        /*
 
302
                         * TODO: handle multipart yEnc encoded files
 
303
                         */
 
304
                        t_line = yEncBegin(m);
 
305
!                       f = lineGetData(t_line->t_line);
 
306
  
 
307
!                       if((filename = strstr(f, " name=")) != NULL) {
 
308
                                filename = cli_strdup(&filename[6]);
 
309
                                if(filename) {
 
310
                                        cli_chomp(filename);
 
311
--- 1385,1397 ----
 
312
                 * Find the filename to decode
 
313
                 */
 
314
                if(((enctype == YENCODE) && yEncBegin(m)) || ((i == 0) && yEncBegin(m))) {
 
315
                        /*
 
316
                         * TODO: handle multipart yEnc encoded files
 
317
                         */
 
318
                        t_line = yEncBegin(m);
 
319
!                       filename = (char *)lineGetData(t_line->t_line);
 
320
  
 
321
!                       if((filename = strstr(filename, " name=")) != NULL) {
 
322
                                filename = cli_strdup(&filename[6]);
 
323
                                if(filename) {
 
324
                                        cli_chomp(filename);
 
325
***************
 
326
*** 1530,1537 ****
 
327
                        }
 
328
                } while((t_line = t_line->t_next) != NULL);
 
329
  
 
330
!               cli_dbgmsg("Exported %lu bytes using enctype %d\n",
 
331
!                       (unsigned long)size, enctype);
 
332
  
 
333
                /* Verify we have nothing left to flush out */
 
334
                if(m->base64chars) {
 
335
--- 1528,1534 ----
 
336
                        }
 
337
                } while((t_line = t_line->t_next) != NULL);
 
338
  
 
339
!               cli_dbgmsg("Exported %u bytes using enctype %d\n", size, enctype);
 
340
  
 
341
                /* Verify we have nothing left to flush out */
 
342
                if(m->base64chars) {
 
343
***************
 
344
*** 2390,2396 ****
 
345
                }
 
346
        }
 
347
  
 
348
!       cli_dbgmsg("messageDedup reclaimed %lu bytes\n", (unsigned long)saved);
 
349
        m->dedupedThisFar = t1;
 
350
  }
 
351
  
 
352
--- 2387,2393 ----
 
353
                }
 
354
        }
 
355
  
 
356
!       cli_dbgmsg("messageDedup reclaimed %u bytes\n", saved);
 
357
        m->dedupedThisFar = t1;
 
358
  }
 
359
  
 
360
*** /home/njh/src/clamav-devel/./libclamav/mbox.c       2007-02-10 20:54:29.000000000 +0000
 
361
--- ./libclamav/mbox.c  2007-02-10 18:00:58.000000000 +0000
 
362
***************
 
363
*** 2059,2066 ****
 
364
        if(mainMessage && (messageGetBody(mainMessage) != NULL)) {
 
365
                mime_type mimeType;
 
366
                int subtype, inhead, htmltextPart, inMimeHead, i;
 
367
!               const char *mimeSubtype;
 
368
!               char *protocol, *boundary;
 
369
                const text *t_line;
 
370
                /*bool isAlternative;*/
 
371
                message *aMessage;
 
372
--- 2059,2066 ----
 
373
        if(mainMessage && (messageGetBody(mainMessage) != NULL)) {
 
374
                mime_type mimeType;
 
375
                int subtype, inhead, htmltextPart, inMimeHead, i;
 
376
!               const char *mimeSubtype, *boundary;
 
377
!               char *protocol;
 
378
                const text *t_line;
 
379
                /*bool isAlternative;*/
 
380
                message *aMessage;
 
381
***************
 
382
*** 2928,2934 ****
 
383
                                break;
 
384
                        cli_dbgmsg("Save non mime part bounce message\n");
 
385
                        fileblobSetFilename(fb, mctx->dir, "bounce");
 
386
!                       fileblobAddData(fb, (const unsigned char *)"Received: by clamd (bounce)\n", 28);
 
387
                        fileblobSetCTX(fb, mctx->ctx);
 
388
  
 
389
                        inheader = TRUE;
 
390
--- 2928,2934 ----
 
391
                                break;
 
392
                        cli_dbgmsg("Save non mime part bounce message\n");
 
393
                        fileblobSetFilename(fb, mctx->dir, "bounce");
 
394
!                       fileblobAddData(fb, (unsigned char *)"Received: by clamd (bounce)\n", 28);
 
395
                        fileblobSetCTX(fb, mctx->ctx);
 
396
  
 
397
                        inheader = TRUE;
 
398
***************
 
399
*** 2943,2951 ****
 
400
                                        }
 
401
                                } else {
 
402
                                        s = lineGetData(l);
 
403
!                                       fileblobAddData(fb, (const unsigned char *)s, strlen(s));
 
404
                                }
 
405
!                               fileblobAddData(fb, (const unsigned char *)"\n", 1);
 
406
                                lookahead = t->t_next;
 
407
                                if(lookahead == NULL)
 
408
                                        break;
 
409
--- 2943,2951 ----
 
410
                                        }
 
411
                                } else {
 
412
                                        s = lineGetData(l);
 
413
!                                       fileblobAddData(fb, (unsigned char *)s, strlen(s));
 
414
                                }
 
415
!                               fileblobAddData(fb, (unsigned char *)"\n", 1);
 
416
                                lookahead = t->t_next;
 
417
                                if(lookahead == NULL)
 
418
                                        break;
 
419
***************
 
420
*** 3059,3066 ****
 
421
  static int
 
422
  boundaryStart(const char *line, const char *boundary)
 
423
  {
 
424
!       const char *ptr;
 
425
!       char *out;
 
426
        int rc;
 
427
        char buf[RFC2821LENGTH + 1];
 
428
  
 
429
--- 3059,3065 ----
 
430
  static int
 
431
  boundaryStart(const char *line, const char *boundary)
 
432
  {
 
433
!       char *ptr, *out;
 
434
        int rc;
 
435
        char buf[RFC2821LENGTH + 1];
 
436
  
 
437
***************
 
438
*** 3081,3090 ****
 
439
                out = NULL;
 
440
                ptr = rfc822comments(line, buf);
 
441
        } else
 
442
!               ptr = out = rfc822comments(line, NULL);
 
443
  
 
444
        if(ptr == NULL)
 
445
!               ptr = line;
 
446
  
 
447
        if(*ptr++ != '-') {
 
448
                if(out)
 
449
--- 3080,3089 ----
 
450
                out = NULL;
 
451
                ptr = rfc822comments(line, buf);
 
452
        } else
 
453
!               out = ptr = rfc822comments(line, NULL);
 
454
  
 
455
        if(ptr == NULL)
 
456
!               ptr = (char *)line;
 
457
  
 
458
        if(*ptr++ != '-') {
 
459
                if(out)
 
460
***************
 
461
*** 3644,3651 ****
 
462
                }
 
463
                b = messageToBlob(m, 1);
 
464
                len = blobGetDataSize(b);
 
465
!               cli_dbgmsg("Decoded as '%*.*s'\n", (int)len, (int)len,
 
466
!                       blobGetData(b));
 
467
                memcpy(pout, blobGetData(b), len);
 
468
                blobDestroy(b);
 
469
                messageDestroy(m);
 
470
--- 3643,3649 ----
 
471
                }
 
472
                b = messageToBlob(m, 1);
 
473
                len = blobGetDataSize(b);
 
474
!               cli_dbgmsg("Decoded as '%*.*s'\n", len, len, blobGetData(b));
 
475
                memcpy(pout, blobGetData(b), len);
 
476
                blobDestroy(b);
 
477
                messageDestroy(m);
 
478
*** /home/njh/src/clamav-devel/./libclamav/message.h    2007-02-10 17:13:33.000000000 +0000
 
479
--- ./libclamav/message.h       2006-10-19 19:54:14.000000000 +0100
 
480
***************
 
481
*** 57,63 ****
 
482
  const char    *messageGetDispositionType(const message *m);
 
483
  void  messageAddArgument(message *m, const char *arg);
 
484
  void  messageAddArguments(message *m, const char *arg);
 
485
! char  *messageFindArgument(const message *m, const char *variable);
 
486
  void  messageSetEncoding(message *m, const char *enctype);
 
487
  encoding_type messageGetEncoding(const message *m);
 
488
  int   messageAddLine(message *m, line_t *line);
 
489
--- 57,63 ----
 
490
  const char    *messageGetDispositionType(const message *m);
 
491
  void  messageAddArgument(message *m, const char *arg);
 
492
  void  messageAddArguments(message *m, const char *arg);
 
493
! const char    *messageFindArgument(const message *m, const char *variable);
 
494
  void  messageSetEncoding(message *m, const char *enctype);
 
495
  encoding_type messageGetEncoding(const message *m);
 
496
  int   messageAddLine(message *m, line_t *line);
 
497
*** /home/njh/src/clamav-devel/./libclamav/untar.c      2007-02-10 21:05:37.000000000 +0000
 
498
--- ./libclamav/untar.c 2007-02-10 14:22:00.000000000 +0000
 
499
***************
 
500
*** 223,232 ****
 
501
  
 
502
                        if(fd < 0) {
 
503
                                cli_errmsg("Can't create temporary file %s: %s\n", fullname, strerror(errno));
 
504
!                               cli_dbgmsg("%lu %lu %lu\n",
 
505
!                                       (unsigned long)suffixLen,
 
506
!                                       (unsigned long)sizeof(fullname),
 
507
!                                       (unsigned long)strlen(fullname));
 
508
                                return CL_ETMPFILE;
 
509
                        }
 
510
  
 
511
--- 223,229 ----
 
512
  
 
513
                        if(fd < 0) {
 
514
                                cli_errmsg("Can't create temporary file %s: %s\n", fullname, strerror(errno));
 
515
!                               cli_dbgmsg("%u %d %d\n", suffixLen, sizeof(fullname), strlen(fullname));
 
516
                                return CL_ETMPFILE;
 
517
                        }
 
518
  
 
519
*** /home/njh/src/clamav-devel/./libclamav/untar.h      2006-12-22 18:29:13.000000000 +0000
 
520
--- ./libclamav/untar.h 2006-11-24 22:28:32.000000000 +0000
 
521
***************
 
522
*** 18,26 ****
 
523
   *
 
524
   * Change History:
 
525
   * $Log: patches,v $
 
526
   * Revision 1.16  2007/02/12 15:41:19  njh
 
527
   * Latest diffs from the W32 fork
 
528
   *
 
529
-  * Revision 1.5  2006/12/22 18:29:13  njh
 
530
-  * Recommit fix for bug 153
 
531
-  *
 
532
   * Revision 1.4  2006/04/09 19:59:28  kojm
 
533
   * update GPL headers with new address for FSF
 
534
   *
 
535
--- 18,23 ----
 
536
***************
 
537
*** 34,37 ****
 
538
   * First draft
 
539
   *
 
540
   */
 
541
! int cli_untar(const char *dir, int desc, unsigned int posix, const struct cl_limits *limits);
 
542
--- 31,34 ----
 
543
   * First draft
 
544
   *
 
545
   */
 
546
! int cli_untar(const char *dir, int desc, unsigned int posix);
 
547
*** /home/njh/src/clamav-devel/./libclamav/pst.c        2007-01-30 10:31:14.000000000 +0000
 
548
--- ./libclamav/pst.c   2007-01-05 14:45:18.000000000 +0000
 
549
***************
 
550
*** 429,435 ****
 
551
  pst_item* _pst_getItem(pst_file *pf, pst_desc_ll *d_ptr);
 
552
  static        void    *_pst_parse_item (pst_file *pf, pst_desc_ll *d_ptr);
 
553
  static        pst_num_array   *_pst_parse_block(pst_file *pf, u_int32_t block_id, pst_index2_ll *i2_head);
 
554
! static        int32_t _pst_process(pst_num_array *list, pst_item *item);
 
555
  int32_t _pst_free_list(pst_num_array *list);
 
556
  void _pst_freeItem(pst_item *item);
 
557
  int32_t _pst_free_id2(pst_index2_ll * head);
 
558
--- 429,435 ----
 
559
  pst_item* _pst_getItem(pst_file *pf, pst_desc_ll *d_ptr);
 
560
  static        void    *_pst_parse_item (pst_file *pf, pst_desc_ll *d_ptr);
 
561
  static        pst_num_array   *_pst_parse_block(pst_file *pf, u_int32_t block_id, pst_index2_ll *i2_head);
 
562
! int32_t _pst_process(pst_num_array *list, pst_item *item);
 
563
  int32_t _pst_free_list(pst_num_array *list);
 
564
  void _pst_freeItem(pst_item *item);
 
565
  int32_t _pst_free_id2(pst_index2_ll * head);
 
566
***************
 
567
*** 814,820 ****
 
568
  pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE *fp)
 
569
  {
 
570
        pst_index_ll *ptr;
 
571
!       int32_t size = 0;
 
572
        char *c;
 
573
  
 
574
        if (attach->id_val != -1) {
 
575
--- 814,820 ----
 
576
  pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE *fp)
 
577
  {
 
578
        pst_index_ll *ptr;
 
579
!       int32_t size;
 
580
        char *c;
 
581
  
 
582
        if (attach->id_val != -1) {
 
583
***************
 
584
*** 899,908 ****
 
585
    // for PST files this will load up ID2 0x61 and check it's "list" attribute.
 
586
    pst_desc_ll *p;
 
587
    pst_num_array *na;
 
588
!   pst_index2_ll *list2 = NULL;
 
589
    unsigned char * buffer=NULL, *headerbuffer=NULL;
 
590
    pst_x_attrib xattrib;
 
591
!   int32_t bptr = 0, bsize = 0, hsize, tint, err=0, x;
 
592
    pst_x_attrib_ll *ptr, *p_head=NULL, *p_sh=NULL, *p_sh2=NULL;
 
593
  
 
594
    if ((p = _pst_getDptr(pf, 0x61)) == NULL) {
 
595
--- 899,908 ----
 
596
    // for PST files this will load up ID2 0x61 and check it's "list" attribute.
 
597
    pst_desc_ll *p;
 
598
    pst_num_array *na;
 
599
!   pst_index2_ll *list2;
 
600
    unsigned char * buffer=NULL, *headerbuffer=NULL;
 
601
    pst_x_attrib xattrib;
 
602
!   int32_t bptr = 0, bsize, hsize, tint, err=0, x;
 
603
    pst_x_attrib_ll *ptr, *p_head=NULL, *p_sh=NULL, *p_sh2=NULL;
 
604
  
 
605
    if ((p = _pst_getDptr(pf, 0x61)) == NULL) {
 
606
***************
 
607
*** 1963,1971 ****
 
608
            cli_dbgmsg("not able to read the ID2 data. Setting to be read later. %#x\n",
 
609
                  table_rec.value);
 
610
            na_ptr->items[x]->size = 0;
 
611
-           na_ptr->items[x]->type = table_rec.value;
 
612
-           free(na_ptr->items[x]->data);
 
613
            na_ptr->items[x]->data = NULL;
 
614
          }
 
615
          cli_dbgmsg("Read %i bytes to a buffer at %p\n",
 
616
                na_ptr->items[x]->size, na_ptr->items[x]->data);
 
617
--- 1963,1970 ----
 
618
            cli_dbgmsg("not able to read the ID2 data. Setting to be read later. %#x\n",
 
619
                  table_rec.value);
 
620
            na_ptr->items[x]->size = 0;
 
621
            na_ptr->items[x]->data = NULL;
 
622
+           na_ptr->items[x]->type = table_rec.value;
 
623
          }
 
624
          cli_dbgmsg("Read %i bytes to a buffer at %p\n",
 
625
                na_ptr->items[x]->size, na_ptr->items[x]->data);
 
626
***************
 
627
*** 2037,2043 ****
 
628
          na_ptr->items[x]->type = table_rec.ref_type;
 
629
        } else {
 
630
        cli_warnmsg("ERROR Unknown ref_type %#x\n", table_rec.ref_type);
 
631
-       if(buf) free(buf);
 
632
        if(na_head)
 
633
        _pst_free_list(na_head);
 
634
        return NULL;
 
635
--- 2036,2041 ----
 
636
***************
 
637
*** 2090,2099 ****
 
638
    }\
 
639
  }
 
640
  
 
641
! static int32_t
 
642
! _pst_process(pst_num_array *list , pst_item *item)
 
643
! {
 
644
!   int32_t x, t;
 
645
    int32_t next = 0;
 
646
    pst_item_attach *attach;
 
647
    pst_item_extra_field *ef;
 
648
--- 2088,2095 ----
 
649
    }\
 
650
  }
 
651
  
 
652
! int32_t _pst_process(pst_num_array *list , pst_item *item) {
 
653
!   int32_t x;
 
654
    int32_t next = 0;
 
655
    pst_item_attach *attach;
 
656
    pst_item_extra_field *ef;
 
657
***************
 
658
*** 2589,2597 ****
 
659
        cli_dbgmsg("Attachment Size - ");
 
660
        NULL_CHECK(attach);
 
661
        MOVE_NEXT(attach);
 
662
!       t = (*(int32_t *)list->items[x]->data);
 
663
!       LE32_CPU(t);
 
664
!       attach->size = t;
 
665
        cli_dbgmsg("%i\n", attach->size);
 
666
        //INC_CHECK_X();
 
667
        break;
 
668
--- 2585,2591 ----
 
669
        cli_dbgmsg("Attachment Size - ");
 
670
        NULL_CHECK(attach);
 
671
        MOVE_NEXT(attach);
 
672
!       memcpy(&(attach->size), list->items[x]->data, sizeof(attach->size));
 
673
        cli_dbgmsg("%i\n", attach->size);
 
674
        //INC_CHECK_X();
 
675
        break;
 
676
***************
 
677
*** 3756,3765 ****
 
678
    pst_num_array *l;
 
679
    while (list != NULL) {
 
680
      while (x < list->count_item) {
 
681
!       if (list->items[x] != NULL) {
 
682
!       if (list->items[x]->data != NULL) {
 
683
        free (list->items[x]->data);
 
684
!       }
 
685
        free (list->items[x]);
 
686
        }
 
687
        x++;
 
688
--- 3750,3759 ----
 
689
    pst_num_array *l;
 
690
    while (list != NULL) {
 
691
      while (x < list->count_item) {
 
692
!       if (list->items[x]->data != NULL) {
 
693
        free (list->items[x]->data);
 
694
!       }
 
695
!       if (list->items[x] != NULL) {
 
696
        free (list->items[x]);
 
697
        }
 
698
        x++;
 
699
***************
 
700
*** 5386,5392 ****
 
701
          if ((temp = item->email->outlook_sender) == NULL)
 
702
            temp = (char *)"";
 
703
          fprintf(f->output, "From: \"%s\" <%s>\n", item->email->outlook_sender_name, temp);
 
704
!         if ((item->email->subject != NULL) && (item->email->subject->subj != NULL)) {
 
705
            fprintf(f->output, "Subject: %s\n", item->email->subject->subj);
 
706
          } /*else
 
707
            fprintf(f->output, "Subject: \n");*/
 
708
--- 5380,5386 ----
 
709
          if ((temp = item->email->outlook_sender) == NULL)
 
710
            temp = (char *)"";
 
711
          fprintf(f->output, "From: \"%s\" <%s>\n", item->email->outlook_sender_name, temp);
 
712
!         if (item->email->subject != NULL) {
 
713
            fprintf(f->output, "Subject: %s\n", item->email->subject->subj);
 
714
          } /*else
 
715
            fprintf(f->output, "Subject: \n");*/
 
716
*** /home/njh/src/clamav-devel/./libclamav/line.c       2007-02-10 17:15:14.000000000 +0000
 
717
--- ./libclamav/line.c  2006-10-19 19:54:12.000000000 +0100
 
718
***************
 
719
*** 110,118 ****
 
720
  {
 
721
        return line ? line->l_str : NULL;
 
722
  }
 
723
 
724
  #else
 
725
 
726
  line_t *
 
727
  lineCreate(const char *data)
 
728
  {
 
729
--- 110,116 ----
 
730
*** /home/njh/src/clamav-devel/./libclamav/text.c       2007-02-10 21:14:39.000000000 +0000
 
731
--- ./libclamav/text.c  2006-10-19 19:54:14.000000000 +0100
 
732
***************
 
733
*** 349,357 ****
 
734
        if(line) {
 
735
                const char *l = lineGetData(line);
 
736
  
 
737
!               blobAddData(b, (const unsigned char *)l, strlen(l));
 
738
        }
 
739
!       blobAddData(b, (const unsigned char *)"\n", 1);
 
740
  }
 
741
  
 
742
  static void
 
743
--- 349,357 ----
 
744
        if(line) {
 
745
                const char *l = lineGetData(line);
 
746
  
 
747
!               blobAddData(b, (unsigned char *)l, strlen(l));
 
748
        }
 
749
!       blobAddData(b, (unsigned char *)"\n", 1);
 
750
  }
 
751
  
 
752
  static void
 
753
***************
 
754
*** 362,370 ****
 
755
        if(line) {
 
756
                const char *l = lineGetData(line);
 
757
  
 
758
!               fileblobAddData(fb, (const unsigned char *)l, strlen(l));
 
759
        }
 
760
!       fileblobAddData(fb, (const unsigned char *)"\n", 1);
 
761
  }
 
762
  
 
763
  static void *
 
764
--- 362,370 ----
 
765
        if(line) {
 
766
                const char *l = lineGetData(line);
 
767
  
 
768
!               fileblobAddData(fb, (unsigned char *)l, strlen(l));
 
769
        }
 
770
!       fileblobAddData(fb, (unsigned char *)"\n", 1);
 
771
  }
 
772
  
 
773
  static void *
 
774
*** /home/njh/src/clamav-devel/./libclamav/js/alloc.c   2006-10-28 12:33:45.000000000 +0100
 
775
--- ./libclamav/js/alloc.c      2006-10-21 14:58:34.000000000 +0100
 
776
***************
 
777
*** 22,36 ****
 
778
   * MA 02111-1307, USA
 
779
   */
 
780
  
 
781
- #if HAVE_CONFIG_H
 
782
- #include "clamav-config.h"
 
783
- #endif
 
784
 
785
- #ifdef        CL_EXPERIMENTAL
 
786
 
787
  /*
 
788
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
789
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
790
   */
 
791
  
 
792
  #include "js/jsint.h"
 
793
--- 22,30 ----
 
794
   * MA 02111-1307, USA
 
795
   */
 
796
  
 
797
  /*
 
798
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
799
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
800
   */
 
801
  
 
802
  #include "js/jsint.h"
 
803
***************
 
804
*** 315,318 ****
 
805
  }
 
806
  
 
807
  #endif /* not JS_DEBUG_MEMORY_LEAKS */
 
808
- #endif        /*CL_EXPERIMENTAL*/
 
809
--- 309,311 ----
 
810
*** /home/njh/src/clamav-devel/./libclamav/js/b_array.c 2006-10-28 12:33:45.000000000 +0100
 
811
--- ./libclamav/js/b_array.c    2006-10-21 14:58:34.000000000 +0100
 
812
***************
 
813
*** 24,30 ****
 
814
  
 
815
  /*
 
816
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
817
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
818
   */
 
819
  
 
820
  /*
 
821
--- 24,30 ----
 
822
  
 
823
  /*
 
824
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
825
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
826
   */
 
827
  
 
828
  /*
 
829
***************
 
830
*** 47,58 ****
 
831
   *   length
 
832
   */
 
833
  
 
834
- #if HAVE_CONFIG_H
 
835
- #include "clamav-config.h"
 
836
- #endif
 
837
 
838
- #ifdef        CL_EXPERIMENTAL
 
839
 
840
  #include "jsint.h"
 
841
  #include "mrgsort.h"
 
842
  
 
843
--- 47,52 ----
 
844
***************
 
845
*** 654,657 ****
 
846
    n = &vm->globals[js_vm_intern (vm, "Array")];
 
847
    js_vm_builtin_create (vm, n, info, NULL);
 
848
  }
 
849
- #endif        /*CL_EXPERIMENTAL*/
 
850
--- 648,650 ----
 
851
*** /home/njh/src/clamav-devel/./libclamav/js/b_bool.c  2006-10-28 12:33:45.000000000 +0100
 
852
--- ./libclamav/js/b_bool.c     2006-10-21 14:58:34.000000000 +0100
 
853
***************
 
854
*** 24,38 ****
 
855
  
 
856
  /*
 
857
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
858
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
859
   */
 
860
  
 
861
- #if HAVE_CONFIG_H
 
862
- #include "clamav-config.h"
 
863
- #endif
 
864
 
865
- #ifdef        CL_EXPERIMENTAL
 
866
 
867
  #include "jsint.h"
 
868
  
 
869
  /*
 
870
--- 24,32 ----
 
871
  
 
872
  /*
 
873
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
874
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
875
   */
 
876
  
 
877
  #include "jsint.h"
 
878
  
 
879
  /*
 
880
***************
 
881
*** 157,160 ****
 
882
    n = &vm->globals[js_vm_intern (vm, "Boolean")];
 
883
    js_vm_builtin_create (vm, n, info, NULL);
 
884
  }
 
885
- #endif        /*CL_EXPERIMENTAL*/
 
886
--- 151,153 ----
 
887
*** /home/njh/src/clamav-devel/./libclamav/js/bc.c      2006-10-28 12:33:45.000000000 +0100
 
888
--- ./libclamav/js/bc.c 2006-10-21 14:58:34.000000000 +0100
 
889
***************
 
890
*** 24,36 ****
 
891
  
 
892
  /*
 
893
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
894
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
895
   */
 
896
- #if HAVE_CONFIG_H
 
897
- #include "clamav-config.h"
 
898
- #endif
 
899
 
900
- #ifdef        CL_EXPERIMENTAL
 
901
  
 
902
  #include "jsint.h"
 
903
  
 
904
--- 24,31 ----
 
905
  
 
906
  /*
 
907
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
908
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
909
   */
 
910
  
 
911
  #include "jsint.h"
 
912
  
 
913
***************
 
914
*** 227,230 ****
 
915
    js_free (bc->sects);
 
916
    js_free (bc);
 
917
  }
 
918
- #endif        /*CL_EXPERIMENTAL*/
 
919
--- 222,224 ----
 
920
*** /home/njh/src/clamav-devel/./libclamav/js/b_core.c  2006-10-28 12:33:45.000000000 +0100
 
921
--- ./libclamav/js/b_core.c     2006-10-21 14:58:34.000000000 +0100
 
922
***************
 
923
*** 24,30 ****
 
924
  
 
925
  /*
 
926
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
927
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
928
   */
 
929
  
 
930
  /*
 
931
--- 24,30 ----
 
932
  
 
933
  /*
 
934
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
935
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
936
   */
 
937
  
 
938
  /*
 
939
***************
 
940
*** 44,54 ****
 
941
   *  isInt (any)
 
942
   *  print (any[,...])
 
943
   */
 
944
- #if HAVE_CONFIG_H
 
945
- #include "clamav-config.h"
 
946
- #endif
 
947
 
948
- #ifdef        CL_EXPERIMENTAL
 
949
  
 
950
  #include "jsint.h"
 
951
  
 
952
--- 44,49 ----
 
953
***************
 
954
*** 662,665 ****
 
955
        js_vm_builtin_create (vm, n, info, NULL);
 
956
      }
 
957
  }
 
958
- #endif        /*CL_EXPERIMENTAL*/
 
959
--- 657,659 ----
 
960
*** /home/njh/src/clamav-devel/./libclamav/js/b_date.c  2006-10-28 12:33:45.000000000 +0100
 
961
--- ./libclamav/js/b_date.c     2006-10-21 14:58:34.000000000 +0100
 
962
***************
 
963
*** 24,36 ****
 
964
  
 
965
  /*
 
966
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
967
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
968
   */
 
969
- #if HAVE_CONFIG_H
 
970
- #include "clamav-config.h"
 
971
- #endif
 
972
 
973
- #ifdef        CL_EXPERIMENTAL
 
974
  
 
975
  #include "jsint.h"
 
976
  #include "rentrant.h"
 
977
--- 24,31 ----
 
978
  
 
979
  /*
 
980
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
981
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
982
   */
 
983
  
 
984
  #include "jsint.h"
 
985
  #include "rentrant.h"
 
986
***************
 
987
*** 795,798 ****
 
988
        js_vm_builtin_create (vm, n, info, NULL);
 
989
      }
 
990
  }
 
991
- #endif        /*CL_EXPERIMENTAL*/
 
992
--- 790,792 ----
 
993
*** /home/njh/src/clamav-devel/./libclamav/js/b_dir.c   2006-10-28 12:33:45.000000000 +0100
 
994
--- ./libclamav/js/b_dir.c      2006-10-21 14:58:34.000000000 +0100
 
995
***************
 
996
*** 24,36 ****
 
997
  
 
998
  /*
 
999
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1000
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1001
   */
 
1002
- #if HAVE_CONFIG_H
 
1003
- #include "clamav-config.h"
 
1004
- #endif
 
1005
 
1006
- #ifdef        CL_EXPERIMENTAL
 
1007
  
 
1008
  #include "jsint.h"
 
1009
  
 
1010
--- 24,31 ----
 
1011
  
 
1012
  /*
 
1013
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1014
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1015
   */
 
1016
  
 
1017
  #include "jsint.h"
 
1018
  
 
1019
***************
 
1020
*** 322,325 ****
 
1021
    n = &vm->globals[js_vm_intern (vm, "Directory")];
 
1022
    js_vm_builtin_create (vm, n, info, NULL);
 
1023
  }
 
1024
- #endif        /*CL_EXPERIMENTAL*/
 
1025
--- 317,319 ----
 
1026
*** /home/njh/src/clamav-devel/./libclamav/js/b_file.c  2006-10-28 12:33:45.000000000 +0100
 
1027
--- ./libclamav/js/b_file.c     2006-10-21 14:58:34.000000000 +0100
 
1028
***************
 
1029
*** 24,30 ****
 
1030
  
 
1031
  /*
 
1032
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1033
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1034
   */
 
1035
  
 
1036
  /*
 
1037
--- 24,30 ----
 
1038
  
 
1039
  /*
 
1040
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1041
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1042
   */
 
1043
  
 
1044
  /*
 
1045
***************
 
1046
*** 63,73 ****
 
1047
   *   autoFlush        boolean         mutable
 
1048
   *   bufferSize       integer         mutable
 
1049
   */
 
1050
- #if HAVE_CONFIG_H
 
1051
- #include "clamav-config.h"
 
1052
- #endif
 
1053
 
1054
- #ifdef        CL_EXPERIMENTAL
 
1055
  
 
1056
  #include "jsint.h"
 
1057
  
 
1058
--- 63,68 ----
 
1059
***************
 
1060
*** 1015,1018 ****
 
1061
    /* Create the builtin. */
 
1062
    js_vm_builtin_create (vm, result_return, n->u.vbuiltin->info, ictx);
 
1063
  }
 
1064
- #endif        /*CL_EXPERIMENTAL*/
 
1065
--- 1010,1012 ----
 
1066
*** /home/njh/src/clamav-devel/./libclamav/js/b_func.c  2006-10-28 12:33:45.000000000 +0100
 
1067
--- ./libclamav/js/b_func.c     2006-10-21 14:58:34.000000000 +0100
 
1068
***************
 
1069
*** 24,36 ****
 
1070
  
 
1071
  /*
 
1072
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1073
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1074
   */
 
1075
- #if HAVE_CONFIG_H
 
1076
- #include "clamav-config.h"
 
1077
- #endif
 
1078
 
1079
- #ifdef        CL_EXPERIMENTAL
 
1080
  
 
1081
  #include "jsint.h"
 
1082
  
 
1083
--- 24,31 ----
 
1084
  
 
1085
  /*
 
1086
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1087
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1088
   */
 
1089
  
 
1090
  #include "jsint.h"
 
1091
  
 
1092
***************
 
1093
*** 81,84 ****
 
1094
    n = &vm->globals[js_vm_intern (vm, "Function")];
 
1095
    js_vm_builtin_create (vm, n, info, NULL);
 
1096
  }
 
1097
- #endif        /*CL_EXPERIMENTAL*/
 
1098
--- 76,78 ----
 
1099
*** /home/njh/src/clamav-devel/./libclamav/js/b_math.c  2006-10-28 12:33:45.000000000 +0100
 
1100
--- ./libclamav/js/b_math.c     2006-10-21 14:58:34.000000000 +0100
 
1101
***************
 
1102
*** 24,36 ****
 
1103
  
 
1104
  /*
 
1105
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1106
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1107
   */
 
1108
- #if HAVE_CONFIG_H
 
1109
- #include "clamav-config.h"
 
1110
- #endif
 
1111
 
1112
- #ifdef        CL_EXPERIMENTAL
 
1113
  
 
1114
  #include "jsint.h"
 
1115
  #include "rentrant.h"
 
1116
--- 24,31 ----
 
1117
  
 
1118
  /*
 
1119
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1120
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1121
   */
 
1122
  
 
1123
  #include "jsint.h"
 
1124
  #include "rentrant.h"
 
1125
***************
 
1126
*** 514,517 ****
 
1127
    n = &vm->globals[js_vm_intern (vm, "Math")];
 
1128
    js_vm_builtin_create (vm, n, info, NULL);
 
1129
  }
 
1130
- #endif        /*CL_EXPERIMENTAL*/
 
1131
--- 509,511 ----
 
1132
*** /home/njh/src/clamav-devel/./libclamav/js/b_number.c        2006-10-28 12:33:45.000000000 +0100
 
1133
--- ./libclamav/js/b_number.c   2006-10-21 14:58:34.000000000 +0100
 
1134
***************
 
1135
*** 24,40 ****
 
1136
  
 
1137
  /*
 
1138
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1139
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1140
   */
 
1141
  
 
1142
  /*
 
1143
   * Standard: ECMAScript-2.0.draft-22-Apr-98
 
1144
   */
 
1145
- #if HAVE_CONFIG_H
 
1146
- #include "clamav-config.h"
 
1147
- #endif
 
1148
 
1149
- #ifdef        CL_EXPERIMENTAL
 
1150
  
 
1151
  #include "jsint.h"
 
1152
  
 
1153
--- 24,35 ----
 
1154
  
 
1155
  /*
 
1156
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1157
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1158
   */
 
1159
  
 
1160
  /*
 
1161
   * Standard: ECMAScript-2.0.draft-22-Apr-98
 
1162
   */
 
1163
  
 
1164
  #include "jsint.h"
 
1165
  
 
1166
***************
 
1167
*** 323,326 ****
 
1168
    n = &vm->globals[js_vm_intern (vm, "Number")];
 
1169
    js_vm_builtin_create (vm, n, info, NULL);
 
1170
  }
 
1171
- #endif        /*CL_EXPERIMENTAL*/
 
1172
--- 318,320 ----
 
1173
*** /home/njh/src/clamav-devel/./libclamav/js/b_object.c        2006-10-28 12:33:45.000000000 +0100
 
1174
--- ./libclamav/js/b_object.c   2006-10-21 14:58:34.000000000 +0100
 
1175
***************
 
1176
*** 24,36 ****
 
1177
  
 
1178
  /*
 
1179
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1180
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1181
   */
 
1182
- #if HAVE_CONFIG_H
 
1183
- #include "clamav-config.h"
 
1184
- #endif
 
1185
 
1186
- #ifdef        CL_EXPERIMENTAL
 
1187
  
 
1188
  #include "jsint.h"
 
1189
  
 
1190
--- 24,31 ----
 
1191
  
 
1192
  /*
 
1193
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1194
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1195
   */
 
1196
  
 
1197
  #include "jsint.h"
 
1198
  
 
1199
***************
 
1200
*** 198,201 ****
 
1201
    n = &vm->globals[js_vm_intern (vm, "Object")];
 
1202
    js_vm_builtin_create (vm, n, info, NULL);
 
1203
  }
 
1204
- #endif        /*CL_EXPERIMENTAL*/
 
1205
--- 193,195 ----
 
1206
*** /home/njh/src/clamav-devel/./libclamav/js/b_regexp.c        2006-10-28 12:33:45.000000000 +0100
 
1207
--- ./libclamav/js/b_regexp.c   2006-10-21 14:58:34.000000000 +0100
 
1208
***************
 
1209
*** 24,36 ****
 
1210
  
 
1211
  /*
 
1212
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1213
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1214
   */
 
1215
- #if HAVE_CONFIG_H
 
1216
- #include "clamav-config.h"
 
1217
- #endif
 
1218
 
1219
- #ifdef        CL_EXPERIMENTAL
 
1220
  
 
1221
  #include "jsint.h"
 
1222
  #include "regex.h"
 
1223
--- 24,31 ----
 
1224
  
 
1225
  /*
 
1226
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1227
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1228
   */
 
1229
  
 
1230
  #include "jsint.h"
 
1231
  #include "regex.h"
 
1232
***************
 
1233
*** 1139,1142 ****
 
1234
    if (regs.end)
 
1235
      free (regs.end);
 
1236
  }
 
1237
- #endif        /*CL_EXPERIMENTAL*/
 
1238
--- 1134,1136 ----
 
1239
*** /home/njh/src/clamav-devel/./libclamav/js/b_string.c        2006-10-28 12:33:45.000000000 +0100
 
1240
--- ./libclamav/js/b_string.c   2006-10-21 14:58:34.000000000 +0100
 
1241
***************
 
1242
*** 24,38 ****
 
1243
  
 
1244
  /*
 
1245
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1246
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1247
   */
 
1248
  
 
1249
  /* TODO: global method: String (obj) => string */
 
1250
- #if HAVE_CONFIG_H
 
1251
- #include "clamav-config.h"
 
1252
- #endif
 
1253
 
1254
- #ifdef        CL_EXPERIMENTAL
 
1255
  
 
1256
  #include "jsint.h"
 
1257
  
 
1258
--- 24,33 ----
 
1259
  
 
1260
  /*
 
1261
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1262
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1263
   */
 
1264
  
 
1265
  /* TODO: global method: String (obj) => string */
 
1266
  
 
1267
  #include "jsint.h"
 
1268
  
 
1269
***************
 
1270
*** 940,943 ****
 
1271
    n = &vm->globals[js_vm_intern (vm, "RegExp")];
 
1272
    ctx->regexp_info = n->u.vbuiltin->info;
 
1273
  }
 
1274
- #endif        /*CL_EXPERIMENTAL*/
 
1275
--- 935,937 ----
 
1276
*** /home/njh/src/clamav-devel/./libclamav/js/b_vm.c    2006-10-28 12:33:45.000000000 +0100
 
1277
--- ./libclamav/js/b_vm.c       2006-10-21 14:58:34.000000000 +0100
 
1278
***************
 
1279
*** 24,30 ****
 
1280
  
 
1281
  /*
 
1282
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1283
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1284
   */
 
1285
  
 
1286
  /*
 
1287
--- 24,30 ----
 
1288
  
 
1289
  /*
 
1290
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1291
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1292
   */
 
1293
  
 
1294
  /*
 
1295
***************
 
1296
*** 56,66 ****
 
1297
   *   VM.versionPatch          integer
 
1298
   *   VM.warnUndef             boolean         yes
 
1299
   */
 
1300
- #if HAVE_CONFIG_H
 
1301
- #include "clamav-config.h"
 
1302
- #endif
 
1303
 
1304
- #ifdef        CL_EXPERIMENTAL
 
1305
  
 
1306
  #include "jsint.h"
 
1307
  
 
1308
--- 56,61 ----
 
1309
***************
 
1310
*** 448,451 ****
 
1311
    n = &vm->globals[js_vm_intern (vm, "VM")];
 
1312
    js_vm_builtin_create (vm, n, info, NULL);
 
1313
  }
 
1314
- #endif        /*CL_EXPERIMENTAL*/
 
1315
--- 443,445 ----
 
1316
*** /home/njh/src/clamav-devel/./libclamav/js/compiler.c        2006-10-28 12:33:45.000000000 +0100
 
1317
--- ./libclamav/js/compiler.c   2006-10-21 14:58:34.000000000 +0100
 
1318
***************
 
1319
*** 1,8 ****
 
1320
- #if HAVE_CONFIG_H
 
1321
- #include "clamav-config.h"
 
1322
- #endif
 
1323
 
1324
- #ifdef        CL_EXPERIMENTAL
 
1325
  const unsigned char js_compiler_bytecode[] = {
 
1326
    0xc0, 0x01, 0x4a, 0x53, 0x00, 0x00, 0x00, 0x03,
 
1327
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0x54,
 
1328
--- 1,3 ----
 
1329
***************
 
1330
*** 11201,11204 ****
 
1331
  };
 
1332
  unsigned int js_compiler_bytecode_len = 89552;
 
1333
  #define JS_COMPILER_BYTECODE_LEN 89552
 
1334
- #endif        /*CL_EXPERIMENTAL*/
 
1335
--- 11196,11198 ----
 
1336
*** /home/njh/src/clamav-devel/./libclamav/js/heap.c    2006-10-28 12:33:45.000000000 +0100
 
1337
--- ./libclamav/js/heap.c       2006-10-21 14:58:34.000000000 +0100
 
1338
***************
 
1339
*** 24,36 ****
 
1340
  
 
1341
  /*
 
1342
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1343
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1344
   */
 
1345
- #if HAVE_CONFIG_H
 
1346
- #include "clamav-config.h"
 
1347
- #endif
 
1348
 
1349
- #ifdef        CL_EXPERIMENTAL
 
1350
  
 
1351
  #include "jsint.h"
 
1352
  
 
1353
--- 24,31 ----
 
1354
  
 
1355
  /*
 
1356
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1357
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1358
   */
 
1359
  
 
1360
  #include "jsint.h"
 
1361
  
 
1362
***************
 
1363
*** 589,592 ****
 
1364
    /* Just sweep without marking. */
 
1365
    sweep (vm);
 
1366
  }
 
1367
- #endif        /*CL_EXPERIMENTAL*/
 
1368
--- 584,586 ----
 
1369
*** /home/njh/src/clamav-devel/./libclamav/js/iostream.c        2006-10-28 12:33:45.000000000 +0100
 
1370
--- ./libclamav/js/iostream.c   2006-10-21 14:58:34.000000000 +0100
 
1371
***************
 
1372
*** 24,36 ****
 
1373
  
 
1374
  /*
 
1375
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1376
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1377
   */
 
1378
- #if HAVE_CONFIG_H
 
1379
- #include "clamav-config.h"
 
1380
- #endif
 
1381
 
1382
- #ifdef        CL_EXPERIMENTAL
 
1383
  
 
1384
  #include "jsint.h"
 
1385
  
 
1386
--- 24,31 ----
 
1387
  
 
1388
  /*
 
1389
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1390
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1391
   */
 
1392
  
 
1393
  #include "jsint.h"
 
1394
  
 
1395
***************
 
1396
*** 476,479 ****
 
1397
    if (stream->data_in_buf == 0)
 
1398
      stream->at_eof = 1;
 
1399
  }
 
1400
- #endif        /*CL_EXPERIMENTAL*/
 
1401
--- 471,473 ----
 
1402
*** /home/njh/src/clamav-devel/./libclamav/js/js.c      2006-10-28 12:33:45.000000000 +0100
 
1403
--- ./libclamav/js/js.c 2006-10-21 14:58:34.000000000 +0100
 
1404
***************
 
1405
*** 24,36 ****
 
1406
  
 
1407
  /*
 
1408
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1409
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1410
   */
 
1411
- #if HAVE_CONFIG_H
 
1412
- #include "clamav-config.h"
 
1413
- #endif
 
1414
 
1415
- #ifdef        CL_EXPERIMENTAL
 
1416
  
 
1417
  #include "js/js.h"
 
1418
  #include "js/jsint.h"
 
1419
--- 24,31 ----
 
1420
  
 
1421
  /*
 
1422
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1423
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1424
   */
 
1425
  
 
1426
  #include "js/js.h"
 
1427
  #include "js/jsint.h"
 
1428
***************
 
1429
*** 1687,1690 ****
 
1430
  
 
1431
    return stream;
 
1432
  }
 
1433
- #endif        /*CL_EXPERIMENTAL*/
 
1434
--- 1682,1684 ----
 
1435
*** /home/njh/src/clamav-devel/./libclamav/js/object.c  2006-10-28 12:33:45.000000000 +0100
 
1436
--- ./libclamav/js/object.c     2006-10-21 14:58:34.000000000 +0100
 
1437
***************
 
1438
*** 24,36 ****
 
1439
  
 
1440
  /*
 
1441
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1442
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1443
   */
 
1444
- #if HAVE_CONFIG_H
 
1445
- #include "clamav-config.h"
 
1446
- #endif
 
1447
 
1448
- #ifdef        CL_EXPERIMENTAL
 
1449
  
 
1450
  #include "jsint.h"
 
1451
  
 
1452
--- 24,31 ----
 
1453
  
 
1454
  /*
 
1455
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1456
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1457
   */
 
1458
  
 
1459
  #include "jsint.h"
 
1460
  
 
1461
***************
 
1462
*** 538,541 ****
 
1463
  
 
1464
    return -1;
 
1465
  }
 
1466
- #endif        /*CL_EXPERIMENTAL*/
 
1467
--- 533,535 ----
 
1468
*** /home/njh/src/clamav-devel/./libclamav/js/r_pthrs.c 2006-10-28 12:33:45.000000000 +0100
 
1469
--- ./libclamav/js/r_pthrs.c    2006-10-21 14:58:34.000000000 +0100
 
1470
***************
 
1471
*** 24,36 ****
 
1472
  
 
1473
  /*
 
1474
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1475
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1476
   */
 
1477
- #if HAVE_CONFIG_H
 
1478
- #include "clamav-config.h"
 
1479
- #endif
 
1480
 
1481
- #ifdef        CL_EXPERIMENTAL
 
1482
  
 
1483
  #include "jsint.h"
 
1484
  #include "rentrant.h"
 
1485
--- 24,31 ----
 
1486
  
 
1487
  /*
 
1488
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1489
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1490
   */
 
1491
  
 
1492
  #include "jsint.h"
 
1493
  #include "rentrant.h"
 
1494
***************
 
1495
*** 132,135 ****
 
1496
  }
 
1497
  
 
1498
  #endif /* not DRAND48_R_WITH_DRAND48D */
 
1499
- #endif        /*CL_EXPERIMENTAL*/
 
1500
--- 127,129 ----
 
1501
*** /home/njh/src/clamav-devel/./libclamav/js/utils.c   2006-10-28 12:33:45.000000000 +0100
 
1502
--- ./libclamav/js/utils.c      2006-10-21 14:58:34.000000000 +0100
 
1503
***************
 
1504
*** 24,36 ****
 
1505
  
 
1506
  /*
 
1507
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1508
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1509
   */
 
1510
- #if HAVE_CONFIG_H
 
1511
- #include "clamav-config.h"
 
1512
- #endif
 
1513
 
1514
- #ifdef        CL_EXPERIMENTAL
 
1515
  
 
1516
  #include "jsint.h"
 
1517
  
 
1518
--- 24,31 ----
 
1519
  
 
1520
  /*
 
1521
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1522
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1523
   */
 
1524
  
 
1525
  #include "jsint.h"
 
1526
  
 
1527
***************
 
1528
*** 442,445 ****
 
1529
  
 
1530
    return result;
 
1531
  }
 
1532
- #endif        /*CL_EXPERIMENTAL*/
 
1533
--- 437,439 ----
 
1534
*** /home/njh/src/clamav-devel/./libclamav/js/vm.c      2006-10-28 12:33:45.000000000 +0100
 
1535
--- ./libclamav/js/vm.c 2006-10-21 14:58:34.000000000 +0100
 
1536
***************
 
1537
*** 24,36 ****
 
1538
  
 
1539
  /*
 
1540
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1541
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1542
   */
 
1543
- #if HAVE_CONFIG_H
 
1544
- #include "clamav-config.h"
 
1545
- #endif
 
1546
 
1547
- #ifdef        CL_EXPERIMENTAL
 
1548
  
 
1549
  #include "jsint.h"
 
1550
  
 
1551
--- 24,31 ----
 
1552
  
 
1553
  /*
 
1554
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1555
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1556
   */
 
1557
  
 
1558
  #include "jsint.h"
 
1559
  
 
1560
***************
 
1561
*** 971,974 ****
 
1562
    js_builtin_Object (vm);
 
1563
    js_builtin_String (vm);
 
1564
  }
 
1565
- #endif        /*CL_EXPERIMENTAL*/
 
1566
--- 966,968 ----
 
1567
*** /home/njh/src/clamav-devel/./libclamav/js/vmjumps.c 2006-10-28 12:33:45.000000000 +0100
 
1568
--- ./libclamav/js/vmjumps.c    2006-10-21 14:58:34.000000000 +0100
 
1569
***************
 
1570
*** 24,36 ****
 
1571
  
 
1572
  /*
 
1573
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1574
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1575
   */
 
1576
- #if HAVE_CONFIG_H
 
1577
- #include "clamav-config.h"
 
1578
- #endif
 
1579
 
1580
- #ifdef        CL_EXPERIMENTAL
 
1581
  
 
1582
  #include "jsint.h"
 
1583
  
 
1584
--- 24,31 ----
 
1585
  
 
1586
  /*
 
1587
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1588
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1589
   */
 
1590
  
 
1591
  #include "jsint.h"
 
1592
  
 
1593
***************
 
1594
*** 586,589 ****
 
1595
    return NULL;
 
1596
  #endif /* not (__GNUC__ && !DISABLE_JUMPS) */
 
1597
  }
 
1598
- #endif        /*CL_EXPERIMENTAL*/
 
1599
--- 581,583 ----
 
1600
*** /home/njh/src/clamav-devel/./libclamav/js/vmswitch.c        2006-10-28 12:33:45.000000000 +0100
 
1601
--- ./libclamav/js/vmswitch.c   2006-10-21 14:58:34.000000000 +0100
 
1602
***************
 
1603
*** 24,36 ****
 
1604
  
 
1605
  /*
 
1606
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1607
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1608
   */
 
1609
- #if HAVE_CONFIG_H
 
1610
- #include "clamav-config.h"
 
1611
- #endif
 
1612
 
1613
- #ifdef        CL_EXPERIMENTAL
 
1614
  
 
1615
  #include "jsint.h"
 
1616
  
 
1617
--- 24,31 ----
 
1618
  
 
1619
  /*
 
1620
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1621
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1622
   */
 
1623
  
 
1624
  #include "jsint.h"
 
1625
  
 
1626
***************
 
1627
*** 557,560 ****
 
1628
  
 
1629
    JS_COPY (&vm->exec_result, JS_SP1);
 
1630
  }
 
1631
- #endif        /*CL_EXPERIMENTAL*/
 
1632
--- 552,554 ----
 
1633
*** /home/njh/src/clamav-devel/./libclamav/js/xjs.c     2006-10-28 12:33:45.000000000 +0100
 
1634
--- ./libclamav/js/xjs.c        2006-10-21 14:58:34.000000000 +0100
 
1635
***************
 
1636
*** 24,36 ****
 
1637
  
 
1638
  /*
 
1639
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1640
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1641
   */
 
1642
- #if HAVE_CONFIG_H
 
1643
- #include "clamav-config.h"
 
1644
- #endif
 
1645
 
1646
- #ifdef        CL_EXPERIMENTAL
 
1647
  
 
1648
  #include "js/js.h"
 
1649
  #include "js/jsint.h"
 
1650
--- 24,31 ----
 
1651
  
 
1652
  /*
 
1653
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1654
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1655
   */
 
1656
  
 
1657
  #include "js/js.h"
 
1658
  #include "js/jsint.h"
 
1659
***************
 
1660
*** 463,466 ****
 
1661
  
 
1662
    js_vm_builtin_create (vm, n, info, NULL);
 
1663
  }
 
1664
- #endif        /*CL_EXPERIMENTAL*/
 
1665
--- 458,460 ----
 
1666
*** /home/njh/src/clamav-devel/./libclamav/js/xmd5.c    2006-10-28 12:33:45.000000000 +0100
 
1667
--- ./libclamav/js/xmd5.c       2006-10-21 14:58:34.000000000 +0100
 
1668
***************
 
1669
*** 24,39 ****
 
1670
  
 
1671
  /*
 
1672
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1673
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1674
   */
 
1675
- #if HAVE_CONFIG_H
 
1676
- #include "clamav-config.h"
 
1677
- #endif
 
1678
  
 
1679
! #ifdef        CL_EXPERIMENTAL
 
1680
 
1681
! #include "jsint.h"
 
1682
! #include "md5.h"
 
1683
  
 
1684
  /*
 
1685
   * Types and definitions.
 
1686
--- 24,34 ----
 
1687
  
 
1688
  /*
 
1689
   * $Source: /cvsroot/clamav/clamav-devel/contrib/Windows/Projects/clamAV/patches,v $
 
1690
!  * $Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $
 
1691
   */
 
1692
  
 
1693
! #include "js/jsint.h"
 
1694
! #include "js/md5.h"
 
1695
  
 
1696
  /*
 
1697
   * Types and definitions.
 
1698
***************
 
1699
*** 225,228 ****
 
1700
    n = &vm->globals[js_vm_intern (vm, "MD5")];
 
1701
    js_vm_builtin_create (vm, n, info, NULL);
 
1702
  }
 
1703
- #endif        /*CL_EXPERIMENTAL*/
 
1704
--- 220,222 ----
 
1705
*** /home/njh/src/clamav-devel/./libclamav/js/jsconfig.h        2006-10-19 18:27:28.000000000 +0100
 
1706
--- ./libclamav/js/jsconfig.h   2006-10-21 16:12:36.000000000 +0100
 
1707
***************
 
1708
*** 165,168 ****
 
1709
  #define HAVE_STRING_H 1
 
1710
  
 
1711
  /* Define if you have the <unistd.h> header file.  */
 
1712
! #define HAVE_UNISTD_H 1
 
1713
--- 165,168 ----
 
1714
  #define HAVE_STRING_H 1
 
1715
  
 
1716
  /* Define if you have the <unistd.h> header file.  */
 
1717
! /* #undef HAVE_UNISTD_H 1 */
 
1718
*** /home/njh/src/clamav-devel/./libclamav/jscript.c    2006-12-13 15:25:34.000000000 +0000
 
1719
--- ./libclamav/jscript.c       2006-11-24 20:52:14.000000000 +0000
 
1720
***************
 
1721
*** 28,40 ****
 
1722
   * TODO:      Add mailfollowurls type feature
 
1723
   * TODO:      Check the NGS code for vulnerabilities, leaks etc.
 
1724
   * TODO:      Check the NGS code is thread safe
 
1725
-  * TODO:      Test code such as
 
1726
-  *    <script>
 
1727
-  *            document.writeln("<script> function f() { ..the real worm code..
 
1728
-  *                    </script>"); f();
 
1729
-  *    </script>
 
1730
   */
 
1731
! static        char    const   rcsid[] = "$Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $";
 
1732
  
 
1733
  #if HAVE_CONFIG_H
 
1734
  #include "clamav-config.h"
 
1735
--- 28,35 ----
 
1736
   * TODO:      Add mailfollowurls type feature
 
1737
   * TODO:      Check the NGS code for vulnerabilities, leaks etc.
 
1738
   * TODO:      Check the NGS code is thread safe
 
1739
   */
 
1740
! static        char    const   rcsid[] = "$Id: patches,v 1.16 2007/02/12 15:41:19 njh Exp $";
 
1741
  
 
1742
  #if HAVE_CONFIG_H
 
1743
  #include "clamav-config.h"
 
1744
*** /home/njh/src/clamav-devel/./libclamav/lockdb.c     2007-02-11 16:26:35.000000000 +0000
 
1745
--- ./libclamav/lockdb.c        2007-02-11 16:26:52.000000000 +0000
 
1746
***************
 
1747
*** 64,69 ****
 
1748
--- 64,73 ----
 
1749
  #define pthread_mutex_unlock(arg)
 
1750
  #endif
 
1751
  
 
1752
+ #ifdef        C_WINDOWS
 
1753
+ #define       DONT_LOCK_DBDIRS
 
1754
+ #endif
 
1755
 
1756
  struct dblock {
 
1757
        struct dblock *lock_link;
 
1758
        char lock_file[NAME_MAX];
 
1759
*** /home/njh/src/clamav-devel/./libclamav/pdf.c        2007-02-10 21:25:35.000000000 +0000
 
1760
--- ./libclamav/pdf.c   2007-02-10 14:22:00.000000000 +0000
 
1761
***************
 
1762
*** 50,56 ****
 
1763
  #include "mbox.h"
 
1764
  #include "pdf.h"
 
1765
  
 
1766
! static        int     flatedecode(unsigned char *buf, off_t len, int fout, const cli_ctx *ctx);
 
1767
  static        int     ascii85decode(const char *buf, off_t len, unsigned char *output);
 
1768
  static        const   char    *pdf_nextlinestart(const char *ptr, size_t len);
 
1769
  static        const   char    *pdf_nextobject(const char *ptr, size_t len);
 
1770
--- 50,56 ----
 
1771
  #include "mbox.h"
 
1772
  #include "pdf.h"
 
1773
  
 
1774
! static        int     flatedecode(const unsigned char *buf, off_t len, int fout, const cli_ctx *ctx);
 
1775
  static        int     ascii85decode(const char *buf, off_t len, unsigned char *output);
 
1776
  static        const   char    *pdf_nextlinestart(const char *ptr, size_t len);
 
1777
  static        const   char    *pdf_nextobject(const char *ptr, size_t len);
 
1778
***************
 
1779
*** 89,95 ****
 
1780
        if(buf == MAP_FAILED)
 
1781
                return CL_EMEM;
 
1782
  
 
1783
!       cli_dbgmsg("cli_pdf: scanning %lu bytes\n", (unsigned long)size);
 
1784
  
 
1785
        /* Lines are terminated by \r, \n or both */
 
1786
  
 
1787
--- 89,95 ----
 
1788
        if(buf == MAP_FAILED)
 
1789
                return CL_EMEM;
 
1790
  
 
1791
!       cli_dbgmsg("cli_pdf: scanning %lu bytes\n", size);
 
1792
  
 
1793
        /* Lines are terminated by \r, \n or both */
 
1794
  
 
1795
***************
 
1796
*** 355,361 ****
 
1797
                                        if(zstat != Z_OK)
 
1798
                                                rc = CL_EZIP;
 
1799
                                } else
 
1800
!                                       cli_writen(fout, (const char *)streamstart, streamlen);
 
1801
                        }
 
1802
                        free(tmpbuf);
 
1803
                } else if(is_flatedecode) {
 
1804
--- 355,361 ----
 
1805
                                        if(zstat != Z_OK)
 
1806
                                                rc = CL_EZIP;
 
1807
                                } else
 
1808
!                                       cli_writen(fout, (char *)streamstart, streamlen);
 
1809
                        }
 
1810
                        free(tmpbuf);
 
1811
                } else if(is_flatedecode) {
 
1812
***************
 
1813
*** 364,372 ****
 
1814
                        if(zstat != Z_OK)
 
1815
                                rc = CL_EZIP;
 
1816
                } else {
 
1817
!                       cli_dbgmsg("cli_pdf: writing %lu bytes from the stream\n",
 
1818
!                               (unsigned long)streamlen);
 
1819
!                       cli_writen(fout, (const char *)streamstart, streamlen);
 
1820
                }
 
1821
  
 
1822
                close(fout);
 
1823
--- 364,372 ----
 
1824
                        if(zstat != Z_OK)
 
1825
                                rc = CL_EZIP;
 
1826
                } else {
 
1827
!                       cli_dbgmsg("cli_pdf: writing %u bytes from the stream\n",
 
1828
!                               streamlen);
 
1829
!                       cli_writen(fout, (char *)streamstart, streamlen);
 
1830
                }
 
1831
  
 
1832
                close(fout);
 
1833
***************
 
1834
*** 390,396 ****
 
1835
  
 
1836
  /* flate inflation - returns zlib status, e.g. Z_OK */
 
1837
  static int
 
1838
! flatedecode(unsigned char *buf, off_t len, int fout, const cli_ctx *ctx)
 
1839
  {
 
1840
        int zstat;
 
1841
        off_t nbytes;
 
1842
--- 390,396 ----
 
1843
  
 
1844
  /* flate inflation - returns zlib status, e.g. Z_OK */
 
1845
  static int
 
1846
! flatedecode(const unsigned char *buf, off_t len, int fout, const cli_ctx *ctx)
 
1847
  {
 
1848
        int zstat;
 
1849
        off_t nbytes;
 
1850
***************
 
1851
*** 402,408 ****
 
1852
        stream.zalloc = (alloc_func)Z_NULL;
 
1853
        stream.zfree = (free_func)Z_NULL;
 
1854
        stream.opaque = (void *)NULL;
 
1855
!       stream.next_in = (Bytef *)buf;
 
1856
        stream.avail_in = len;
 
1857
        stream.next_out = output;
 
1858
        stream.avail_out = sizeof(output);
 
1859
--- 402,408 ----
 
1860
        stream.zalloc = (alloc_func)Z_NULL;
 
1861
        stream.zfree = (free_func)Z_NULL;
 
1862
        stream.opaque = (void *)NULL;
 
1863
!       stream.next_in = (unsigned char *)buf;
 
1864
        stream.avail_in = len;
 
1865
        stream.next_out = output;
 
1866
        stream.avail_out = sizeof(output);
 
1867
***************
 
1868
*** 540,547 ****
 
1869
                        len = 0;
 
1870
                        break;
 
1871
                } else if(!isspace(byte)) {
 
1872
!                       cli_warnmsg("ascii85Decode: invalid character 0x%x, len %lu\n",
 
1873
!                               byte & 0xFF, (unsigned long)len);
 
1874
                        return -1;
 
1875
                }
 
1876
        }
 
1877
--- 540,546 ----
 
1878
                        len = 0;
 
1879
                        break;
 
1880
                } else if(!isspace(byte)) {
 
1881
!                       cli_warnmsg("ascii85Decode: invalid character 0x%x, len %lu\n", byte & 0xFF, len);
 
1882
                        return -1;
 
1883
                }
 
1884
        }
 
1885
*** /home/njh/src/clamav-devel/./clamscan/manager.c     2007-02-11 16:20:26.000000000 +0000
 
1886
--- ./clamscan/manager.c        2007-02-11 16:20:48.000000000 +0000
 
1887
***************
 
1888
*** 29,39 ****
 
1889
--- 29,47 ----
 
1890
  #include <ctype.h>
 
1891
  #include <sys/stat.h>
 
1892
  #include <sys/types.h>
 
1893
+ #ifdef        C_WINDOWS
 
1894
+ #include <sys/utime.h>
 
1895
+ #else
 
1896
  #include <sys/wait.h>
 
1897
  #include <utime.h>
 
1898
+ #endif
 
1899
+ #ifdef        HAVE_INITGROUPS
 
1900
  #include <grp.h>
 
1901
+ #endif
 
1902
  #include <fcntl.h>
 
1903
+ #ifdef        HAVE_UNISTD_H
 
1904
  #include <unistd.h>
 
1905
+ #endif
 
1906
  #include <sys/types.h>
 
1907
  #include <signal.h>
 
1908
  #include <errno.h>
 
1909
***************
 
1910
*** 57,62 ****
 
1911
--- 65,76 ----
 
1912
  dev_t procdev;
 
1913
  #endif
 
1914
  
 
1915
+ #ifdef        C_WINDOWS
 
1916
+ #undef        P_tmpdir
 
1917
 
1918
+ #define       P_tmpdir        "C:\\WINDOWS\\TEMP"
 
1919
+ #endif
 
1920
 
1921
  static int scandirs(const char *dirname, struct cl_engine *engine, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, int options)
 
1922
  {
 
1923
      return treewalk(dirname, engine, user, opt, limits, options, 1);
 
1924
***************
 
1925
*** 132,138 ****
 
1926
  
 
1927
  
 
1928
  /* njh@bandsman.co.uk: BeOS */
 
1929
! #if !defined(C_CYGWIN) && !defined(C_OS2) && !defined(C_BEOS)
 
1930
      if(!geteuid()) {
 
1931
        if((user = getpwnam(CLAMAVUSER)) == NULL) {
 
1932
            logg("!Can't get information about user "CLAMAVUSER"\n");
 
1933
--- 146,152 ----
 
1934
  
 
1935
  
 
1936
  /* njh@bandsman.co.uk: BeOS */
 
1937
! #if !defined(C_CYGWIN) && !defined(C_OS2) && !defined(C_BEOS) && !defined(C_WINDOWS)
 
1938
      if(!geteuid()) {
 
1939
        if((user = getpwnam(CLAMAVUSER)) == NULL) {
 
1940
            logg("!Can't get information about user "CLAMAVUSER"\n");
 
1941
***************
 
1942
*** 280,286 ****
 
1943
--- 294,304 ----
 
1944
        options |= CL_SCAN_MAIL;
 
1945
  
 
1946
        if(opt_check(opt, "mail-follow-urls"))
 
1947
+ #ifdef WITH_CURL
 
1948
            options |= CL_SCAN_MAILURL;
 
1949
+ #else
 
1950
+           logg("^Support for URLs downloading with libcurl not compiled in\n");
 
1951
+ #endif
 
1952
      }
 
1953
  
 
1954
      if(opt_check(opt, "no-algorithmic"))
 
1955
***************
 
1956
*** 383,388 ****
 
1957
--- 401,416 ----
 
1958
   * -3 -> external signal
 
1959
   * 0 -> OK
 
1960
   */
 
1961
 
1962
+ #ifdef        C_WINDOWS
 
1963
+ static int
 
1964
+ clamav_unpack(const char *prog, char **args, const char *tmpdir, const struct passwd *user, const struct optstruct *opt)
 
1965
+ {
 
1966
+       /* TODO: use spamvp(P_WAIT, prog, args); */
 
1967
+       cli_errmsg("clamav_unpack is not supported under Windows yet\n");
 
1968
+       return -1;
 
1969
+ }
 
1970
+ #else
 
1971
  static int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struct passwd *user, const struct optstruct *opt)
 
1972
  {
 
1973
        pid_t pid;
 
1974
***************
 
1975
*** 490,495 ****
 
1976
--- 518,524 ----
 
1977
  
 
1978
      return 0;
 
1979
  }
 
1980
+ #endif
 
1981
  
 
1982
  static void move_infected(const char *filename, const struct optstruct *opt)
 
1983
  {
 
1984
***************
 
1985
*** 605,611 ****
 
1986
  
 
1987
      logg("*Scanning %s\n", filename);
 
1988
  
 
1989
!     if((fd = open(filename, O_RDONLY)) == -1) {
 
1990
        logg("^Can't open file %s\n", filename);
 
1991
        return 54;
 
1992
      }
 
1993
--- 634,640 ----
 
1994
  
 
1995
      logg("*Scanning %s\n", filename);
 
1996
  
 
1997
!     if((fd = open(filename, O_RDONLY|O_BINARY)) == -1) {
 
1998
        logg("^Can't open file %s\n", filename);
 
1999
        return 54;
 
2000
      }
 
2001
***************
 
2002
*** 647,653 ****
 
2003
      tmpdir = getenv("TMPDIR");
 
2004
  
 
2005
      if(tmpdir == NULL)
 
2006
! #ifdef P_tmpdir
 
2007
        tmpdir = P_tmpdir;
 
2008
  #else
 
2009
        tmpdir = "/tmp";
 
2010
--- 676,682 ----
 
2011
      tmpdir = getenv("TMPDIR");
 
2012
  
 
2013
      if(tmpdir == NULL)
 
2014
! #ifdef        P_tmpdir
 
2015
        tmpdir = P_tmpdir;
 
2016
  #else
 
2017
        tmpdir = "/tmp";
 
2018
***************
 
2019
*** 666,672 ****
 
2020
        exit(63); /* critical */
 
2021
      }
 
2022
  
 
2023
! #ifndef C_OS2
 
2024
      if(user)
 
2025
        chown(gendir, user->pw_uid, user->pw_gid);
 
2026
  #endif
 
2027
--- 695,702 ----
 
2028
        exit(63); /* critical */
 
2029
      }
 
2030
  
 
2031
! #if   (!defined(C_OS2)) && (!defined(C_WINDOWS))
 
2032
!       /* FIXME: do the correct native windows way */
 
2033
      if(user)
 
2034
        chown(gendir, user->pw_uid, user->pw_gid);
 
2035
  #endif
 
2036
***************
 
2037
*** 845,851 ****
 
2038
      tmpdir = getenv("TMPDIR");
 
2039
  
 
2040
      if(tmpdir == NULL)
 
2041
! #ifdef P_tmpdir
 
2042
        tmpdir = P_tmpdir;
 
2043
  #else
 
2044
        tmpdir = "/tmp";
 
2045
--- 875,881 ----
 
2046
      tmpdir = getenv("TMPDIR");
 
2047
  
 
2048
      if(tmpdir == NULL)
 
2049
! #ifdef        P_tmpdir
 
2050
        tmpdir = P_tmpdir;
 
2051
  #else
 
2052
        tmpdir = "/tmp";
 
2053
***************
 
2054
*** 881,887 ****
 
2055
  
 
2056
      fixperms(gendir);
 
2057
  
 
2058
! #ifndef C_OS2
 
2059
      if(user) {
 
2060
        chown(gendir, user->pw_uid, user->pw_gid);
 
2061
        chown(tmpfile, user->pw_uid, user->pw_gid);
 
2062
--- 911,917 ----
 
2063
  
 
2064
      fixperms(gendir);
 
2065
  
 
2066
! #if   (!defined(C_OS2)) && (!defined(C_WINDOWS))
 
2067
      if(user) {
 
2068
        chown(gendir, user->pw_uid, user->pw_gid);
 
2069
        chown(tmpfile, user->pw_uid, user->pw_gid);
 
2070
***************
 
2071
*** 965,976 ****
 
2072
--- 995,1008 ----
 
2073
        return 0;
 
2074
      }
 
2075
  
 
2076
+ #ifndef       C_WINDOWS
 
2077
      if(geteuid())
 
2078
        if(checkaccess(filename, NULL, R_OK) != 1) {
 
2079
            if(!printinfected)
 
2080
                logg("%s: Access denied\n", filename);
 
2081
            return 0;
 
2082
        }
 
2083
+ #endif
 
2084
  
 
2085
      info.files++;
 
2086
  
 
2087
*** /home/njh/src/clamav-devel/./clamscan/clamscan.c    2007-01-31 04:46:12.000000000 +0000
 
2088
--- ./clamscan/clamscan.c       2007-02-09 19:45:48.000000000 +0000
 
2089
***************
 
2090
*** 24,32 ****
 
2091
--- 24,39 ----
 
2092
  #include <stdio.h>
 
2093
  #include <stdlib.h>
 
2094
  #include <string.h>
 
2095
+ #ifdef        HAVE_UNISTD_H
 
2096
  #include <unistd.h>
 
2097
+ #endif
 
2098
+ #ifdef        C_WINDOWS
 
2099
+ #include <fcntl.h>
 
2100
+ #else
 
2101
  #include <sys/time.h>
 
2102
+ #endif
 
2103
  #include <time.h>
 
2104
+ #include <ctype.h>
 
2105
  #ifdef C_LINUX
 
2106
  #include <sys/resource.h>
 
2107
  #endif
 
2108
***************
 
2109
*** 43,48 ****
 
2110
--- 50,59 ----
 
2111
  
 
2112
  void help(void);
 
2113
  
 
2114
+ #if   defined(C_WINDOWS) && defined(_DEBUG)
 
2115
+ #include <crtdbg.h>
 
2116
+ #endif
 
2117
 
2118
  struct s_info info;
 
2119
  short recursion = 0, printinfected = 0, bell = 0;
 
2120
  
 
2121
***************
 
2122
*** 51,59 ****
 
2123
--- 62,79 ----
 
2124
        int ds, dms, ret;
 
2125
        double mb;
 
2126
        struct timeval t1, t2;
 
2127
+ #ifndef       C_WINDOWS
 
2128
        struct timezone tz;
 
2129
+ #endif
 
2130
        struct optstruct *opt;
 
2131
        const char *pt;
 
2132
+       
 
2133
+ #if   defined(C_WINDOWS) && defined(CL_THREAD_SAFE)
 
2134
+       if(!pthread_win32_process_attach_np()) {
 
2135
+               mprintf("!Can't start the win32 pthreads layer\n");
 
2136
+               return 1;
 
2137
+       }
 
2138
+ #endif
 
2139
  
 
2140
  
 
2141
      opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, NULL);
 
2142
***************
 
2143
*** 180,190 ****
 
2144
--- 200,227 ----
 
2145
  
 
2146
      memset(&info, 0, sizeof(struct s_info));
 
2147
  
 
2148
+ #ifdef        C_WINDOWS
 
2149
+       _set_fmode(_O_BINARY);
 
2150
+ #ifdef        _DEBUG
 
2151
+       {
 
2152
+               _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
 
2153
+               _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
 
2154
+       }
 
2155
+ #endif        
 
2156
 
2157
+       gettimeofday(&t1, NULL);
 
2158
+ #else
 
2159
      gettimeofday(&t1, &tz);
 
2160
+ #endif
 
2161
 
2162
      ret = scanmanager(opt);
 
2163
  
 
2164
      if(!opt_check(opt, "disable-summary") && !opt_check(opt, "no-summary")) {
 
2165
+ #ifdef        C_WINDOWS
 
2166
+       gettimeofday(&t2, NULL);
 
2167
+ #else
 
2168
        gettimeofday(&t2, &tz);
 
2169
+ #endif
 
2170
        ds = t2.tv_sec - t1.tv_sec;
 
2171
        dms = t2.tv_usec - t1.tv_usec;
 
2172
        ds -= (dms < 0) ? (1):(0);
 
2173
***************
 
2174
*** 210,215 ****
 
2175
--- 247,260 ----
 
2176
      }
 
2177
  
 
2178
      opt_free(opt);
 
2179
+     
 
2180
+ #if   defined(C_WINDOWS) && defined(CL_THREAD_SAFE)
 
2181
+       if(!pthread_win32_process_detach_np()) {
 
2182
+               mprintf("!Can't stop the win32 pthreads layer\n");
 
2183
+               return 1;
 
2184
+       }
 
2185
+ #endif
 
2186
 
2187
      return ret;
 
2188
  }
 
2189
  
 
2190
*** /home/njh/src/clamav-devel/./clamscan/treewalk.c    2007-01-31 04:46:12.000000000 +0000
 
2191
--- ./clamscan/treewalk.c       2007-01-31 09:37:40.000000000 +0000
 
2192
***************
 
2193
*** 24,35 ****
 
2194
--- 24,43 ----
 
2195
  #include <stdio.h>
 
2196
  #include <stdlib.h>
 
2197
  #include <string.h>
 
2198
+ #ifdef        HAVE_UNISTD_H
 
2199
  #include <unistd.h>
 
2200
+ #endif
 
2201
  #include <sys/stat.h>
 
2202
  #include <sys/types.h>
 
2203
+ #ifndef       C_WINDOWS
 
2204
  #include <sys/wait.h>
 
2205
+ #endif
 
2206
+ #ifdef        HAVE_INITGROUPS
 
2207
  #include <grp.h>
 
2208
+ #endif
 
2209
+ #ifndef       C_WINDOWS
 
2210
  #include <dirent.h>
 
2211
+ #endif
 
2212
  #include <errno.h>
 
2213
  
 
2214
  #include "global.h"
 
2215
***************
 
2216
*** 99,105 ****
 
2217
  
 
2218
      if((dd = opendir(dirname)) != NULL) {
 
2219
        while((dent = readdir(dd))) {
 
2220
! #ifndef C_INTERIX
 
2221
            if(dent->d_ino)
 
2222
  #endif
 
2223
            {
 
2224
--- 107,113 ----
 
2225
  
 
2226
      if((dd = opendir(dirname)) != NULL) {
 
2227
        while((dent = readdir(dd))) {
 
2228
! #if   (!defined(C_INTERIX)) && (!defined(C_WINDOWS)) && (!defined(C_CYGWIN))
 
2229
            if(dent->d_ino)
 
2230
  #endif
 
2231
            {
 
2232
***************
 
2233
*** 138,143 ****
 
2234
--- 146,158 ----
 
2235
  
 
2236
  }
 
2237
  
 
2238
+ #ifdef        C_WINDOWS
 
2239
+ int
 
2240
+ clamav_rmdirs(const char *dir)
 
2241
+ {
 
2242
+       return rmdirs(dir);
 
2243
+ }
 
2244
+ #else
 
2245
  int clamav_rmdirs(const char *dir)
 
2246
  {
 
2247
  #ifndef C_CYGWIN
 
2248
***************
 
2249
*** 185,190 ****
 
2250
--- 200,206 ----
 
2251
                return -2;
 
2252
      }
 
2253
  }
 
2254
+ #endif
 
2255
  
 
2256
  int fixperms(const char *dirname)
 
2257
  {
 
2258
***************
 
2259
*** 196,202 ****
 
2260
  
 
2261
      if((dd = opendir(dirname)) != NULL) {
 
2262
        while((dent = readdir(dd))) {
 
2263
! #ifndef C_INTERIX
 
2264
            if(dent->d_ino)
 
2265
  #endif
 
2266
            {
 
2267
--- 212,218 ----
 
2268
  
 
2269
      if((dd = opendir(dirname)) != NULL) {
 
2270
        while((dent = readdir(dd))) {
 
2271
! #if   (!defined(C_INTERIX)) && (!defined(C_WINDOWS)) && (!defined(C_CYGWIN))
 
2272
            if(dent->d_ino)
 
2273
  #endif
 
2274
            {
 
2275
***************
 
2276
*** 242,248 ****
 
2277
  
 
2278
      if((dd = opendir(dirname)) != NULL) {
 
2279
        while((dent = readdir(dd))) {
 
2280
! #ifndef C_INTERIX
 
2281
            if(dent->d_ino)
 
2282
  #endif
 
2283
            {
 
2284
--- 258,264 ----
 
2285
  
 
2286
      if((dd = opendir(dirname)) != NULL) {
 
2287
        while((dent = readdir(dd))) {
 
2288
! #if   (!defined(C_INTERIX)) && (!defined(C_WINDOWS)) && (!defined(C_CYGWIN))
 
2289
            if(dent->d_ino)
 
2290
  #endif
 
2291
            {
 
2292
*** /home/njh/src/clamav-devel/./clamscan/treewalk.h    2007-01-31 04:46:12.000000000 +0000
 
2293
--- ./clamscan/treewalk.h       2007-01-31 09:37:34.000000000 +0000
 
2294
***************
 
2295
*** 20,26 ****
 
2296
--- 20,29 ----
 
2297
  #ifndef __TREEWALK_H
 
2298
  #define __TREEWALK_H
 
2299
  
 
2300
+ #ifndef       C_WINDOWS
 
2301
  #include <pwd.h>
 
2302
+ #endif
 
2303
 
2304
  #include "libclamav/clamav.h"
 
2305
  #include "shared/options.h"
 
2306
  
 
2307
*** /home/njh/src/clamav-devel/./clamscan/manager.h     2007-01-31 04:46:12.000000000 +0000
 
2308
--- ./clamscan/manager.h        2007-01-31 09:37:40.000000000 +0000
 
2309
***************
 
2310
*** 20,32 ****
 
2311
  #ifndef __MANAGER_H
 
2312
  #define __MANAGER_H
 
2313
  
 
2314
- #include <pwd.h>
 
2315
 
2316
  #include "libclamav/clamav.h"
 
2317
! #include "shared/options.h"
 
2318
  
 
2319
  int scanmanager(const struct optstruct *opt);
 
2320
  
 
2321
! int scanfile(const char *filename, struct cl_engine *engine, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, unsigned int options);
 
2322
  
 
2323
  #endif
 
2324
--- 20,52 ----
 
2325
  #ifndef __MANAGER_H
 
2326
  #define __MANAGER_H
 
2327
  
 
2328
  #include "libclamav/clamav.h"
 
2329
! #ifndef       C_WINDOWS
 
2330
! #include <pwd.h>
 
2331
! #endif
 
2332
! #include "options.h"
 
2333
  
 
2334
  int scanmanager(const struct optstruct *opt);
 
2335
  
 
2336
! int scanfile(const char *filename, struct cl_node *root, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, int options);
 
2337
 
2338
! int scancompressed(const char *filename, struct cl_node *root, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, int options);
 
2339
 
2340
! int scandenied(const char *filename, struct cl_node *root, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, int options);
 
2341
 
2342
! int scandirs(const char *dirname, struct cl_node *root, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, int options);
 
2343
 
2344
! int checkfile(const char *filename, const struct cl_node *root, const struct cl_limits *limits, int options, short printclean);
 
2345
 
2346
! int checkstdin(const struct cl_node *root, const struct cl_limits *limits, int options);
 
2347
 
2348
! int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struct passwd *user, const struct optstruct *opt);
 
2349
 
2350
! void move_infected(const char *filename, const struct optstruct *opt);
 
2351
 
2352
! #ifdef        _DEBUG
 
2353
! /* breaks mspack/qtmd.c :-( */
 
2354
! #define       free(p) _free_dbg(p, _NORMAL_BLOCK)
 
2355
! #endif
 
2356
  
 
2357
  #endif
 
2358
*** /home/njh/src/clamav-devel/./clamscan/others.c      2007-01-31 04:46:12.000000000 +0000
 
2359
--- ./clamscan/others.c 2006-07-26 16:03:16.000000000 +0100
 
2360
***************
 
2361
*** 16,21 ****
 
2362
--- 16,24 ----
 
2363
   *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
2364
   *  MA 02110-1301, USA.
 
2365
   *
 
2366
+  *  Sat May 18 15:20:26 CEST 2002: included detectCpu() from Magnus Ekdahl
 
2367
+  *  Sat Jun 29 12:19:26 CEST 2002: fixed non386 detectCpu (Magnus Ekdahl)
 
2368
+  *
 
2369
   */
 
2370
  
 
2371
  #if HAVE_CONFIG_H
 
2372
***************
 
2373
*** 26,38 ****
 
2374
--- 29,47 ----
 
2375
  #include <stdlib.h>
 
2376
  #include <string.h>
 
2377
  #include <ctype.h>
 
2378
+ #ifdef        HAVE_UNISTD_H
 
2379
  #include <unistd.h>
 
2380
+ #endif
 
2381
  #include <errno.h>
 
2382
+ #ifndef       C_WINDOWS
 
2383
  #include <pwd.h>
 
2384
+ #endif
 
2385
  #include <sys/types.h>
 
2386
  #include <sys/stat.h>
 
2387
+ #ifndef       C_WINDOWS
 
2388
  #include <sys/wait.h>
 
2389
  #include <sys/time.h>
 
2390
+ #endif
 
2391
  #include <time.h>
 
2392
  #include <fcntl.h>
 
2393
  #include <signal.h>
 
2394
***************
 
2395
*** 42,48 ****
 
2396
  #include <regex.h>
 
2397
  #endif
 
2398
  
 
2399
! #include "shared/output.h"
 
2400
  #include "others.h"
 
2401
  
 
2402
  int fileinfo(const char *filename, short i)
 
2403
--- 51,57 ----
 
2404
  #include <regex.h>
 
2405
  #endif
 
2406
  
 
2407
! #include "output.h"
 
2408
  #include "others.h"
 
2409
  
 
2410
  int fileinfo(const char *filename, short i)
 
2411
***************
 
2412
*** 70,75 ****
 
2413
--- 79,92 ----
 
2414
      }
 
2415
  }
 
2416
  
 
2417
+ #ifdef        C_WINDOWS
 
2418
+ /* FIXME: Handle users correctly */
 
2419
+ int
 
2420
+ checkaccess(const char *path, const char *username, int mode)
 
2421
+ {
 
2422
+       return _access(path, mode);
 
2423
+ }
 
2424
+ #else
 
2425
  int checkaccess(const char *path, const char *username, int mode)
 
2426
  {
 
2427
        struct passwd *user;
 
2428
***************
 
2429
*** 114,119 ****
 
2430
--- 131,137 ----
 
2431
  
 
2432
      return ret;
 
2433
  }
 
2434
+ #endif
 
2435
  
 
2436
  int match_regex(const char *filename, const char *pattern)
 
2437
  {
 
2438
*** /home/njh/src/clamav-devel/./shared/getopt.c        2004-03-29 01:00:58.000000000 +0100
 
2439
--- ./shared/getopt.c   2006-07-26 16:49:38.000000000 +0100
 
2440
***************
 
2441
*** 41,47 ****
 
2442
--- 41,49 ----
 
2443
  
 
2444
  #include <stdio.h>
 
2445
  
 
2446
+ #ifndef       C_WINDOWS
 
2447
  int strncmp(const char *s1, const char *s2, size_t n);
 
2448
+ #endif
 
2449
  
 
2450
  /* Comment out all this code if we are using the GNU C Library, and are not
 
2451
     actually compiling the library itself.  This code is part of the GNU C
 
2452
*** /home/njh/src/clamav-devel/./shared/network.h       2006-04-09 20:59:28.000000000 +0100
 
2453
--- ./shared/network.h  2006-07-31 15:59:30.000000000 +0100
 
2454
***************
 
2455
*** 21,28 ****
 
2456
--- 21,33 ----
 
2457
  #ifndef __NETWORK_H
 
2458
  #define __NETWORK_H
 
2459
  
 
2460
+ #ifdef        HAVE_SYS_TYPES_H
 
2461
  #include <sys/types.h>
 
2462
+ #endif
 
2463
 
2464
+ #ifndef       C_WINDOWS
 
2465
  #include <netdb.h>
 
2466
+ #endif
 
2467
  
 
2468
  int r_gethostbyname(const char *hostname, struct hostent *hp, char *buf, size_t len);
 
2469
  
 
2470
*** /home/njh/src/clamav-devel/./shared/output.c        2006-08-31 09:03:18.000000000 +0100
 
2471
--- ./shared/output.c   2006-08-31 10:23:58.000000000 +0100
 
2472
***************
 
2473
*** 16,21 ****
 
2474
--- 16,26 ----
 
2475
   *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
2476
   *  MA 02110-1301, USA.
 
2477
   */
 
2478
+ #ifdef        _MSC_VER
 
2479
+ #include <windows.h>
 
2480
+ #include <winsock.h>
 
2481
+ #endif
 
2482
 
2483
  
 
2484
  #if HAVE_CONFIG_H
 
2485
  #include "clamav-config.h"
 
2486
***************
 
2487
*** 30,42 ****
 
2488
--- 35,51 ----
 
2489
  #include <stdlib.h>
 
2490
  #include <string.h>
 
2491
  #include <ctype.h>
 
2492
+ #ifdef        HAVE_UNISTD_H
 
2493
  #include <unistd.h>
 
2494
+ #endif
 
2495
  #include <fcntl.h>
 
2496
  #include <time.h>
 
2497
  #include <sys/stat.h>
 
2498
  #include <errno.h>
 
2499
+ #ifndef       C_WINDOWS
 
2500
  #include <sys/time.h>
 
2501
  #include <sys/socket.h>
 
2502
+ #endif
 
2503
  #if HAVE_SYS_TYPES_H
 
2504
  #include <sys/types.h>
 
2505
  #endif
 
2506
***************
 
2507
*** 122,128 ****
 
2508
--- 131,139 ----
 
2509
  int logg(const char *str, ...)
 
2510
  {
 
2511
        va_list args, argscpy, argsout;
 
2512
+ #ifdef        F_WRLCK
 
2513
        struct flock fl;
 
2514
+ #endif
 
2515
        char *pt, *timestr, vbuff[1025];
 
2516
        time_t currtime;
 
2517
        struct stat sb;
 
2518
***************
 
2519
*** 140,146 ****
 
2520
      if(logg_file) {
 
2521
        if(!logg_fd) {
 
2522
            old_umask = umask(0037);
 
2523
!           if((logg_fd = fopen(logg_file, "a")) == NULL) {
 
2524
                umask(old_umask);
 
2525
  #ifdef CL_THREAD_SAFE
 
2526
                pthread_mutex_unlock(&logg_mutex);
 
2527
--- 151,157 ----
 
2528
      if(logg_file) {
 
2529
        if(!logg_fd) {
 
2530
            old_umask = umask(0037);
 
2531
!           if((logg_fd = fopen(logg_file, "at")) == NULL) {
 
2532
                umask(old_umask);
 
2533
  #ifdef CL_THREAD_SAFE
 
2534
                pthread_mutex_unlock(&logg_mutex);
 
2535
***************
 
2536
*** 149,154 ****
 
2537
--- 160,166 ----
 
2538
                return -1;
 
2539
            } else umask(old_umask);
 
2540
  
 
2541
+ #ifdef        F_WRLCK
 
2542
            if(logg_lock) {
 
2543
                memset(&fl, 0, sizeof(fl));
 
2544
                fl.l_type = F_WRLCK;
 
2545
***************
 
2546
*** 159,164 ****
 
2547
--- 171,177 ----
 
2548
                    return -1;
 
2549
                }
 
2550
            }
 
2551
+ #endif
 
2552
        }
 
2553
  
 
2554
        if(logg_size) {
 
2555
*** /home/njh/src/clamav-devel/./shared/memory.h        2006-04-09 20:59:28.000000000 +0100
 
2556
--- ./shared/memory.h   2006-10-10 11:16:24.000000000 +0100
 
2557
***************
 
2558
*** 25,28 ****
 
2559
--- 25,33 ----
 
2560
  void *mmalloc(size_t size);
 
2561
  void *mcalloc(size_t nmemb, size_t size);
 
2562
  
 
2563
+ #ifdef        _DEBUG
 
2564
+ #include <crtdbg.h>
 
2565
+ #define       free(p) _free_dbg(p, _NORMAL_BLOCK)
 
2566
+ #endif
 
2567
 
2568
  #endif
 
2569
*** /home/njh/src/clamav-devel/./shared/memory.c        2007-02-11 11:43:29.000000000 +0000
 
2570
--- ./shared/memory.c   2007-02-11 15:02:08.000000000 +0000
 
2571
***************
 
2572
*** 19,25 ****
 
2573
--- 19,27 ----
 
2574
  
 
2575
  #include <stdio.h>
 
2576
  #include <stdlib.h>
 
2577
+ #ifdef        HAVE_UNISTD_H
 
2578
  #include <unistd.h>
 
2579
+ #endif
 
2580
  #include "memory.h"
 
2581
  
 
2582
  void *mmalloc(size_t size)
 
2583
*** /home/njh/src/clamav-devel/./shared/cdiff.c 2007-02-11 11:43:29.000000000 +0000
 
2584
--- ./shared/cdiff.c    2007-02-11 15:06:46.000000000 +0000
 
2585
***************
 
2586
*** 27,33 ****
 
2587
--- 27,35 ----
 
2588
  #include <ctype.h>
 
2589
  #include <sys/types.h>
 
2590
  #include <sys/stat.h>
 
2591
+ #ifdef        HAVE_UNISTD_H
 
2592
  #include <unistd.h>
 
2593
+ #endif
 
2594
  
 
2595
  #include "shared/memory.h"
 
2596
  #include "shared/misc.h"
 
2597
*** /home/njh/src/clamav-devel/./freshclam/manager.c    2007-02-12 13:30:50.000000000 +0000
 
2598
--- ./freshclam/manager.c       2007-02-12 13:32:08.000000000 +0000
 
2599
***************
 
2600
*** 20,25 ****
 
2601
--- 20,29 ----
 
2602
   *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
2603
   *  MA 02110-1301, USA.
 
2604
   */
 
2605
+  
 
2606
+ #ifdef        _MSC_VER
 
2607
+ #include <winsock.h>  /* only needed in CL_EXPERIMENTAL */
 
2608
+ #endif
 
2609
  
 
2610
  #if HAVE_CONFIG_H
 
2611
  #include "clamav-config.h"
 
2612
***************
 
2613
*** 27,40 ****
 
2614
--- 31,50 ----
 
2615
  
 
2616
  #include <stdio.h>
 
2617
  #include <stdlib.h>
 
2618
+ #ifdef        HAVE_UNISTD_H
 
2619
  #include <unistd.h>
 
2620
+ #endif
 
2621
  #include <string.h>
 
2622
  #include <ctype.h>
 
2623
+ #ifndef       C_WINDOWS
 
2624
  #include <netinet/in.h>
 
2625
  #include <netdb.h>
 
2626
+ #endif
 
2627
  #include <sys/types.h>
 
2628
+ #ifndef       C_WINDOWS
 
2629
  #include <sys/socket.h>
 
2630
  #include <sys/time.h>
 
2631
+ #endif
 
2632
  #include <time.h>
 
2633
  #include <fcntl.h>
 
2634
  #include <sys/stat.h>
 
2635
***************
 
2636
*** 64,69 ****
 
2637
--- 74,82 ----
 
2638
  #define       O_BINARY        0
 
2639
  #endif
 
2640
  
 
2641
+ #ifndef       C_WINDOWS
 
2642
+ #define       closesocket(s)  close(s)
 
2643
+ #endif
 
2644
  
 
2645
  static int wwwconnect(const char *server, const char *proxy, int pport, char *ip, const char *localip, int ctimeout, struct mirdat *mdat)
 
2646
  {
 
2647
***************
 
2648
*** 144,150 ****
 
2649
--- 157,165 ----
 
2650
                else
 
2651
                        port = 8080;
 
2652
  
 
2653
+ #ifndef       C_WINDOWS
 
2654
                endservent();
 
2655
+ #endif
 
2656
  #else
 
2657
                port = 8080;
 
2658
  #endif
 
2659
***************
 
2660
*** 156,162 ****
 
2661
      }
 
2662
  
 
2663
      if((host = gethostbyname(hostpt)) == NULL) {
 
2664
!       const char *herr;
 
2665
        switch(h_errno) {
 
2666
            case HOST_NOT_FOUND:
 
2667
                herr = "Host not found";
 
2668
--- 171,177 ----
 
2669
      }
 
2670
  
 
2671
      if((host = gethostbyname(hostpt)) == NULL) {
 
2672
!       char *herr;
 
2673
        switch(h_errno) {
 
2674
            case HOST_NOT_FOUND:
 
2675
                herr = "Host not found";
 
2676
***************
 
2677
*** 376,384 ****
 
2678
      if(!ip[0])
 
2679
        strcpy(ip, ipaddr);
 
2680
  
 
2681
!     if(write(sd, cmd, strlen(cmd)) < 0) {
 
2682
        logg("!remote_cvdhead: write failed\n");
 
2683
!       close(sd);
 
2684
        return NULL;
 
2685
      }
 
2686
  
 
2687
--- 391,399 ----
 
2688
      if(!ip[0])
 
2689
        strcpy(ip, ipaddr);
 
2690
  
 
2691
!     if(send(sd, cmd, strlen(cmd), 0) < 0) {
 
2692
        logg("!remote_cvdhead: write failed\n");
 
2693
!       closesocket(sd);
 
2694
        return NULL;
 
2695
      }
 
2696
  
 
2697
***************
 
2698
*** 394,400 ****
 
2699
        if(cnt <= 0)
 
2700
            break;
 
2701
      }
 
2702
!     close(sd);
 
2703
  
 
2704
      if(bread == -1) {
 
2705
        logg("!remote_cvdhead: Error while reading CVD header from %s\n", hostname);
 
2706
--- 409,415 ----
 
2707
        if(cnt <= 0)
 
2708
            break;
 
2709
      }
 
2710
!     closesocket(sd);
 
2711
  
 
2712
      if(bread == -1) {
 
2713
        logg("!remote_cvdhead: Error while reading CVD header from %s\n", hostname);
 
2714
***************
 
2715
*** 525,531 ****
 
2716
      if(!ip[0])
 
2717
        strcpy(ip, ipaddr);
 
2718
  
 
2719
!     if(write(sd, cmd, strlen(cmd)) < 0) {
 
2720
        logg("!getfile: Can't write to socket\n");
 
2721
        return 52;
 
2722
      }
 
2723
--- 540,546 ----
 
2724
      if(!ip[0])
 
2725
        strcpy(ip, ipaddr);
 
2726
  
 
2727
!     if(send(sd, cmd, strlen(cmd), 0) < 0) {
 
2728
        logg("!getfile: Can't write to socket\n");
 
2729
        return 52;
 
2730
      }
 
2731
***************
 
2732
*** 565,571 ****
 
2733
      if((strstr(buffer, "HTTP/1.1 404")) != NULL || (strstr(buffer, "HTTP/1.0 404")) != NULL) { 
 
2734
        logg("!getfile: %s not found on remote server (IP: %s)\n", srcfile, ipaddr);
 
2735
        /* mirman_update(mdat->currip, mdat, 1); */
 
2736
!       close(sd);
 
2737
        return 58;
 
2738
      }
 
2739
  
 
2740
--- 580,586 ----
 
2741
      if((strstr(buffer, "HTTP/1.1 404")) != NULL || (strstr(buffer, "HTTP/1.0 404")) != NULL) { 
 
2742
        logg("!getfile: %s not found on remote server (IP: %s)\n", srcfile, ipaddr);
 
2743
        /* mirman_update(mdat->currip, mdat, 1); */
 
2744
!       closesocket(sd);
 
2745
        return 58;
 
2746
      }
 
2747
  
 
2748
***************
 
2749
*** 573,579 ****
 
2750
         !strstr(buffer, "HTTP/1.1 206") && !strstr(buffer, "HTTP/1.0 206")) {
 
2751
        logg("!getfile: Unknown response from remote server (IP: %s)\n", ipaddr);
 
2752
        mirman_update(mdat->currip, mdat, 1);
 
2753
!       close(sd);
 
2754
        return 58;
 
2755
      }
 
2756
  
 
2757
--- 588,594 ----
 
2758
         !strstr(buffer, "HTTP/1.1 206") && !strstr(buffer, "HTTP/1.0 206")) {
 
2759
        logg("!getfile: Unknown response from remote server (IP: %s)\n", ipaddr);
 
2760
        mirman_update(mdat->currip, mdat, 1);
 
2761
!       closesocket(sd);
 
2762
        return 58;
 
2763
      }
 
2764
  
 
2765
***************
 
2766
*** 596,602 ****
 
2767
        getcwd(currdir, sizeof(currdir));
 
2768
        logg("!getfile: Can't create new file %s in %s\n", destfile, currdir);
 
2769
        logg("Hint: The database directory must be writable for UID %d or GID %d\n", getuid(), getgid());
 
2770
!       close(sd);
 
2771
        return 57;
 
2772
      }
 
2773
  
 
2774
--- 611,617 ----
 
2775
        getcwd(currdir, sizeof(currdir));
 
2776
        logg("!getfile: Can't create new file %s in %s\n", destfile, currdir);
 
2777
        logg("Hint: The database directory must be writable for UID %d or GID %d\n", getuid(), getgid());
 
2778
!       closesocket(sd);
 
2779
        return 57;
 
2780
      }
 
2781
  
 
2782
***************
 
2783
*** 609,615 ****
 
2784
            logg("getfile: Can't write %d bytes to %s\n", bread, destfile);
 
2785
            unlink(destfile);
 
2786
            close(fd);
 
2787
!           close(sd);
 
2788
            return 57; /* FIXME */
 
2789
        }
 
2790
  
 
2791
--- 624,630 ----
 
2792
            logg("getfile: Can't write %d bytes to %s\n", bread, destfile);
 
2793
            unlink(destfile);
 
2794
            close(fd);
 
2795
!           closesocket(sd);
 
2796
            return 57; /* FIXME */
 
2797
        }
 
2798
  
 
2799
***************
 
2800
*** 626,632 ****
 
2801
              fflush(stdout);
 
2802
          }
 
2803
      }
 
2804
!     close(sd);
 
2805
      close(fd);
 
2806
  
 
2807
      if(totalsize > 0)
 
2808
--- 641,647 ----
 
2809
              fflush(stdout);
 
2810
          }
 
2811
      }
 
2812
!     closesocket(sd);
 
2813
      close(fd);
 
2814
  
 
2815
      if(totalsize > 0)
 
2816
*** /home/njh/src/clamav-devel/./freshclam/execute.c    2007-02-11 16:30:34.000000000 +0000
 
2817
--- ./freshclam/execute.c       2007-02-11 16:25:36.000000000 +0000
 
2818
***************
 
2819
*** 1,5 ****
 
2820
  /*
 
2821
!  *  By Per Jessen <per@computer.org>
 
2822
   *
 
2823
   *  This program is free software; you can redistribute it and/or modify
 
2824
   *  it under the terms of the GNU General Public License as published by
 
2825
--- 1,5 ----
 
2826
  /*
 
2827
!  *  By Per Jessen <per@computer.org> with changes by the ClamAV team
 
2828
   *
 
2829
   *  This program is free software; you can redistribute it and/or modify
 
2830
   *  it under the terms of the GNU General Public License as published by
 
2831
***************
 
2832
*** 23,31 ****
 
2833
--- 23,36 ----
 
2834
  
 
2835
  #include <stdio.h>
 
2836
  #include <stdlib.h>
 
2837
+ #ifdef        HAVE_UNISTD_H
 
2838
  #include <unistd.h>
 
2839
+ #endif
 
2840
  #include <string.h>
 
2841
  #include <errno.h>
 
2842
+ #ifdef        C_WINDOWS
 
2843
+ #include <process.h>
 
2844
+ #endif
 
2845
  
 
2846
  #include "shared/output.h"
 
2847
  #include "execute.h"
 
2848
***************
 
2849
*** 36,41 ****
 
2850
--- 41,56 ----
 
2851
  
 
2852
  void execute( const char *type, const char *text )
 
2853
  {
 
2854
+ #ifdef        C_WINDOWS
 
2855
+       if(active_children < MAX_CHILDREN) {
 
2856
+               if(spawnlp(P_DETACH, text, text, NULL) == -1) {
 
2857
+                       logg("^%s: couldn't execute \"%s\".\n", type, text);
 
2858
+                       return;
 
2859
+               }
 
2860
+               active_children++;      /* FIXME: this is never reduced */
 
2861
+       } else
 
2862
+               logg("^%s: already %d processes active.\n", type, active_children);
 
2863
+ #else
 
2864
        pid_t pid;
 
2865
  
 
2866
        if ( active_children<MAX_CHILDREN )
 
2867
***************
 
2868
*** 56,59 ****
 
2869
--- 71,75 ----
 
2870
        {
 
2871
                logg("^%s: already %d processes active.\n", type, active_children);
 
2872
        }
 
2873
+ #endif
 
2874
  }
 
2875
*** /home/njh/src/clamav-devel/./freshclam/nonblock.c   2007-01-31 04:43:08.000000000 +0000
 
2876
--- ./freshclam/nonblock.c      2007-02-10 16:40:54.000000000 +0000
 
2877
***************
 
2878
*** 15,20 ****
 
2879
--- 15,23 ----
 
2880
   *  along with this program; if not, write to the Free Software
 
2881
   *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
2882
   */
 
2883
+ #ifdef        _MSC_VER
 
2884
+ #include <winsock.h>
 
2885
+ #endif
 
2886
  
 
2887
  #if HAVE_CONFIG_H
 
2888
  #include "clamav-config.h"
 
2889
***************
 
2890
*** 24,37 ****
 
2891
  
 
2892
  #include <stdio.h>
 
2893
  #include <stdlib.h>
 
2894
  #include <unistd.h>
 
2895
  #include <string.h>
 
2896
  #include <ctype.h>
 
2897
  #include <netinet/in.h>
 
2898
  #include <netdb.h>
 
2899
  #include <sys/types.h>
 
2900
! #include <sys/socket.h>
 
2901
  #include <sys/time.h>
 
2902
  #include <time.h>
 
2903
  #include <fcntl.h>
 
2904
  #include <sys/stat.h>
 
2905
--- 27,46 ----
 
2906
  
 
2907
  #include <stdio.h>
 
2908
  #include <stdlib.h>
 
2909
+ #ifdef        HAVE_UNISTD_H
 
2910
  #include <unistd.h>
 
2911
+ #endif
 
2912
  #include <string.h>
 
2913
  #include <ctype.h>
 
2914
+ #ifndef       C_WINDOWS
 
2915
  #include <netinet/in.h>
 
2916
  #include <netdb.h>
 
2917
+ #endif
 
2918
  #include <sys/types.h>
 
2919
! /*#include <sys/socket.h>     /* in nonblock.h */
 
2920
! #ifndef       C_WINDOWS
 
2921
  #include <sys/time.h>
 
2922
+ #endif
 
2923
  #include <time.h>
 
2924
  #include <fcntl.h>
 
2925
  #include <sys/stat.h>
 
2926
***************
 
2927
*** 40,45 ****
 
2928
--- 49,64 ----
 
2929
  #include "shared/output.h"
 
2930
  #include "libclamav/clamav.h"
 
2931
  
 
2932
+ #if   (!defined(EALREADY)) && (defined(WSAEALREADY))
 
2933
+ #define EALREADY      WSAEALREADY
 
2934
+ #endif
 
2935
+ #if   (!defined(EINPROGRESS)) && (defined(WSAEINPROGRESS))
 
2936
+ #define EINPROGRESS   WSAEINPROGRESS
 
2937
+ #endif
 
2938
+ #if   (!defined(EISCONN)) && (defined(WSAEISCONN))
 
2939
+ #define EISCONN       WSAEISCONN
 
2940
+ #endif
 
2941
 
2942
  #ifdef SO_ERROR
 
2943
  
 
2944
  #ifndef timercmp
 
2945
***************
 
2946
*** 229,234 ****
 
2947
--- 248,254 ----
 
2948
  
 
2949
  static long nonblock_fcntl(int sock)
 
2950
  {
 
2951
+ #ifdef        F_GETFL
 
2952
        long fcntl_flags; /* Save fcntl() flags */
 
2953
  
 
2954
        fcntl_flags = fcntl(sock, F_GETFL, 0);
 
2955
***************
 
2956
*** 242,257 ****
 
2957
--- 262,282 ----
 
2958
        }
 
2959
  
 
2960
        return fcntl_flags;
 
2961
+ #else
 
2962
+       return 0;
 
2963
+ #endif
 
2964
  }
 
2965
  
 
2966
  static void restore_fcntl(int sock, long fcntl_flags)
 
2967
  {
 
2968
+ #ifdef        F_SETFL
 
2969
        if (fcntl_flags != -1) {
 
2970
                if (fcntl(sock, F_SETFL, fcntl_flags)) {
 
2971
                        logg("restore_fcntl: restoring: fcntl(%d, F_SETFL): errno=%d: %s\n",
 
2972
                             sock, errno, strerror(errno));
 
2973
                }
 
2974
        }
 
2975
+ #endif
 
2976
  }
 
2977
  
 
2978
  /*
 
2979
*** /home/njh/src/clamav-devel/./freshclam/nonblock.h   2006-09-04 09:24:02.000000000 +0100
 
2980
--- ./freshclam/nonblock.h      2006-09-04 10:35:10.000000000 +0100
 
2981
***************
 
2982
*** 24,30 ****
 
2983
--- 24,32 ----
 
2984
  #endif
 
2985
  
 
2986
  #include <sys/types.h>
 
2987
+ #ifndef       C_WINDOWS
 
2988
  #include <sys/socket.h>
 
2989
+ #endif
 
2990
  
 
2991
  /*
 
2992
        wait_connect(): wrapper for connect(), with explicit 'secs' timeout
 
2993
*** /home/njh/src/clamav-devel/./freshclam/notify.c     2007-02-11 16:25:00.000000000 +0000
 
2994
--- ./freshclam/notify.c        2007-02-11 16:24:48.000000000 +0000
 
2995
***************
 
2996
*** 16,21 ****
 
2997
--- 16,26 ----
 
2998
   *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
2999
   *  MA 02110-1301, USA.
 
3000
   */
 
3001
+ #ifdef        _MSC_VER
 
3002
+ #include <windows.h>
 
3003
+ #include <winsock.h>
 
3004
+ #endif
 
3005
 
3006
  
 
3007
  #if HAVE_CONFIG_H
 
3008
  #include "clamav-config.h"
 
3009
***************
 
3010
*** 24,46 ****
 
3011
--- 29,61 ----
 
3012
  #ifdef BUILD_CLAMD
 
3013
  
 
3014
  #include <stdio.h>
 
3015
+ #ifdef        HAVE_UNISTD_H
 
3016
  #include <unistd.h>
 
3017
+ #endif
 
3018
  #include <sys/types.h>
 
3019
+ #ifndef       C_WINDOWS
 
3020
  #include <sys/socket.h>
 
3021
  #include <sys/un.h>
 
3022
  #include <netinet/in.h>
 
3023
  #include <arpa/inet.h>
 
3024
  #include <netdb.h>
 
3025
+ #endif
 
3026
  #include <string.h>
 
3027
  
 
3028
  #include "shared/cfgparser.h"
 
3029
  #include "shared/output.h"
 
3030
  #include "notify.h"
 
3031
  
 
3032
+ #ifndef       C_WINDOWS
 
3033
+ #define       closesocket(s)  close(s)
 
3034
+ #endif
 
3035
 
3036
  int notify(const char *cfgfile)
 
3037
  {
 
3038
        char buff[20];
 
3039
+ #ifndef       C_WINDOWS
 
3040
        struct sockaddr_un server;
 
3041
+ #endif
 
3042
          struct sockaddr_in server2;
 
3043
        struct hostent *he;
 
3044
        struct cfgstruct *copt, *cpt;
 
3045
***************
 
3046
*** 53,58 ****
 
3047
--- 68,74 ----
 
3048
        return 1;
 
3049
      }
 
3050
  
 
3051
+ #ifndef       C_WINDOWS
 
3052
      if((cpt = cfgopt(copt, "LocalSocket"))->enabled) {
 
3053
        socktype = "UNIX";
 
3054
        server.sun_family = AF_UNIX;
 
3055
***************
 
3056
*** 65,77 ****
 
3057
        }
 
3058
  
 
3059
        if(connect(sockd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) {
 
3060
!           close(sockd);
 
3061
            logg("^Clamd was NOT notified: Can't connect to clamd through %s\n", cpt->strarg);
 
3062
            perror("connect()");
 
3063
            return 1;
 
3064
        }
 
3065
  
 
3066
!     } else if((cpt = cfgopt(copt, "TCPSocket"))->enabled) {
 
3067
  
 
3068
        socktype = "TCP";
 
3069
  #ifdef PF_INET
 
3070
--- 81,95 ----
 
3071
        }
 
3072
  
 
3073
        if(connect(sockd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) {
 
3074
!           closesocket(sockd);
 
3075
            logg("^Clamd was NOT notified: Can't connect to clamd through %s\n", cpt->strarg);
 
3076
            perror("connect()");
 
3077
            return 1;
 
3078
        }
 
3079
  
 
3080
!     } else
 
3081
! #endif
 
3082
!     if((cpt = cfgopt(copt, "TCPSocket"))->enabled) {
 
3083
  
 
3084
        socktype = "TCP";
 
3085
  #ifdef PF_INET
 
3086
***************
 
3087
*** 99,105 ****
 
3088
  
 
3089
  
 
3090
        if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) {
 
3091
!           close(sockd);
 
3092
            logg("^Clamd was NOT notified: Can't connect to clamd on %s:%d\n",
 
3093
                    inet_ntoa(server2.sin_addr), ntohs(server2.sin_port));
 
3094
            perror("connect()");
 
3095
--- 117,123 ----
 
3096
  
 
3097
  
 
3098
        if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) {
 
3099
!           closesocket(sockd);
 
3100
            logg("^Clamd was NOT notified: Can't connect to clamd on %s:%d\n",
 
3101
                    inet_ntoa(server2.sin_addr), ntohs(server2.sin_port));
 
3102
            perror("connect()");
 
3103
***************
 
3104
*** 111,133 ****
 
3105
        return 1;
 
3106
      }
 
3107
  
 
3108
!     if(write(sockd, "RELOAD", 6) < 0) {
 
3109
        logg("^Clamd was NOT notified: Could not write to %s socket\n", socktype);
 
3110
        perror("write()");
 
3111
!       close(sockd);
 
3112
        return 1;
 
3113
      }
 
3114
  
 
3115
      /* TODO: Handle timeout */
 
3116
      memset(buff, 0, sizeof(buff));
 
3117
!     if((bread = read(sockd, buff, sizeof(buff))) > 0)
 
3118
        if(!strstr(buff, "RELOADING")) {
 
3119
            logg("^Clamd was NOT notified: Unknown answer from clamd: '%s'\n", buff);
 
3120
!           close(sockd);
 
3121
            return 1;
 
3122
        }
 
3123
  
 
3124
!     close(sockd);
 
3125
      logg("Clamd successfully notified about the update.\n");
 
3126
      return 0;
 
3127
  }
 
3128
--- 129,151 ----
 
3129
        return 1;
 
3130
      }
 
3131
  
 
3132
!     if(send(sockd, "RELOAD", 6, 0) < 0) {
 
3133
        logg("^Clamd was NOT notified: Could not write to %s socket\n", socktype);
 
3134
        perror("write()");
 
3135
!       closesocket(sockd);
 
3136
        return 1;
 
3137
      }
 
3138
  
 
3139
      /* TODO: Handle timeout */
 
3140
      memset(buff, 0, sizeof(buff));
 
3141
!     if((bread = recv(sockd, buff, sizeof(buff), 0)) > 0)
 
3142
        if(!strstr(buff, "RELOADING")) {
 
3143
            logg("^Clamd was NOT notified: Unknown answer from clamd: '%s'\n", buff);
 
3144
!           closesocket(sockd);
 
3145
            return 1;
 
3146
        }
 
3147
  
 
3148
!     closesocket(sockd);
 
3149
      logg("Clamd successfully notified about the update.\n");
 
3150
      return 0;
 
3151
  }
 
3152
*** /home/njh/src/clamav-devel/./clamd/server-th.c      2007-02-12 15:39:21.000000000 +0000
 
3153
--- ./clamd/server-th.c 2007-02-12 15:39:54.000000000 +0000
 
3154
***************
 
3155
*** 303,308 ****
 
3156
--- 303,309 ----
 
3157
      logg("*Listening daemon: PID: %d\n", getpid());
 
3158
      max_threads = cfgopt(copt, "MaxThreads")->numarg;
 
3159
  
 
3160
 
3161
      if(cfgopt(copt, "ScanArchive")->enabled) {
 
3162
  
 
3163
        /* set up limits */
 
3164
***************
 
3165
*** 516,522 ****
 
3166
      time(&start_time);
 
3167
  
 
3168
      for(;;) {                         
 
3169
!       struct stat st_buf;
 
3170
        int socketd = socketds[0];
 
3171
        if(nsockets > 1) {
 
3172
            int pollret = poll_fds(socketds, nsockets, -1);
 
3173
--- 517,525 ----
 
3174
      time(&start_time);
 
3175
  
 
3176
      for(;;) {                         
 
3177
! #if   !defined(C_WINDOWS) && !defined(C_BEOS)
 
3178
!               struct stat st_buf;
 
3179
! #endif
 
3180
        int socketd = socketds[0];
 
3181
        if(nsockets > 1) {
 
3182
            int pollret = poll_fds(socketds, nsockets, -1);
 
3183
***************
 
3184
*** 525,531 ****
 
3185
            } else {
 
3186
                socketd = socketds[0]; /* on a poll error use the first socket */
 
3187
            }
 
3188
!       }    
 
3189
        if(fstat(socketd, &st_buf) == -1) {
 
3190
            logg("!fstat(): socket descriptor gone\n");
 
3191
            memmove(socketds, socketds + 1, sizeof(socketds[0]) * nsockets);
 
3192
--- 528,535 ----
 
3193
            } else {
 
3194
                socketd = socketds[0]; /* on a poll error use the first socket */
 
3195
            }
 
3196
!       } 
 
3197
! #if   !defined(C_WINDOWS) && !defined(C_BEOS)
 
3198
        if(fstat(socketd, &st_buf) == -1) {
 
3199
            logg("!fstat(): socket descriptor gone\n");
 
3200
            memmove(socketds, socketds + 1, sizeof(socketds[0]) * nsockets);
 
3201
***************
 
3202
*** 535,540 ****
 
3203
--- 539,545 ----
 
3204
                break;
 
3205
            }
 
3206
        }
 
3207
+ #endif
 
3208
        new_sd = accept(socketd, NULL, NULL);
 
3209
        if((new_sd == -1) && (errno != EINTR)) {
 
3210
            if(progexit) {
 
3211
*** /home/njh/src/clamav-devel/./clamd/localserver.c    2007-02-11 16:14:40.000000000 +0000
 
3212
--- ./clamd/localserver.c       2007-02-11 16:15:10.000000000 +0000
 
3213
***************
 
3214
*** 24,32 ****
 
3215
--- 24,36 ----
 
3216
  #include <stdio.h>
 
3217
  #include <string.h>
 
3218
  #include <sys/types.h>
 
3219
+ #ifndef       C_WINDOWS
 
3220
  #include <sys/socket.h>
 
3221
+ #endif
 
3222
  #include <sys/stat.h>
 
3223
+ #ifndef       C_WINDOWS
 
3224
  #include <sys/un.h>
 
3225
+ #endif
 
3226
  #include <errno.h>
 
3227
  #ifdef HAVE_UNISTD_H
 
3228
  #include <unistd.h>
 
3229
*** /home/njh/src/clamav-devel/./clamdscan/clamdscan.c  2007-02-11 16:10:59.000000000 +0000
 
3230
--- ./clamdscan/clamdscan.c     2007-02-11 16:11:26.000000000 +0000
 
3231
***************
 
3232
*** 16,21 ****
 
3233
--- 16,26 ----
 
3234
   *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
3235
   *  MA 02110-1301, USA.
 
3236
   */
 
3237
+  
 
3238
+ #ifdef        _MSC_VER
 
3239
+ #include <windows.h>
 
3240
+ #include <winsock.h>
 
3241
+ #endif
 
3242
  
 
3243
  #if HAVE_CONFIG_H
 
3244
  #include "clamav-config.h"
 
3245
***************
 
3246
*** 24,31 ****
 
3247
--- 29,44 ----
 
3248
  #include <stdio.h>
 
3249
  #include <string.h>
 
3250
  #include <stdlib.h>
 
3251
+ #ifdef        HAVE_UNISTD_H
 
3252
  #include <unistd.h>
 
3253
+ #endif
 
3254
+ #ifdef        C_WINDOWS
 
3255
+ #ifdef        CL_THREAD_SAFE
 
3256
+ #include <pthread.h>
 
3257
+ #endif
 
3258
+ #else
 
3259
  #include <sys/time.h>
 
3260
+ #endif
 
3261
  #include <time.h>
 
3262
  #include <signal.h>
 
3263
  
 
3264
***************
 
3265
*** 48,61 ****
 
3266
  {
 
3267
        int ds, dms, ret, infected;
 
3268
        struct timeval t1, t2;
 
3269
        struct timezone tz;
 
3270
        time_t starttime;
 
3271
        struct optstruct *opt;
 
3272
        const char *clamdscan_accepted[] = { "help", "version", "verbose", "quiet",
 
3273
                                  "stdout", "log", "move", "copy", "remove",
 
3274
                                  "config-file", "no-summary",
 
3275
                                  "disable-summary", "multiscan", NULL };
 
3276
 
3277
  
 
3278
      opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, clamdscan_accepted);
 
3279
      if(!opt) {
 
3280
--- 61,82 ----
 
3281
  {
 
3282
        int ds, dms, ret, infected;
 
3283
        struct timeval t1, t2;
 
3284
+ #ifndef       C_WINDOWS
 
3285
        struct timezone tz;
 
3286
+ #endif
 
3287
        time_t starttime;
 
3288
        struct optstruct *opt;
 
3289
        const char *clamdscan_accepted[] = { "help", "version", "verbose", "quiet",
 
3290
                                  "stdout", "log", "move", "copy", "remove",
 
3291
                                  "config-file", "no-summary",
 
3292
                                  "disable-summary", "multiscan", NULL };
 
3293
!                                 
 
3294
! #ifdef        C_WINDOWS
 
3295
!       if(!pthread_win32_process_attach_np()) {
 
3296
!               mprintf("!Can't start the win32 pthreads layer\n");
 
3297
!               return 1;
 
3298
!       }
 
3299
! #endif
 
3300
  
 
3301
      opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, clamdscan_accepted);
 
3302
      if(!opt) {
 
3303
***************
 
3304
*** 104,116 ****
 
3305
      time(&starttime);
 
3306
      /* ctime() does \n, but I need it once more */
 
3307
  
 
3308
!     gettimeofday(&t1, &tz);
 
3309
  
 
3310
      ret = client(opt, &infected);
 
3311
  
 
3312
      /* TODO: Implement STATUS in clamd */
 
3313
      if(!opt_check(opt, "disable-summary") && !opt_check(opt, "no-summary")) {
 
3314
        gettimeofday(&t2, &tz);
 
3315
        ds = t2.tv_sec - t1.tv_sec;
 
3316
        dms = t2.tv_usec - t1.tv_usec;
 
3317
        ds -= (dms < 0) ? (1):(0);
 
3318
--- 125,145 ----
 
3319
      time(&starttime);
 
3320
      /* ctime() does \n, but I need it once more */
 
3321
  
 
3322
! #ifdef        C_WINDOWS
 
3323
!       gettimeofday(&t1, NULL);
 
3324
! #else
 
3325
!       gettimeofday(&t1, &tz);
 
3326
! #endif
 
3327
  
 
3328
      ret = client(opt, &infected);
 
3329
  
 
3330
      /* TODO: Implement STATUS in clamd */
 
3331
      if(!opt_check(opt, "disable-summary") && !opt_check(opt, "no-summary")) {
 
3332
+ #ifdef        C_WINDOWS
 
3333
+       gettimeofday(&t2, NULL);
 
3334
+ #else
 
3335
        gettimeofday(&t2, &tz);
 
3336
+ #endif
 
3337
        ds = t2.tv_sec - t1.tv_sec;
 
3338
        dms = t2.tv_usec - t1.tv_usec;
 
3339
        ds -= (dms < 0) ? (1):(0);
 
3340
***************
 
3341
*** 127,132 ****
 
3342
--- 156,170 ----
 
3343
      }
 
3344
  
 
3345
      opt_free(opt);
 
3346
 
3347
+ #ifdef        C_WINDOWS
 
3348
+       WSACleanup();
 
3349
+       if(!pthread_win32_process_detach_np()) {
 
3350
+               mprintf("!Can't stop the win32 pthreads layer\n");
 
3351
+               return 1;
 
3352
+       }
 
3353
+ #endif
 
3354
 
3355
      exit(ret);
 
3356
  }
 
3357
  
 
3358
*** /home/njh/src/clamav-devel/./clamdscan/client.c     2007-02-11 16:10:59.000000000 +0000
 
3359
--- ./clamdscan/client.c        2007-02-11 16:11:16.000000000 +0000
 
3360
***************
 
3361
*** 16,37 ****
 
3362
--- 16,44 ----
 
3363
   *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
3364
   *  MA 02110-1301, USA.
 
3365
   */
 
3366
+ #ifdef        _MSC_VER
 
3367
+ #include <winsock.h>
 
3368
+ #endif
 
3369
  
 
3370
  #if HAVE_CONFIG_H
 
3371
  #include "clamav-config.h"
 
3372
  #endif
 
3373
  
 
3374
  #include <stdio.h>
 
3375
+ #ifdef        HAVE_UNISTD_H
 
3376
  #include <unistd.h>
 
3377
+ #endif
 
3378
  #include <string.h>
 
3379
  #include <sys/types.h>
 
3380
  #include <sys/stat.h>
 
3381
+ #ifndef       C_WINDOWS
 
3382
  #include <sys/socket.h>
 
3383
  #include <sys/un.h>
 
3384
  #include <netinet/in.h>
 
3385
  #include <arpa/inet.h>
 
3386
  #include <netdb.h>
 
3387
  #include <utime.h>
 
3388
+ #endif
 
3389
  #include <errno.h>
 
3390
  
 
3391
  #ifdef HAVE_SYS_UIO_H
 
3392
***************
 
3393
*** 54,65 ****
 
3394
--- 61,140 ----
 
3395
  # define SOCKET_INET  AF_INET
 
3396
  #endif
 
3397
  
 
3398
+ #ifndef       C_WINDOWS
 
3399
+ #define       closesocket(s)  close(s)
 
3400
+ #endif
 
3401
 
3402
  /* #define ENABLE_FD_PASSING      FIXME: Doesn't work yet */
 
3403
  
 
3404
  void move_infected(const char *filename, const struct optstruct *opt);
 
3405
  int notremoved = 0, notmoved = 0;
 
3406
  static int ncore = 0;
 
3407
  
 
3408
+ #ifdef        C_WINDOWS
 
3409
+ static  int     get_a_line(int sockd, char *buf, size_t len);
 
3410
 
3411
+ static int
 
3412
+ dsresult(int sockd, const struct optstruct *opt)
 
3413
+ {
 
3414
+       char buff[BUFSIZ], *pt;
 
3415
+       int infected = 0, waserror = 0;
 
3416
 
3417
+       while(get_a_line(sockd, buff, sizeof(buff))) {
 
3418
+               if(strstr(buff, "FOUND\n")) {
 
3419
+                       infected++;
 
3420
+                       logg("%s", buff);
 
3421
+                       if(opt_check(opt, "move") || opt_check(opt, "copy")) {
 
3422
+                               /* filename: Virus FOUND */
 
3423
+                               if((pt = strrchr(buff, ':'))) {
 
3424
+                                       *pt = 0;
 
3425
+                                       move_infected(buff, opt);
 
3426
+                               } else
 
3427
+                                       mprintf("@Broken data format. File not %s.\n", opt_check(opt, "move") ? "moved" : "copied");
 
3428
+                       } else if(opt_check(opt, "remove")) {
 
3429
+                               if(!(pt = strrchr(buff, ':')))
 
3430
+                                       mprintf("@Broken data format. File not removed.\n");
 
3431
+                               else {
 
3432
+                                       *pt = 0;
 
3433
+                                       if(unlink(buff)) {
 
3434
+                                               mprintf("%s: Can't remove.\n", buff);
 
3435
+                                               logg("%s: Can't remove.\n", buff);
 
3436
+                                               notremoved++;
 
3437
+                                       } else {
 
3438
+                                               mprintf("%s: Removed.\n", buff);
 
3439
+                                               logg("%s: Removed.\n", buff);
 
3440
+                                       }
 
3441
+                               }
 
3442
+                       }
 
3443
+               }
 
3444
 
3445
+               if(strstr(buff, "ERROR\n")) {
 
3446
+                       logg("%s", buff);
 
3447
+                       waserror = 1;
 
3448
+               }
 
3449
+       }
 
3450
 
3451
+       return infected ? infected : (waserror ? -1 : 0);
 
3452
+ }
 
3453
 
3454
+ static int
 
3455
+ get_a_line(int sockd, char *buf, size_t len)
 
3456
+ {
 
3457
+       char *ptr;
 
3458
 
3459
+       for(ptr = buf; ptr < &buf[len]; ptr++) {
 
3460
+               /* FIXME: very inefficient to call recv so many times */
 
3461
+               if(recv(sockd, ptr, sizeof(char), 0) <= 0)
 
3462
+                       return 0;
 
3463
+               if(*ptr == '\n') {
 
3464
+                       *++ptr = '\0';
 
3465
+                       return 1;
 
3466
+               }
 
3467
+       }
 
3468
+       return 1;
 
3469
+ }
 
3470
 
3471
+ #else
 
3472
  static int dsresult(int sockd, const struct optstruct *opt)
 
3473
  {
 
3474
        int infected = 0, waserror = 0;
 
3475
***************
 
3476
*** 67,76 ****
 
3477
        FILE *fd;
 
3478
  
 
3479
  
 
3480
! #ifndef C_OS2
 
3481
      if((fd = fdopen(dup(sockd), "r")) == NULL) {
 
3482
! #else /* FIXME: accoriding to YD OS/2 does not support dup() for sockets */
 
3483
!     if((fd = fdopen(sockd, "r")) == NULL) {
 
3484
  #endif
 
3485
        logg("^Can't open descriptor for reading.\n");
 
3486
        return -1;
 
3487
--- 142,151 ----
 
3488
        FILE *fd;
 
3489
  
 
3490
  
 
3491
! #ifndef (C_OS2)
 
3492
      if((fd = fdopen(dup(sockd), "r")) == NULL) {
 
3493
! #else /* FIXME: according to YD OS/2 does not support dup() for sockets */
 
3494
!     if((fd = fdopen(sockd, "rb")) == NULL) {
 
3495
  #endif
 
3496
        logg("^Can't open descriptor for reading.\n");
 
3497
        return -1;
 
3498
***************
 
3499
*** 80,92 ****
 
3500
        if(strstr(buff, "FOUND\n")) {
 
3501
            infected++;
 
3502
            logg("%s", buff);
 
3503
!           if(opt_check(opt, "move") || opt_check(opt, "copy")) {
 
3504
                /* filename: Virus FOUND */
 
3505
                if((pt = strrchr(buff, ':'))) {
 
3506
                    *pt = 0;
 
3507
                    move_infected(buff, opt);
 
3508
                } else {
 
3509
!                   mprintf("@Broken data format. File not %s.\n", opt_check(opt, "move") ? "moved" : "copied");
 
3510
                }
 
3511
  
 
3512
            } else if(opt_check(opt, "remove")) {
 
3513
--- 155,167 ----
 
3514
        if(strstr(buff, "FOUND\n")) {
 
3515
            infected++;
 
3516
            logg("%s", buff);
 
3517
!           if(opt_check(opt, "move")) {
 
3518
                /* filename: Virus FOUND */
 
3519
                if((pt = strrchr(buff, ':'))) {
 
3520
                    *pt = 0;
 
3521
                    move_infected(buff, opt);
 
3522
                } else {
 
3523
!                   mprintf("@Broken data format. File not moved.\n");
 
3524
                }
 
3525
  
 
3526
            } else if(opt_check(opt, "remove")) {
 
3527
***************
 
3528
*** 118,123 ****
 
3529
--- 193,199 ----
 
3530
  
 
3531
      return infected ? infected : (waserror ? -1 : 0);
 
3532
  }
 
3533
+ #endif        /* C_WINDOWS */
 
3534
  
 
3535
  static int dsfile(int sockd, const char *scantype, const char *filename, const struct optstruct *opt)
 
3536
  {
 
3537
***************
 
3538
*** 128,134 ****
 
3539
      scancmd = mcalloc(strlen(filename) + 20, sizeof(char));
 
3540
      sprintf(scancmd, "%s %s", scantype, filename);
 
3541
  
 
3542
!     if(write(sockd, scancmd, strlen(scancmd)) <= 0) {
 
3543
        logg("^Can't write to the socket.\n");
 
3544
        free(scancmd);
 
3545
        return -1;
 
3546
--- 204,210 ----
 
3547
      scancmd = mcalloc(strlen(filename) + 20, sizeof(char));
 
3548
      sprintf(scancmd, "%s %s", scantype, filename);
 
3549
  
 
3550
!     if(send(sockd, scancmd, strlen(scancmd), 0) <= 0) {
 
3551
        logg("^Can't write to the socket.\n");
 
3552
        free(scancmd);
 
3553
        return -1;
 
3554
***************
 
3555
*** 202,208 ****
 
3556
        char buff[4096], *pt;
 
3557
  
 
3558
  
 
3559
!     if(write(sockd, "STREAM", 6) <= 0) {
 
3560
        logg("^Can't write to the socket.\n");
 
3561
        return 2;
 
3562
      }
 
3563
--- 278,284 ----
 
3564
        char buff[4096], *pt;
 
3565
  
 
3566
  
 
3567
!     if(send(sockd, "STREAM", 6, 0) <= 0) {
 
3568
        logg("^Can't write to the socket.\n");
 
3569
        return 2;
 
3570
      }
 
3571
***************
 
3572
*** 312,318 ****
 
3573
--- 388,396 ----
 
3574
  
 
3575
  static int dconnect(const struct optstruct *opt)
 
3576
  {
 
3577
+ #ifndef       C_WINDOWS
 
3578
        struct sockaddr_un server;
 
3579
+ #endif
 
3580
        struct sockaddr_in server2;
 
3581
        struct hostent *he;
 
3582
        struct cfgstruct *copt, *cpt;
 
3583
***************
 
3584
*** 328,341 ****
 
3585
        return -1;
 
3586
      }
 
3587
  
 
3588
      memset((char *) &server, 0, sizeof(server));
 
3589
      memset((char *) &server2, 0, sizeof(server2));
 
3590
  
 
3591
      /* Set default address to connect to */
 
3592
      server2.sin_addr.s_addr = inet_addr("127.0.0.1");    
 
3593
  
 
3594
-     if((cpt = cfgopt(copt, "LocalSocket"))->enabled) {
 
3595
  
 
3596
        server.sun_family = AF_UNIX;
 
3597
        strncpy(server.sun_path, cpt->strarg, sizeof(server.sun_path));
 
3598
  
 
3599
--- 406,424 ----
 
3600
        return -1;
 
3601
      }
 
3602
  
 
3603
+ #ifndef       C_WINDOWS
 
3604
      memset((char *) &server, 0, sizeof(server));
 
3605
+ #endif
 
3606
      memset((char *) &server2, 0, sizeof(server2));
 
3607
  
 
3608
      /* Set default address to connect to */
 
3609
      server2.sin_addr.s_addr = inet_addr("127.0.0.1");    
 
3610
  
 
3611
  
 
3612
+     if((cpt = cfgopt(copt, "LocalSocket"))->enabled) {
 
3613
+ #ifdef        C_WINDOWS
 
3614
+       logg("^LocalSocket is not supported under Windows");
 
3615
+ #else
 
3616
        server.sun_family = AF_UNIX;
 
3617
        strncpy(server.sun_path, cpt->strarg, sizeof(server.sun_path));
 
3618
  
 
3619
***************
 
3620
*** 353,360 ****
 
3621
--- 436,452 ----
 
3622
            freecfg(copt);
 
3623
            return -1;
 
3624
        }
 
3625
+ #endif
 
3626
  
 
3627
      } else if((cpt = cfgopt(copt, "TCPSocket"))->enabled) {
 
3628
+ #ifdef  C_WINDOWS
 
3629
+                 WSADATA wsaData;
 
3630
 
3631
+                 if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) {
 
3632
+                         logg("!Error at WSAStartup(): %d\n", WSAGetLastError());
 
3633
+                         return -1;
 
3634
+                 }
 
3635
+ #endif
 
3636
  
 
3637
        if((sockd = socket(SOCKET_INET, SOCK_STREAM, 0)) < 0) {
 
3638
            perror("socket()");
 
3639
***************
 
3640
*** 368,374 ****
 
3641
  
 
3642
        if((cpt = cfgopt(copt, "TCPAddr"))->enabled) {
 
3643
            if ((he = gethostbyname(cpt->strarg)) == 0) {
 
3644
!               close(sockd);
 
3645
                perror("gethostbyname()");
 
3646
                logg("^Can't lookup clamd hostname.\n");
 
3647
                freecfg(copt);
 
3648
--- 460,466 ----
 
3649
  
 
3650
        if((cpt = cfgopt(copt, "TCPAddr"))->enabled) {
 
3651
            if ((he = gethostbyname(cpt->strarg)) == 0) {
 
3652
!               closesocket(sockd);
 
3653
                perror("gethostbyname()");
 
3654
                logg("^Can't lookup clamd hostname.\n");
 
3655
                freecfg(copt);
 
3656
***************
 
3657
*** 378,384 ****
 
3658
        }
 
3659
  
 
3660
        if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) {
 
3661
!           close(sockd);
 
3662
            perror("connect()");
 
3663
            logg("^Can't connect to clamd.\n");
 
3664
            freecfg(copt);
 
3665
--- 470,476 ----
 
3666
        }
 
3667
  
 
3668
        if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) {
 
3669
!           closesocket(sockd);
 
3670
            perror("connect()");
 
3671
            logg("^Can't connect to clamd.\n");
 
3672
            freecfg(copt);
 
3673
***************
 
3674
*** 430,436 ****
 
3675
        else
 
3676
            errors++;
 
3677
  
 
3678
!       close(sockd);
 
3679
  
 
3680
  #if defined(ENABLE_FD_PASSING) && defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN)
 
3681
      } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */
 
3682
--- 522,528 ----
 
3683
        else
 
3684
            errors++;
 
3685
  
 
3686
!       closesocket(sockd);
 
3687
  
 
3688
  #if defined(ENABLE_FD_PASSING) && defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN)
 
3689
      } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */
 
3690
***************
 
3691
*** 488,494 ****
 
3692
                        else
 
3693
                            errors++;
 
3694
  
 
3695
!                       close(sockd);
 
3696
                        break;
 
3697
  
 
3698
                    default:
 
3699
--- 580,586 ----
 
3700
                        else
 
3701
                            errors++;
 
3702
  
 
3703
!                       closesocket(sockd);
 
3704
                        break;
 
3705
  
 
3706
                    default:
 
3707
***************
 
3708
*** 510,520 ****
 
3709
        struct stat fstat, mfstat;
 
3710
        int n, len, movefilename_size;
 
3711
        int moveflag = opt_check(opt, "move");
 
3712
        struct utimbuf ubuf;
 
3713
  
 
3714
  
 
3715
      if((moveflag && !(movedir = opt_arg(opt, "move"))) ||
 
3716
!         (!moveflag && !(movedir = opt_arg(opt, "copy")))) {
 
3717
          /* Should never reach here */
 
3718
          logg("^opt_arg() returned NULL\n");
 
3719
          notmoved++;
 
3720
--- 602,614 ----
 
3721
        struct stat fstat, mfstat;
 
3722
        int n, len, movefilename_size;
 
3723
        int moveflag = opt_check(opt, "move");
 
3724
+ #ifndef       C_WINDOWS
 
3725
        struct utimbuf ubuf;
 
3726
+ #endif
 
3727
  
 
3728
  
 
3729
      if((moveflag && !(movedir = opt_arg(opt, "move"))) ||
 
3730
!        (!moveflag && !(movedir = opt_arg(opt, "copy")))) {
 
3731
          /* Should never reach here */
 
3732
          logg("^opt_arg() returned NULL\n");
 
3733
          notmoved++;
 
3734
***************
 
3735
*** 585,591 ****
 
3736
         }
 
3737
      }
 
3738
  
 
3739
!     if(!moveflag || rename(filename, movefilename) == -1) {
 
3740
        if(filecopy(filename, movefilename) == -1) {
 
3741
            logg("^cannot %s '%s' to '%s': %s\n", (moveflag) ? "move" : "copy", filename, movefilename, strerror(errno));
 
3742
            notmoved++;
 
3743
--- 679,685 ----
 
3744
         }
 
3745
      }
 
3746
  
 
3747
!     if(rename(filename, movefilename) == -1) {
 
3748
        if(filecopy(filename, movefilename) == -1) {
 
3749
            logg("^cannot %s '%s' to '%s': %s\n", (moveflag) ? "move" : "copy", filename, movefilename, strerror(errno));
 
3750
            notmoved++;
 
3751
***************
 
3752
*** 596,604 ****
 
3753
--- 690,700 ----
 
3754
        chmod(movefilename, fstat.st_mode);
 
3755
        chown(movefilename, fstat.st_uid, fstat.st_gid);
 
3756
  
 
3757
+ #ifndef       C_WINDOWS
 
3758
        ubuf.actime = fstat.st_atime;
 
3759
        ubuf.modtime = fstat.st_mtime;
 
3760
        utime(movefilename, &ubuf);
 
3761
+ #endif
 
3762
  
 
3763
        if(moveflag && unlink(filename)) {
 
3764
            logg("^cannot unlink '%s': %s\n", filename, strerror(errno));
 
3765
***************
 
3766
*** 608,614 ****
 
3767
        }
 
3768
      }
 
3769
  
 
3770
!     logg("%s: %s to '%s'\n", (moveflag)?"moved":"copied", filename, movefilename);
 
3771
  
 
3772
      free(movefilename);
 
3773
  }
 
3774
--- 704,710 ----
 
3775
        }
 
3776
      }
 
3777
  
 
3778
!     logg("%s: %s to '%s'\n", (moveflag) ? "moved" : "copied", filename, movefilename);
 
3779
  
 
3780
      free(movefilename);
 
3781
  }
 
3782
*** /home/njh/src/clamav-devel/./clamconf/clamconf.c    2007-02-11 16:13:08.000000000 +0000
 
3783
--- ./clamconf/clamconf.c       2007-02-11 16:12:52.000000000 +0000
 
3784
***************
 
3785
*** 26,32 ****
 
3786
--- 26,34 ----
 
3787
  #include <string.h>
 
3788
  #include <sys/types.h>
 
3789
  #include <sys/stat.h>
 
3790
+ #ifdef        HAVE_UNISTD_H
 
3791
  #include <unistd.h>
 
3792
+ #endif
 
3793
  
 
3794
  #include "cfgparser.h"
 
3795
  #define _GNU_SOURCE
 
3796
*** /home/njh/src/clamav-devel/./sigtool/sigtool.c      2007-02-10 00:08:29.000000000 +0000
 
3797
--- ./sigtool/sigtool.c 2006-11-05 10:16:14.000000000 +0000
 
3798
***************
 
3799
*** 36,41 ****
 
3800
--- 36,42 ----
 
3801
  #include <sys/un.h>
 
3802
  #include <netinet/in.h>
 
3803
  #include <arpa/inet.h>
 
3804
+ #include <clamav.h>
 
3805
  #include <sys/wait.h>
 
3806
  #include <dirent.h>
 
3807
  
 
3808
***************
 
3809
*** 52,58 ****
 
3810
  #include "shared/misc.h"
 
3811
  #include "shared/cdiff.h"
 
3812
  
 
3813
- #include "libclamav/clamav.h"
 
3814
  #include "libclamav/cvd.h"
 
3815
  #include "libclamav/others.h"
 
3816
  #include "libclamav/str.h"
 
3817
--- 53,58 ----
 
3818
***************
 
3819
*** 147,153 ****
 
3820
  {
 
3821
        const char *fname;
 
3822
        char *newname, buff[512], *decoded;
 
3823
!       int fd1, fd2, bytes;
 
3824
  
 
3825
  
 
3826
      fname = opt_arg(opt, "utf16-decode");
 
3827
--- 147,153 ----
 
3828
  {
 
3829
        const char *fname;
 
3830
        char *newname, buff[512], *decoded;
 
3831
!       int ret = CL_CLEAN, fd1, fd2, bytes;
 
3832
  
 
3833
  
 
3834
      fname = opt_arg(opt, "utf16-decode");
 
3835
***************
 
3836
*** 218,259 ****
 
3837
  #endif
 
3838
  
 
3839
  
 
3840
-     if((pt = getenv("SIGNDPASS"))) {
 
3841
-       strncpy(pass, pt, sizeof(pass));
 
3842
-     } else {
 
3843
-       fflush(stdin);
 
3844
-       mprintf("Password: ");
 
3845
 
3846
- #ifdef HAVE_TERMIOS_H
 
3847
-       if(tcgetattr(0, &old)) {
 
3848
-           mprintf("!getdsig: tcgetattr() failed\n");
 
3849
-           return NULL;
 
3850
-       }
 
3851
-       new = old;
 
3852
-       new.c_lflag &= ~ECHO;
 
3853
-       if(tcsetattr(0, TCSAFLUSH, &new)) {
 
3854
-           mprintf("!getdsig: tcsetattr() failed\n");
 
3855
-           return NULL;
 
3856
-       }
 
3857
- #endif
 
3858
 
3859
-       if(fgets(pass, sizeof(pass), stdin)) {
 
3860
-           cli_chomp(pass);
 
3861
-       } else {
 
3862
-           mprintf("!getdsig: Can't get password\n");
 
3863
-           return NULL;
 
3864
-       }
 
3865
 
3866
- #ifdef HAVE_TERMIOS_H
 
3867
-       if(tcsetattr(0, TCSAFLUSH, &old)) {
 
3868
-           mprintf("!getdsig: tcsetattr() failed\n", host);
 
3869
-           memset(pass, 0, strlen(pass));
 
3870
-           return NULL;
 
3871
-       }
 
3872
- #endif
 
3873
-       mprintf("\n");
 
3874
-     }
 
3875
 
3876
  #ifdef PF_INET
 
3877
      if((sockd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
 
3878
  #else
 
3879
--- 218,223 ----
 
3880
***************
 
3881
*** 261,267 ****
 
3882
  #endif
 
3883
        perror("socket()");
 
3884
        mprintf("!getdsig: Can't create socket\n");
 
3885
-       memset(pass, 0, strlen(pass));
 
3886
        return NULL;
 
3887
      }
 
3888
  
 
3889
--- 225,230 ----
 
3890
***************
 
3891
*** 273,283 ****
 
3892
          close(sockd);
 
3893
        perror("connect()");
 
3894
        mprintf("!getdsig: Can't connect to ClamAV Signing Service at %s\n", host);
 
3895
-       memset(pass, 0, strlen(pass));
 
3896
        return NULL;
 
3897
      }
 
3898
      memset(cmd, 0, sizeof(cmd));
 
3899
  
 
3900
      if(mode == 1)
 
3901
        snprintf(cmd, sizeof(cmd) - datalen, "ClamSignPSS:%s:%s:", user, pass);
 
3902
      else
 
3903
--- 236,281 ----
 
3904
          close(sockd);
 
3905
        perror("connect()");
 
3906
        mprintf("!getdsig: Can't connect to ClamAV Signing Service at %s\n", host);
 
3907
        return NULL;
 
3908
      }
 
3909
 
3910
      memset(cmd, 0, sizeof(cmd));
 
3911
  
 
3912
+     fflush(stdin);
 
3913
+     mprintf("Password: ");
 
3914
 
3915
+ #ifdef HAVE_TERMIOS_H
 
3916
+     if(tcgetattr(0, &old)) {
 
3917
+       mprintf("!getdsig: tcgetattr() failed\n", host);
 
3918
+       close(sockd);
 
3919
+       return NULL;
 
3920
+     }
 
3921
+     new = old;
 
3922
+     new.c_lflag &= ~ECHO;
 
3923
+     if(tcsetattr(0, TCSAFLUSH, &new)) {
 
3924
+       mprintf("!getdsig: tcsetattr() failed\n", host);
 
3925
+       close(sockd);
 
3926
+       return NULL;
 
3927
+     }
 
3928
+ #endif
 
3929
 
3930
+     if(fgets(pass, sizeof(pass), stdin)) {
 
3931
+       cli_chomp(pass);
 
3932
+     } else {
 
3933
+       mprintf("!getdsig: Can't get password\n");
 
3934
+       close(sockd);
 
3935
+       return NULL;
 
3936
+     }
 
3937
 
3938
+ #ifdef HAVE_TERMIOS_H
 
3939
+     if(tcsetattr(0, TCSAFLUSH, &old)) {
 
3940
+       mprintf("!getdsig: tcsetattr() failed\n", host);
 
3941
+       close(sockd);
 
3942
+       return NULL;
 
3943
+     }
 
3944
+ #endif
 
3945
+     mprintf("\n");
 
3946
 
3947
      if(mode == 1)
 
3948
        snprintf(cmd, sizeof(cmd) - datalen, "ClamSignPSS:%s:%s:", user, pass);
 
3949
      else
 
3950
***************
 
3951
*** 300,322 ****
 
3952
      memset(pass, 0, strlen(pass));
 
3953
      memset(buff, 0, sizeof(buff));
 
3954
  
 
3955
!     if((bread = cli_readn(sockd, buff, sizeof(buff))) > 0) {
 
3956
        if(!strstr(buff, "Signature:")) {
 
3957
            mprintf("!getdsig: Error generating digital signature\n");
 
3958
            mprintf("!getdsig: Answer from remote server: %s\n", buff);
 
3959
            close(sockd);
 
3960
            return NULL;
 
3961
        } else {
 
3962
!           mprintf("Signature received (length = %u)\n", strlen(buff) - 10);
 
3963
        }
 
3964
-     } else {
 
3965
-       mprintf("!getdsig: Communication error with remote server\n");
 
3966
-       close(sockd);
 
3967
-       return NULL;
 
3968
      }
 
3969
  
 
3970
      close(sockd);
 
3971
 
3972
      pt = buff;
 
3973
      pt += 10;
 
3974
      return strdup(pt);
 
3975
--- 298,315 ----
 
3976
      memset(pass, 0, strlen(pass));
 
3977
      memset(buff, 0, sizeof(buff));
 
3978
  
 
3979
!     if((bread = read(sockd, buff, sizeof(buff))) > 0) {
 
3980
        if(!strstr(buff, "Signature:")) {
 
3981
            mprintf("!getdsig: Error generating digital signature\n");
 
3982
            mprintf("!getdsig: Answer from remote server: %s\n", buff);
 
3983
            close(sockd);
 
3984
            return NULL;
 
3985
        } else {
 
3986
!          /* mprintf("Signature received (length = %d)\n", strlen(buff) - 10); */
 
3987
        }
 
3988
      }
 
3989
  
 
3990
      close(sockd);
 
3991
      pt = buff;
 
3992
      pt += 10;
 
3993
      return strdup(pt);
 
3994
***************
 
3995
*** 328,334 ****
 
3996
        int i;
 
3997
        struct stat sb;
 
3998
        char file[32], *md5;
 
3999
!       char *extlist[] = { "db", "fp", "hdb", "mdb", "ndb", "pdb", "rmd", "zmd", "sdb", "cfg", NULL };
 
4000
  
 
4001
  
 
4002
      snprintf(file, sizeof(file), "%s.info", db);
 
4003
--- 321,327 ----
 
4004
        int i;
 
4005
        struct stat sb;
 
4006
        char file[32], *md5;
 
4007
!       char *extlist[] = { "db", "fp", "hdb", "mdb", "ndb", "pdb", "rmd", "zmd", "sdb", NULL };
 
4008
  
 
4009
  
 
4010
      snprintf(file, sizeof(file), "%s.info", db);
 
4011
***************
 
4012
*** 494,504 ****
 
4013
  {
 
4014
        int ret, inc = 1, dn;
 
4015
        size_t bytes;
 
4016
!       unsigned int sigs = 0, oldsigs = 0, lines = 0, version, real_header, fl;
 
4017
        struct stat foo;
 
4018
        char buffer[FILEBUFF], *tarfile, *gzfile, header[513], smbuff[32],
 
4019
             builder[32], *pt, *dbname, olddb[512], patch[32], broken[32];
 
4020
!         struct cl_engine *engine = NULL;
 
4021
        FILE *tar, *cvd;
 
4022
        gzFile *gz;
 
4023
        time_t timet;
 
4024
--- 487,497 ----
 
4025
  {
 
4026
        int ret, inc = 1, dn;
 
4027
        size_t bytes;
 
4028
!       unsigned int sigs = 0, oldsigs = 0, lines = 0, version, real_header;
 
4029
        struct stat foo;
 
4030
        char buffer[FILEBUFF], *tarfile, *gzfile, header[513], smbuff[32],
 
4031
             builder[32], *pt, *dbname, olddb[512], patch[32], broken[32];
 
4032
!         struct cl_node *root = NULL;
 
4033
        FILE *tar, *cvd;
 
4034
        gzFile *gz;
 
4035
        time_t timet;
 
4036
***************
 
4037
*** 529,539 ****
 
4038
        return -1;
 
4039
      }
 
4040
  
 
4041
!     if((ret = cl_load(".", &engine, &sigs, CL_DB_STDOPT))) {
 
4042
        mprintf("!build: Can't load database: %s\n", cl_strerror(ret));
 
4043
        return -1;
 
4044
      } else {
 
4045
!       cl_free(engine);
 
4046
      }
 
4047
  
 
4048
      if(!sigs) {
 
4049
--- 522,532 ----
 
4050
        return -1;
 
4051
      }
 
4052
  
 
4053
!     if((ret = cl_loaddbdir(".", &root, &sigs))) {
 
4054
        mprintf("!build: Can't load database: %s\n", cl_strerror(ret));
 
4055
        return -1;
 
4056
      } else {
 
4057
!       cl_free(root);
 
4058
      }
 
4059
  
 
4060
      if(!sigs) {
 
4061
***************
 
4062
*** 549,557 ****
 
4063
                countlines("main.fp") + countlines("daily.fp");
 
4064
  
 
4065
        if(lines != sigs) {
 
4066
!           mprintf("^build: Signatures in database: %d, loaded by libclamav: %d\n", lines, sigs);
 
4067
!           mprintf("^build: Please check the current directory and remove unnecessary databases\n");
 
4068
!           mprintf("^build: or install the latest ClamAV version.\n");
 
4069
        }
 
4070
      }
 
4071
  
 
4072
--- 542,551 ----
 
4073
                countlines("main.fp") + countlines("daily.fp");
 
4074
  
 
4075
        if(lines != sigs) {
 
4076
!           mprintf("!build: Signatures in database: %d, loaded by libclamav: %d\n", lines, sigs);
 
4077
!           mprintf("!build: Please check the current directory and remove unnecessary databases\n");
 
4078
!           mprintf("!build: or install the latest ClamAV version.\n");
 
4079
!           return -1;
 
4080
        }
 
4081
      }
 
4082
  
 
4083
***************
 
4084
*** 562,591 ****
 
4085
      else
 
4086
        dbname = "daily";
 
4087
  
 
4088
 
4089
!     if(opt->filename) {
 
4090
!       if(cli_strbcasestr(opt->filename, ".cvd")) {
 
4091
!           strncpy(olddb, opt->filename, sizeof(olddb));
 
4092
!           inc = 0;
 
4093
!       } else if(cli_strbcasestr(opt->filename, ".inc")) {
 
4094
!           snprintf(olddb, sizeof(olddb), "%s/%s.info", opt->filename, dbname);
 
4095
!       } else {
 
4096
!           mprintf("!build: The optional argument points to neither CVD nor incremental directory\n");
 
4097
!           return -1;
 
4098
!       }
 
4099
 
4100
!     } else {
 
4101
!       pt = freshdbdir();
 
4102
!       snprintf(olddb, sizeof(olddb), "%s/%s.inc/%s.info", pt, dbname, dbname);
 
4103
!       if(stat(olddb, &foo) == -1) {
 
4104
!           inc = 0;
 
4105
!           snprintf(olddb, sizeof(olddb), "%s/%s.cvd", pt, dbname);
 
4106
!       }
 
4107
!       free(pt);
 
4108
      }
 
4109
  
 
4110
      if(!(oldcvd = cl_cvdhead(olddb))) {
 
4111
!       mprintf("^build: CAN'T READ CVD HEADER OF CURRENT DATABASE %s\n", olddb);
 
4112
        sleep(3);
 
4113
      }
 
4114
  
 
4115
--- 556,572 ----
 
4116
      else
 
4117
        dbname = "daily";
 
4118
  
 
4119
!     pt = freshdbdir();
 
4120
!     snprintf(olddb, sizeof(olddb), "%s/%s.inc/%s.info", pt, dbname, dbname);
 
4121
!     if(stat(olddb, &foo) == -1) {
 
4122
!       inc = 0;
 
4123
!       snprintf(olddb, sizeof(olddb), "%s/%s.cvd", pt, dbname);
 
4124
      }
 
4125
  
 
4126
+     free(pt);
 
4127
 
4128
      if(!(oldcvd = cl_cvdhead(olddb))) {
 
4129
!       mprintf("^build: CAN'T READ CVD HEADER OF CURRENT DATABASE %s\n", buffer);
 
4130
        sleep(3);
 
4131
      }
 
4132
  
 
4133
***************
 
4134
*** 621,634 ****
 
4135
      strcat(header, smbuff);
 
4136
  
 
4137
      /* functionality level */
 
4138
!     if(!strcmp(dbname, "main")) {
 
4139
!       fflush(stdin);
 
4140
!       mprintf("Functionality level: ");
 
4141
!       scanf("%u", &fl);
 
4142
!     } else {
 
4143
!       fl = cl_retflevel();
 
4144
!     }
 
4145
!     sprintf(smbuff, "%u:", fl);
 
4146
      strcat(header, smbuff);
 
4147
  
 
4148
      real_header = strlen(header);
 
4149
--- 602,608 ----
 
4150
      strcat(header, smbuff);
 
4151
  
 
4152
      /* functionality level */
 
4153
!     sprintf(smbuff, "%d:", cl_retflevel());
 
4154
      strcat(header, smbuff);
 
4155
  
 
4156
      real_header = strlen(header);
 
4157
***************
 
4158
*** 636,653 ****
 
4159
      /* add fake MD5 and dsig (for writeinfo) */
 
4160
      strcat(header, "X:X:");
 
4161
  
 
4162
!     if((pt = getenv("SIGNDUSER"))) {
 
4163
!       strncpy(builder, pt, sizeof(builder));
 
4164
      } else {
 
4165
!       /* ask for builder name */
 
4166
!       fflush(stdin);
 
4167
!       mprintf("Builder name: ");
 
4168
!       if(fgets(builder, sizeof(builder), stdin)) {
 
4169
!           cli_chomp(builder);
 
4170
!       } else {
 
4171
!           mprintf("!build: Can't get builder name\n");
 
4172
!           return -1;
 
4173
!       }
 
4174
      }
 
4175
  
 
4176
      /* add builder */
 
4177
--- 610,623 ----
 
4178
      /* add fake MD5 and dsig (for writeinfo) */
 
4179
      strcat(header, "X:X:");
 
4180
  
 
4181
!     /* ask for builder name */
 
4182
!     fflush(stdin);
 
4183
!     mprintf("Builder name: ");
 
4184
!     if(fgets(builder, sizeof(builder), stdin)) {
 
4185
!       cli_chomp(builder);
 
4186
      } else {
 
4187
!       mprintf("!build: Can't get builder name\n");
 
4188
!       return -1;
 
4189
      }
 
4190
  
 
4191
      /* add builder */
 
4192
***************
 
4193
*** 683,689 ****
 
4194
                                 "daily.fp", "main.mdb", "daily.mdb",
 
4195
                                 "daily.info", "main.info", "main.wdb",
 
4196
                                 "daily.wdb", "main.pdb", "daily.pdb",
 
4197
-                                "main.cfg", "daily.cfg",
 
4198
                                 NULL };
 
4199
                args[2] = tarfile;
 
4200
                if(!opt_check(opt, "debug")) {
 
4201
--- 653,658 ----
 
4202
***************
 
4203
*** 842,862 ****
 
4204
      mprintf("Created %s\n", pt);
 
4205
  
 
4206
      /* generate patch */
 
4207
!     if(opt->filename) {
 
4208
!       strncpy(olddb, opt->filename, sizeof(olddb));
 
4209
      } else {
 
4210
!       if(inc) {
 
4211
!           pt = freshdbdir();
 
4212
!           snprintf(olddb, sizeof(olddb), "%s/%s.inc", pt, dbname);
 
4213
!           free(pt);
 
4214
!       } else {
 
4215
!           pt = freshdbdir();
 
4216
!           snprintf(olddb, sizeof(olddb), "%s/%s.cvd", pt, dbname);
 
4217
!           free(pt);
 
4218
!       }
 
4219
!     }
 
4220
  
 
4221
-     if(!inc) {
 
4222
        pt = cli_gentemp(NULL);
 
4223
        if(mkdir(pt, 0700)) {
 
4224
            mprintf("!build: Can't create temporary directory %s\n", pt);
 
4225
--- 811,825 ----
 
4226
      mprintf("Created %s\n", pt);
 
4227
  
 
4228
      /* generate patch */
 
4229
!     if(inc) {
 
4230
!       pt = freshdbdir();
 
4231
!       snprintf(olddb, sizeof(olddb), "%s/%s.inc", pt, dbname);
 
4232
!       free(pt);
 
4233
      } else {
 
4234
!       pt = freshdbdir();
 
4235
!       snprintf(olddb, sizeof(olddb), "%s/%s.cvd", pt, dbname);
 
4236
!       free(pt);
 
4237
  
 
4238
        pt = cli_gentemp(NULL);
 
4239
        if(mkdir(pt, 0700)) {
 
4240
            mprintf("!build: Can't create temporary directory %s\n", pt);
 
4241
***************
 
4242
*** 1697,1709 ****
 
4243
      mprintf("    --html-normalise=FILE                  create normalised parts of HTML file\n");
 
4244
      mprintf("    --utf16-decode=FILE                    decode UTF16 encoded files\n");
 
4245
      mprintf("    --info=FILE            -i FILE         print database information\n");
 
4246
!     mprintf("    --build=NAME [cvd/inc] -b NAME         build a CVD file\n");
 
4247
      mprintf("    --server=ADDR                          ClamAV Signing Service address\n");
 
4248
      mprintf("    --unpack=FILE          -u FILE         Unpack a CVD file\n");
 
4249
      mprintf("    --unpack-current=SHORTNAME             Unpack local CVD/INCDIR in cwd\n");
 
4250
      mprintf("    --list-sigs[=FILE]     -l[FILE]        List signature names\n");
 
4251
      mprintf("    --vba=FILE                             Extract VBA/Word6 macro code\n");
 
4252
      mprintf("    --vba-hex=FILE                         Extract Word6 macro code with hex values\n");
 
4253
      mprintf("    --diff=OLD NEW         -d OLD NEW      Create diff for OLD and NEW CVDs\n");
 
4254
      mprintf("    --run-cdiff=FILE       -r FILE         Execute update script FILE in cwd\n");
 
4255
      mprintf("    --verify-cdiff=DIFF CVD/INCDIR         Verify DIFF against CVD\n");
 
4256
--- 1660,1673 ----
 
4257
      mprintf("    --html-normalise=FILE                  create normalised parts of HTML file\n");
 
4258
      mprintf("    --utf16-decode=FILE                    decode UTF16 encoded files\n");
 
4259
      mprintf("    --info=FILE            -i FILE         print database information\n");
 
4260
!     mprintf("    --build=NAME           -b NAME         build a CVD file\n");
 
4261
      mprintf("    --server=ADDR                          ClamAV Signing Service address\n");
 
4262
      mprintf("    --unpack=FILE          -u FILE         Unpack a CVD file\n");
 
4263
      mprintf("    --unpack-current=SHORTNAME             Unpack local CVD/INCDIR in cwd\n");
 
4264
      mprintf("    --list-sigs[=FILE]     -l[FILE]        List signature names\n");
 
4265
      mprintf("    --vba=FILE                             Extract VBA/Word6 macro code\n");
 
4266
      mprintf("    --vba-hex=FILE                         Extract Word6 macro code with hex values\n");
 
4267
+     mprintf("    --vba-hex=FILE                         Extract Word6 macro code with hex values\n");
 
4268
      mprintf("    --diff=OLD NEW         -d OLD NEW      Create diff for OLD and NEW CVDs\n");
 
4269
      mprintf("    --run-cdiff=FILE       -r FILE         Execute update script FILE in cwd\n");
 
4270
      mprintf("    --verify-cdiff=DIFF CVD/INCDIR         Verify DIFF against CVD\n");
 
4271
*** /home/njh/src/clamav-devel/./sigtool/vba.c  2007-02-11 14:41:15.000000000 +0000
 
4272
--- ./sigtool/vba.c     2006-11-05 10:16:14.000000000 +0000
 
4273
***************
 
4274
*** 25,48 ****
 
4275
  #include <sys/stat.h>
 
4276
  #include <fcntl.h>
 
4277
  #include <dirent.h>
 
4278
  #include <ctype.h>
 
4279
  
 
4280
! #include "libclamav/clamav.h"
 
4281
! #include "libclamav/vba_extract.h"
 
4282
! #include "libclamav/others.h"
 
4283
! #include "libclamav/cltypes.h"
 
4284
! #include "libclamav/ole2_extract.h"
 
4285
  
 
4286
  typedef struct mac_token_tag
 
4287
  {
 
4288
      unsigned char token;
 
4289
!     const unsigned char *str;
 
4290
  } mac_token_t;
 
4291
  
 
4292
  typedef struct mac_token2_tag
 
4293
  {
 
4294
      uint16_t token;
 
4295
!     const unsigned char *str;
 
4296
  
 
4297
  } mac_token2_t;
 
4298
  
 
4299
--- 25,48 ----
 
4300
  #include <sys/stat.h>
 
4301
  #include <fcntl.h>
 
4302
  #include <dirent.h>
 
4303
+ #include <clamav.h>
 
4304
  #include <ctype.h>
 
4305
  
 
4306
! #include "../libclamav/vba_extract.h"
 
4307
! #include "../libclamav/others.h"
 
4308
! #include "../libclamav/cltypes.h"
 
4309
! #include "../libclamav/ole2_extract.h"
 
4310
  
 
4311
  typedef struct mac_token_tag
 
4312
  {
 
4313
      unsigned char token;
 
4314
!     unsigned char *str;
 
4315
  } mac_token_t;
 
4316
  
 
4317
  typedef struct mac_token2_tag
 
4318
  {
 
4319
      uint16_t token;
 
4320
!     unsigned char *str;
 
4321
  
 
4322
  } mac_token2_t;
 
4323