Menu

#214 [tsk_comparedir.cpp:164]: (error) Dangerous usage of 'fullPath' (strncpy doesn't always null-terminate it).

1.65
open
nobody
None
5
2014-08-15
2014-03-14
dcb
No

Source code is

strncpy(fullPath, m_lclDir, TSK_CD_BUFSIZE);
strncat(fullPath, a_dir, TSK_CD_BUFSIZE-strlen(fullPath));

Maybe better code might be

strncpy(fullPath, m_lclDir, TSK_CD_BUFSIZE);
fullPath[TSK_CD_BUFSIZE - 1] = '\0';
strncat(fullPath, a_dir, TSK_CD_BUFSIZE-strlen(fullPath));

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.