[PATCH 1/2] blspec: Do not crash on config files without newline on last line

Sascha Hauer s.hauer at pengutronix.de
Thu Feb 11 07:00:39 PST 2016


When the last line in a config file has no newline then 'next' is NULL
on the the loop iteration. Check that before derefencing 'next'.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/blspec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/blspec.c b/common/blspec.c
index d5ddb4f..0f806ca 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -75,7 +75,7 @@ static struct blspec_entry *blspec_entry_open(struct blspec *blspec,
 
 	next = buf;
 
-	while (*next) {
+	while (next && *next) {
 		char *name, *val;
 
 		line = next;
-- 
2.7.0.rc3




More information about the barebox mailing list