1. stop doing unaligned memory accesses - htons() on a pointer to some

arbitrary point...
2. use int not long - long will be 64bit on 64bit platforms, but 32bit almost
everywhere (yes in theory it may not - but in practice, it won't - long
though will vary).


SVN revision: 34211
This commit is contained in:
Carsten Haitzler 2008-04-06 23:02:54 +00:00
parent 4d54b4aaa6
commit ec51ff71c6
1 changed files with 9 additions and 5 deletions

View File

@ -921,6 +921,8 @@ efreet_mime_shared_mimeinfo_magic_parse(char *data, int size)
} }
else else
{ {
short tshort;
if (!mime) continue; if (!mime) continue;
if (!entry) if (!entry)
{ {
@ -952,7 +954,9 @@ efreet_mime_shared_mimeinfo_magic_parse(char *data, int size)
case '=': case '=':
ptr++; ptr++;
entry->value_len = ntohs(*((short*)(ptr)));
memcpy(&tshort, ptr, sizeof(short));
entry->value_len = ntohs(tshort);
ptr += 2; ptr += 2;
entry->value = NEW(1, entry->value_len); entry->value = NEW(1, entry->value_len);
@ -1002,12 +1006,12 @@ efreet_mime_shared_mimeinfo_magic_parse(char *data, int size)
} }
else if (entry->word_size == 4) else if (entry->word_size == 4)
{ {
((long*)entry->value)[j] = ((int*)entry->value)[j] =
ntohl(((long*)entry->value)[j]); ntohl(((int*)entry->value)[j]);
if (entry->mask) if (entry->mask)
((long*)entry->mask)[j] = ((int*)entry->mask)[j] =
ntohl(((long*)entry->mask)[j]); ntohl(((int*)entry->mask)[j]);
} }
} }
} }