projects
/
oweals
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
68f335b
)
libs/lmo: fix off-by-one in bounds check, null-terminate dest buffer in lmo_lookup()
author
Jo-Philipp Wich
<jow@openwrt.org>
Wed, 19 Aug 2009 22:10:24 +0000
(22:10 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Wed, 19 Aug 2009 22:10:24 +0000
(22:10 +0000)
libs/lmo/src/lmo_core.c
patch
|
blob
|
history
diff --git
a/libs/lmo/src/lmo_core.c
b/libs/lmo/src/lmo_core.c
index ab2410f462e76bd0a89ebc484c3153b2446761c5..55696af9c75e6a35d91c11a348e278f88f2c10a1 100644
(file)
--- 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;
}