summaryrefslogtreecommitdiff
path: root/soltools
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2014-10-03 22:28:20 -0500
committerNorbert Thiebaud <nthiebaud@gmail.com>2014-10-04 08:58:12 -0500
commit9b401751a8a8b96cfe9f85eefce1173fe4cabe6f (patch)
treeccc667959e0e72001bf30e7d64ac9c71bf587cdd /soltools
parentbb78299e8ebdfc495fac44cbfaba4d6bf91b2982 (diff)
coverity#706158 Copy into fixed size buffer
Change-Id: I5d540e6e3a21b0563febb70696882439a10b9b86
Diffstat (limited to 'soltools')
-rw-r--r--soltools/mkdepend/include.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/soltools/mkdepend/include.c b/soltools/mkdepend/include.c
index f525272d8c58..d1d05a389bbe 100644
--- a/soltools/mkdepend/include.c
+++ b/soltools/mkdepend/include.c
@@ -91,11 +91,30 @@ struct inclist *inc_path(char *file, char *include, boolean dot, struct Includes
if (*p == '/')
break;
if (p == file)
- strcpy(path, include);
- else {
- strncpy(path, file, (p-file) + 1);
- path[ (p-file) + 1 ] = '\0';
- strcpy(path + (p-file) + 1, include);
+ {
+ if(strlen(include) >= BUFSIZ )
+ {
+ fatalerr("include filename too long \"%s\"\n", include);
+ }
+ else
+ {
+ strcpy(path, include);
+ }
+ }
+ else
+ {
+ int partial = (p - file);
+ int inc_len = strlen(include);
+ if(inc_len + partial >= BUFSIZ )
+ {
+ fatalerr("include filename too long \"%s\"\n", include);
+ }
+ else
+ {
+ memcpy(path, file, partial);
+ memcpy(path + partial, include, inc_len);
+ path[partial + inc_len] = 0;
+ }
}
remove_dotdot(path);
if ((exists_path(incCollection, path)) && stat(path, &st) == 0 && !( st.st_mode & S_IFDIR)) {