From 3e5bd813d3978558c5e164c7819b18f51e810ec2 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Mon, 12 Aug 2013 18:30:24 +0100 Subject: [PATCH] embryo: Fix a potential buffer overflow (klocwork id 321) Signed-off-by: Daniel Willmann --- src/bin/embryo/embryo_cc_sc1.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bin/embryo/embryo_cc_sc1.c b/src/bin/embryo/embryo_cc_sc1.c index 4c49a60d24..0340d35cbb 100644 --- a/src/bin/embryo/embryo_cc_sc1.c +++ b/src/bin/embryo/embryo_cc_sc1.c @@ -679,10 +679,15 @@ setconfig(char *root) { strcat(path, "include"); } - len = strlen(path); - path[len] = DIRSEP_CHAR; - path[len + 1] = '\0'; - insert_path(path); + + /* Make sure we have enough space for the trailing DIRSEP_CHAR */ + if (strlen(path) == sizeof(path) - 1) + { + len = strlen(path); + path[len] = DIRSEP_CHAR; + path[len + 1] = '\0'; + insert_path(path); + } } /* if */ }