summaryrefslogtreecommitdiffhomepage
path: root/libs/lmo
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-08-19 22:10:24 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-08-19 22:10:24 +0000
commit83e4af43aa71b2958a429c9f2ebd4a3dd1815841 (patch)
treeab0585ed97d46871a5f4b84048982cd864c55301 /libs/lmo
parent68f335b8d6e3f96c0e35d2b2021d5995e0f536e7 (diff)
libs/lmo: fix off-by-one in bounds check, null-terminate dest buffer in lmo_lookup()
Diffstat (limited to 'libs/lmo')
-rw-r--r--libs/lmo/src/lmo_core.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libs/lmo/src/lmo_core.c b/libs/lmo/src/lmo_core.c
index ab2410f46..55696af9c 100644
--- a/libs/lmo/src/lmo_core.c
+++ b/libs/lmo/src/lmo_core.c
@@ -218,8 +218,9 @@ int lmo_lookup(lmo_archive_t *ar, const char *key, char *dest, int len)
{
if( entry->key_id == look_key )
{
- copy_len = (len > entry->length) ? entry->length : len;
+ copy_len = ((len - 1) > entry->length) ? entry->length : (len - 1);
memcpy(dest, &ar->mmap[entry->offset], copy_len);
+ data[copy_len] = '\0';
break;
}