git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1235 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2005/01/08 10:29:48... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Sat Jan 8 02:25:58 CET 2005 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav: Fix cli_writeint32 alignment problem on SPARC (reported by |
|
4 |
+ Andy Fiddaman <clam*fiddaman.net>) |
|
5 |
+ |
|
1 | 6 |
Fri Jan 7 13:50:52 GMT 2005 (njh) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav/mbox.c: Fix to "content-type: application" which could cause |
... | ... |
@@ -530,18 +530,23 @@ int32_t cli_readint32(const char *buff) |
530 | 530 |
#if WORDS_BIGENDIAN == 0 |
531 | 531 |
ret = *(int32_t *) buff; |
532 | 532 |
#else |
533 |
- int32_t shift, i = 0; |
|
534 |
- |
|
535 |
- ret = 0; |
|
536 |
- for(shift = 0; shift < 32; shift += 8) { |
|
537 |
- ret |= (buff[i] & 0xff ) << shift; |
|
538 |
- i++; |
|
539 |
- } |
|
533 |
+ ret = buff[0] & 0xff; |
|
534 |
+ ret |= (buff[1] & 0xff) << 8; |
|
535 |
+ ret |= (buff[2] & 0xff) << 16; |
|
536 |
+ ret |= (buff[3] & 0xff) << 24; |
|
540 | 537 |
#endif |
541 | 538 |
|
542 | 539 |
return ret; |
543 | 540 |
} |
544 | 541 |
|
542 |
+void cli_writeint32(char *offset, uint32_t value) |
|
543 |
+{ |
|
544 |
+ offset[0] = value & 0xff; |
|
545 |
+ offset[1] = (value & 0xff00) >> 8; |
|
546 |
+ offset[2] = (value & 0xff0000) >> 16; |
|
547 |
+ offset[3] = (value & 0xff000000) >> 24; |
|
548 |
+} |
|
549 |
+ |
|
545 | 550 |
int cli_memstr(const char *haystack, int hs, const char *needle, int ns) |
546 | 551 |
{ |
547 | 552 |
const char *pt, *hay; |
... | ... |
@@ -35,6 +35,7 @@ char *cli_md5file(const char *filename); |
35 | 35 |
int cli_readn(int fd, void *buff, unsigned int count); |
36 | 36 |
int cli_writen(int fd, void *buff, unsigned int count); |
37 | 37 |
int32_t cli_readint32(const char *buff); |
38 |
+void cli_writeint32(char *offset, uint32_t value); |
|
38 | 39 |
char *cli_gentemp(const char *dir); |
39 | 40 |
unsigned int cli_rndnum(unsigned int max); |
40 | 41 |
int cli_memstr(const char *haystack, int hs, const char *needle, int ns); |
... | ... |
@@ -68,17 +68,6 @@ |
68 | 68 |
\x63\x6C\x61\x6D\x61\x76\x2E\x6E\x65\x74\x0D\x0A\x24\x00\x00\x00\ |
69 | 69 |
" |
70 | 70 |
|
71 |
-#if WORDS_BIGENDIAN == 0 |
|
72 |
-#define EC32(v) (v) |
|
73 |
-#else |
|
74 |
-static inline uint32_t EC32(uint32_t v) |
|
75 |
-{ |
|
76 |
- return ((v >> 24) | ((v & 0x00FF0000) >> 8) | ((v & 0x0000FF00) << 8) | (v << 24)); |
|
77 |
-} |
|
78 |
-#endif |
|
79 |
- |
|
80 |
-#define cli_writeint32(offset,value) *(uint32_t *)(offset) = EC32(value) |
|
81 |
- |
|
82 | 71 |
/* PE from UPX */ |
83 | 72 |
|
84 | 73 |
int pefromupx (char *src, char *dst, int *dsize, uint32_t ep, uint32_t upx0, uint32_t upx1, uint32_t magic) |