git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1118 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/11/23 18:07:09... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Tue Nov 23 09:06:45 GMT 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/binhex.c: Fix crash in base64 encoded binhex files reported by |
|
4 |
+ Stefan Kaltenbrunner <stefan@kaltenbrunner.cc> |
|
5 |
+ |
|
1 | 6 |
Mon Nov 22 15:20:07 GMT 2004 (njh) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav: General performance enhancements |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: binhex.c,v $ |
20 |
+ * Revision 1.7 2004/11/23 09:05:26 nigelhorne |
|
21 |
+ * Fix crash in base64 encoded binhex files |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.6 2004/11/22 15:16:53 nigelhorne |
21 | 24 |
* Use cli_realloc instead of many cli_mallocs |
22 | 25 |
* |
... | ... |
@@ -33,7 +36,7 @@ |
33 | 33 |
* First draft of binhex.c |
34 | 34 |
* |
35 | 35 |
*/ |
36 |
-static char const rcsid[] = "$Id: binhex.c,v 1.6 2004/11/22 15:16:53 nigelhorne Exp $"; |
|
36 |
+static char const rcsid[] = "$Id: binhex.c,v 1.7 2004/11/23 09:05:26 nigelhorne Exp $"; |
|
37 | 37 |
|
38 | 38 |
#include "clamav.h" |
39 | 39 |
|
... | ... |
@@ -75,7 +78,8 @@ cli_binhex(const char *dir, int desc) |
75 | 75 |
{ |
76 | 76 |
struct stat statb; |
77 | 77 |
char *buf, *start, *line; |
78 |
- size_t size, bytesleft; |
|
78 |
+ size_t size; |
|
79 |
+ int bytesleft; |
|
79 | 80 |
message *m; |
80 | 81 |
fileblob *fb; |
81 | 82 |
|
... | ... |
@@ -97,28 +101,28 @@ cli_binhex(const char *dir, int desc) |
97 | 97 |
|
98 | 98 |
cli_dbgmsg("mmap'ed binhex file\n"); |
99 | 99 |
|
100 |
- bytesleft = size; |
|
100 |
+ bytesleft = (int)size; |
|
101 | 101 |
line = NULL; |
102 | 102 |
|
103 |
- while(bytesleft) { |
|
103 |
+ while(bytesleft > 0) { |
|
104 | 104 |
int length = 0; |
105 | 105 |
char *ptr; |
106 | 106 |
|
107 |
- /* printf("%d: ", bytesleft); */ |
|
107 |
+ /*printf("%d: ", bytesleft);*/ |
|
108 | 108 |
|
109 |
- for(ptr = buf; bytesleft && (*ptr != '\r') && (*ptr != '\n'); ptr++) { |
|
109 |
+ for(ptr = buf; bytesleft && *ptr && (*ptr != '\r') && (*ptr != '\n'); ptr++) { |
|
110 | 110 |
length++; |
111 | 111 |
--bytesleft; |
112 | 112 |
} |
113 | 113 |
|
114 |
- /* printf("%d: ", length); */ |
|
114 |
+ /*printf("%d: ", length);*/ |
|
115 | 115 |
|
116 | 116 |
line = cli_realloc(line, length + 1); |
117 | 117 |
|
118 | 118 |
memcpy(line, buf, length); |
119 | 119 |
line[length] = '\0'; |
120 | 120 |
|
121 |
- /* puts(line); */ |
|
121 |
+ /*puts(line);*/ |
|
122 | 122 |
|
123 | 123 |
if(messageAddStr(m, line) < 0) |
124 | 124 |
break; |