static lmo_entry_t * lmo_find_entry(lmo_archive_t *ar, uint32_t hash)
{
unsigned int m, l, r;
+ uint32_t k;
l = 0;
r = ar->length - 1;
if (r < l)
break;
- if (ar->index[m].key_id == hash)
+ k = ntohl(ar->index[m].key_id);
+
+ if (k == hash)
return &ar->index[m];
- if (ar->index[m].key_id > hash)
+ if (k > hash)
{
if (!m)
break;
if (!key || !_lmo_active_catalog)
return -2;
- hash = htonl(lmo_canon_hash(key, keylen));
+ hash = lmo_canon_hash(key, keylen);
for (ar = _lmo_active_catalog->archives; ar; ar = ar->next)
{
if ((e = lmo_find_entry(ar, hash)) != NULL)
{
- *out = ar->mmap + e->offset;
- *outlen = e->length;
+ *out = ar->mmap + ntohl(e->offset);
+ *outlen = ntohl(e->length);
return 0;
}
}