libs/lmo: fix possible null pointer dereference in lmo_lookup() - thanks blogic
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 19 Aug 2009 21:36:10 +0000 (21:36 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 19 Aug 2009 21:36:10 +0000 (21:36 +0000)
libs/lmo/src/lmo_core.c

index 17467f2..ab2410f 100644 (file)
@@ -207,8 +207,12 @@ int lmo_lookup(lmo_archive_t *ar, const char *key, char *dest, int len)
 {
        uint32_t look_key = sfh_hash(key, strlen(key));
        int copy_len = -1;
 {
        uint32_t look_key = sfh_hash(key, strlen(key));
        int copy_len = -1;
+       lmo_entry_t *entry;
 
 
-       lmo_entry_t *entry = ar->index;
+       if( !ar )
+               return copy_len;
+
+       entry = ar->index;
 
        while( entry != NULL )
        {
 
        while( entry != NULL )
        {