From bef59476ba1b3a29aaf65caeb9930bb19b09d05c Mon Sep 17 00:00:00 2001 From: ihsinme <61293369+ihsinme@users.noreply.github.com> Date: Fri, 30 Oct 2020 17:26:12 +0300 Subject: [PATCH] fix of possible memory overflow. --- tools/autotools/tsk_comparedir.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/autotools/tsk_comparedir.cpp b/tools/autotools/tsk_comparedir.cpp index 0ab30faf8..db771d88e 100644 --- a/tools/autotools/tsk_comparedir.cpp +++ b/tools/autotools/tsk_comparedir.cpp @@ -166,18 +166,18 @@ uint8_t struct stat status; strncpy(fullPath, m_lclDir, TSK_CD_BUFSIZE); - strncat(fullPath, a_dir, TSK_CD_BUFSIZE-strlen(fullPath)); + strncat(fullPath, a_dir, TSK_CD_BUFSIZE-strlen(fullPath)-1); if ((dp = opendir(fullPath)) == NULL) { fprintf(stderr, "Error opening directory"); return 1; } while ((dirp = readdir(dp)) != NULL) { strncpy(file, a_dir, TSK_CD_BUFSIZE); - strncat(file, "/", TSK_CD_BUFSIZE-strlen(file)); - strncat(file, dirp->d_name, TSK_CD_BUFSIZE-strlen(file)); + strncat(file, "/", TSK_CD_BUFSIZE-strlen(file)-1); + strncat(file, dirp->d_name, TSK_CD_BUFSIZE-strlen(file)-1); strncpy(fullPath, m_lclDir, TSK_CD_BUFSIZE); - strncat(fullPath, file, TSK_CD_BUFSIZE-strlen(fullPath)); + strncat(fullPath, file, TSK_CD_BUFSIZE-strlen(fullPath)-1); stat(fullPath, &status); if (S_ISDIR(status.st_mode)) { -- GitLab