don't ever set pointer outside of buffer
authorDaniel Golle <daniel@makrotopia.org>
Sun, 10 Jun 2018 17:03:00 +0000 (19:03 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 14 Jun 2018 16:51:22 +0000 (18:51 +0200)
even if it's not going to be used.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This work was sponsored by WIO (wiowireless.com)

ucert.c

diff --git a/ucert.c b/ucert.c
index 686589ff49dbe9a86714f7bc66c2c6a367e42ac7..6cdc2201fb3933bacfdfbb011102a167571206ee 100644 (file)
--- a/ucert.c
+++ b/ucert.c
@@ -172,9 +172,8 @@ static int cert_load(const char *certfile, struct list_head *chain) {
 
                list_add_tail(&cobj->list, chain);
                ret += pret;
-               bufpt = blob_next(bufpt);
        /* repeat parsing while there is still enough remaining data in buffer */
-       } while(len > pos + sizeof(struct blob_attr));
+       } while(len > pos + sizeof(struct blob_attr) && (bufpt = blob_next(bufpt)));
 
        return (ret <= 0);
 }