summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2013-01-27 18:18:47 +0000
committerJo-Philipp Wich <jow@openwrt.org>2013-01-27 18:18:47 +0000
commit6bec9b6bcf3906a085e0757c3ab876d300b3b99c (patch)
tree5d2380dd6f6a1395b0e6d740e9acf7bacab68e94 /libs
parent5f76dada3c0eb1e949ca3b2cf2adacaab25028eb (diff)
libs/web: further endian fixes in lmo processing
Diffstat (limited to 'libs')
-rw-r--r--libs/web/src/template_lmo.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libs/web/src/template_lmo.c b/libs/web/src/template_lmo.c
index 164999e88..27205a722 100644
--- a/libs/web/src/template_lmo.c
+++ b/libs/web/src/template_lmo.c
@@ -244,6 +244,7 @@ int lmo_change_catalog(const char *lang)
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;
@@ -255,10 +256,12 @@ static lmo_entry_t * lmo_find_entry(lmo_archive_t *ar, uint32_t hash)
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;
@@ -283,14 +286,14 @@ int lmo_translate(const char *key, int keylen, char **out, int *outlen)
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;
}
}