fix overlapping copy found by address sanitizer

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@7022 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 182fb464826a442d0b9febf885262b91db27765b
Former-commit-id: 997133ef9e46e552783d7d70aac6a6efa7a46d09
This commit is contained in:
iobyte 2020-05-05 22:28:04 +00:00
parent 38785391eb
commit 72cd04351c

View file

@ -242,8 +242,11 @@ void* GetFileHandle(const char* RobotName)
{
void* RobotSettings = NULL;
strncpy(BufName, RobotName, BUFSIZE - 1); // Save robot's name
BufName[BUFSIZE - 1] = '\0';
if (BufName != RobotName) // Don't copy if same names
{
strncpy(BufName, RobotName, BUFSIZE - 1); // Save robot's name
BufName[BUFSIZE - 1] = '\0';
}
snprintf(BufPathDirRel, BUFSIZE, // Robot's directory
"drivers/%s",RobotName); // relative to installation
snprintf(BufPathXMLRel, BUFSIZE, // Robot's xml-filename