git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@976 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/10/07 03:53:13... | ... |
@@ -112,6 +112,7 @@ David S. Madole <david*madole.net> |
112 | 112 |
Joe Maimon <jmaimon*ttec.com> |
113 | 113 |
Andrey V. Malyshev <amal*krasn.ru> |
114 | 114 |
Everton da Silva Marques <everton*lab.ipaccess.diveo.net.br> |
115 |
+Alexander Marx <mad-ml*madness.at> |
|
115 | 116 |
Andrey J. Melnikoff <temnota*kmv.ru> |
116 | 117 |
Damian Menscher <menscher*uiuc.edu> |
117 | 118 |
Denis De Messemacker <ddm*clamav.net> |
... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Wed Oct 6 20:48:17 CEST 2004 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * freshclam/manager.c: fix download problems with some proxy servers |
|
4 |
+ (patch by Alexander Marx <mad-ml*madness.at>) |
|
5 |
+ |
|
1 | 6 |
Wed Oct 6 18:25:46 CEST 2004 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav/pe.c: do not report I/O error for small files with empty |
... | ... |
@@ -599,24 +599,21 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char |
599 | 599 |
free(remotename); |
600 | 600 |
free(authorization); |
601 | 601 |
|
602 |
- if ((bread = recv(socketfd, buffer, FILEBUFF, 0)) == -1) { |
|
603 |
- mprintf("@Error while reading database from %s\n", hostname); |
|
604 |
- close(fd); |
|
605 |
- unlink(file); |
|
606 |
- return 52; |
|
607 |
- } |
|
608 |
- |
|
609 |
- if ((strstr(buffer, "HTTP/1.1 404")) != NULL) { |
|
610 |
- mprintf("@%s not found on remote server\n", dbfile); |
|
611 |
- close(fd); |
|
612 |
- unlink(file); |
|
613 |
- return 58; |
|
614 |
- } |
|
602 |
+ /* read all the http headers */ |
|
615 | 603 |
|
616 | 604 |
ch = buffer; |
617 | 605 |
i = 0; |
618 | 606 |
while (1) { |
619 |
- if (*ch == '\n' && *(ch - 1) == '\r' && *(ch - 2) == '\n' && *(ch - 3) == '\r') { |
|
607 |
+ /* recv one byte at a time, until we reach \r\n\r\n */ |
|
608 |
+ |
|
609 |
+ if(recv(socketfd, buffer + i, 1, 0) == -1) { |
|
610 |
+ mprintf("@Error while reading database from %s\n", hostname); |
|
611 |
+ close(fd); |
|
612 |
+ unlink(file); |
|
613 |
+ return 52; |
|
614 |
+ } |
|
615 |
+ |
|
616 |
+ if (i>2 && *ch == '\n' && *(ch - 1) == '\r' && *(ch - 2) == '\n' && *(ch - 3) == '\r') { |
|
620 | 617 |
ch++; |
621 | 618 |
i++; |
622 | 619 |
break; |
... | ... |
@@ -625,7 +622,17 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char |
625 | 625 |
i++; |
626 | 626 |
} |
627 | 627 |
|
628 |
- write(fd, ch, bread - i); |
|
628 |
+ /* check whether the resource actually existed or not */ |
|
629 |
+ |
|
630 |
+ if ((strstr(buffer, "HTTP/1.1 404")) != NULL) { |
|
631 |
+ mprintf("@%s not found on remote server\n", dbfile); |
|
632 |
+ close(fd); |
|
633 |
+ unlink(file); |
|
634 |
+ return 58; |
|
635 |
+ } |
|
636 |
+ |
|
637 |
+ /* receive body and write it to disk */ |
|
638 |
+ |
|
629 | 639 |
while((bread = read(socketfd, buffer, FILEBUFF))) { |
630 | 640 |
write(fd, buffer, bread); |
631 | 641 |
mprintf("Downloading %s [%c]\r", dbfile, rotation[rot]); |