From 7bc642aff12f755980eaf864f72f7ebeb64a7647 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Thu, 24 Jan 2008 00:25:13 +0000 Subject: [PATCH] fix path string stuff to not be able to overflow (unlikely tho - ever) SVN revision: 33571 --- legacy/embryo/src/bin/embryo_cc_sc1.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/legacy/embryo/src/bin/embryo_cc_sc1.c b/legacy/embryo/src/bin/embryo_cc_sc1.c index 1f2073cbc8..0e3949257b 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc1.c +++ b/legacy/embryo/src/bin/embryo_cc_sc1.c @@ -697,7 +697,11 @@ setconfig(char *root) /* add the default "include" directory */ if (root != NULL) - strcpy(path, root); /* path + filename (hopefully) */ + { + /* path + filename (hopefully) */ + strncpy(path, root, sizeof(path) - 1); + path[sizeof(path) - 1] = 0; + } /* terminate just behind last \ or : */ if ((ptr = strrchr(path, DIRSEP_CHAR)) != NULL || (ptr = strchr(path, ':')) != NULL) @@ -708,7 +712,10 @@ setconfig(char *root) * to the list in that case */ *(ptr + 1) = '\0'; - strcat(path, "include"); + if (strlen(path) < (sizeof(path) - 1 - 7)) + { + strcat(path, "include"); + } len = strlen(path); path[len] = DIRSEP_CHAR; path[len + 1] = '\0';