git-svn: trunk@1827
aCaB authored on 2006/01/24 01:34:27... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Mon Jan 23 17:09:26 CET 2006 (acab) |
|
2 |
+----------------------------------- |
|
3 |
+ * libclamav: Fixed more warnings |
|
4 |
+ Wrapped write() |
|
5 |
+ Finalized yc emulator |
|
6 |
+ |
|
1 | 7 |
Mon Jan 23 12:12:07 CET 2006 (acab) |
2 | 8 |
----------------------------------- |
3 | 9 |
* libclamav/yc.c Fix warnings |
... | ... |
@@ -193,7 +193,7 @@ static int unfsg(char *source, char *dest, int ssize, int dsize, char **endsrc, |
193 | 193 |
|
194 | 194 |
int unfsg_200(char *source, char *dest, int ssize, int dsize, uint32_t rva, uint32_t base, uint32_t ep, int file) { |
195 | 195 |
char *fake, *tsrc; |
196 |
- struct SECTION section; // Yup, just one ;) |
|
196 |
+ struct SECTION section; /* Yup, just one ;) */ |
|
197 | 197 |
|
198 | 198 |
if ( unfsg(source, dest, ssize, dsize, &fake, &fake) ) return -1; |
199 | 199 |
|
... | ... |
@@ -202,7 +202,10 @@ int unfsg_200(char *source, char *dest, int ssize, int dsize, uint32_t rva, uint |
202 | 202 |
section.vsz = dsize; |
203 | 203 |
section.rva = rva; |
204 | 204 |
if ( (tsrc = rebuildpe(dest, §ion, 1, base, ep, 0, 0)) ) { |
205 |
- write(file, tsrc, 0x148+0x80+0x28+dsize); |
|
205 |
+ if (cli_writen(file, tsrc, 0x148+0x80+0x28+dsize)==-1) { |
|
206 |
+ free(tsrc); |
|
207 |
+ return 0; |
|
208 |
+ } |
|
206 | 209 |
free(tsrc); |
207 | 210 |
} else { |
208 | 211 |
cli_dbgmsg("FSG: Rebuilding failed\n"); |
... | ... |
@@ -262,7 +265,10 @@ int unfsg_133(char *source, char *dest, int ssize, int dsize, struct SECTION *se |
262 | 262 |
} |
263 | 263 |
|
264 | 264 |
if ( (tsrc = rebuildpe(dest, sections, sectcount+1, base, ep, 0, 0)) ) { |
265 |
- write(file, tsrc, 0x148+0x80+0x28*(sectcount+1)+offs); |
|
265 |
+ if (cli_writen(file, tsrc, 0x148+0x80+0x28+dsize)==-1) { |
|
266 |
+ free(tsrc); |
|
267 |
+ return 0; |
|
268 |
+ } |
|
266 | 269 |
free(tsrc); |
267 | 270 |
} else { |
268 | 271 |
cli_dbgmsg("FSG: Rebuilding failed\n"); |
... | ... |
@@ -232,7 +232,11 @@ int petite_inflate2x_1to9(char *buf, uint32_t minrva, uint32_t bufsz, struct pe_ |
232 | 232 |
for (t = 0; t < j ; t++) |
233 | 233 |
cli_dbgmsg("Petite: .SECT%d RVA:%x VSize:%x ROffset: %x, RSize:% x\n", t, usects[t].rva, usects[t].vsz, usects[t].raw, usects[t].rsz); |
234 | 234 |
if ( (ssrc = rebuildpe(buf, usects, j, Imagebase, enc_ep, ResRva, ResSize)) ) { |
235 |
- write(desc, ssrc, 0x148+0x80+0x28*j+usects[j-1].raw+usects[j-1].rsz); |
|
235 |
+ if (cli_writen(desc, ssrc, 0x148+0x80+0x28*j+usects[j-1].raw+usects[j-1].rsz)==-1) { |
|
236 |
+ free(ssrc); |
|
237 |
+ free(usects); |
|
238 |
+ return -1; |
|
239 |
+ } |
|
236 | 240 |
free(ssrc); |
237 | 241 |
} else |
238 | 242 |
cli_dbgmsg("Petite: Rebuilding failed\n"); |
... | ... |
@@ -318,7 +322,7 @@ int petite_inflate2x_1to9(char *buf, uint32_t minrva, uint32_t bufsz, struct pe_ |
318 | 318 |
*/ |
319 | 319 |
|
320 | 320 |
if (!check4resources) { |
321 |
- int q; |
|
321 |
+ unsigned int q; |
|
322 | 322 |
for ( q = 0 ; q < sectcount ; q++ ) { |
323 | 323 |
if ( thisrva <= EC32(sections[q].VirtualAddress) || thisrva >= EC32(sections[q].VirtualAddress) + EC32(sections[q].VirtualSize)) |
324 | 324 |
continue; |
... | ... |
@@ -136,7 +136,7 @@ static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx |
136 | 136 |
if(decryptor_offset[j]=='\xC0') /* ROL AL,num */ |
137 | 137 |
{ |
138 | 138 |
j++; |
139 |
- al = ROL(al,decryptor_offset[j]); |
|
139 |
+ ROL(al,decryptor_offset[j]); |
|
140 | 140 |
} |
141 | 141 |
else /* ROR AL,num */ |
142 | 142 |
{ |
... | ... |
@@ -166,6 +166,7 @@ static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx |
166 | 166 |
|
167 | 167 |
default: |
168 | 168 |
cli_dbgmsg("yC: Unhandled opcode %x\n", (unsigned char)decryptor_offset[j]); |
169 |
+ return 1; |
|
169 | 170 |
} |
170 | 171 |
} |
171 | 172 |
cl--; |
... | ... |
@@ -182,7 +183,7 @@ static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx |
182 | 182 |
int yc_decrypt(char *fbuf, unsigned int filesize, struct pe_image_section_hdr *sections, unsigned int sectcount, uint32_t peoffset, int desc) |
183 | 183 |
{ |
184 | 184 |
uint32_t ycsect = EC32(sections[sectcount].PointerToRawData); |
185 |
- int i; |
|
185 |
+ unsigned int i; |
|
186 | 186 |
struct pe_image_file_hdr *pe = (struct pe_image_file_hdr*) (fbuf + peoffset); |
187 | 187 |
|
188 | 188 |
/* |