libs/lmo: fix off-by-one in bounds check, null-terminate dest buffer in lmo_lookup()
This commit is contained in:
parent
68f335b8d6
commit
83e4af43aa
1 changed files with 2 additions and 1 deletions
|
@ -218,8 +218,9 @@ int lmo_lookup(lmo_archive_t *ar, const char *key, char *dest, int len)
|
||||||
{
|
{
|
||||||
if( entry->key_id == look_key )
|
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);
|
memcpy(dest, &ar->mmap[entry->offset], copy_len);
|
||||||
|
data[copy_len] = '\0';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue