Fix truncation warning

This commit is contained in:
Carles Fernandez 2023-03-21 09:53:16 +01:00
parent 5f5077ffc5
commit 8e1818f743
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
1 changed files with 5 additions and 2 deletions

View File

@ -2051,8 +2051,11 @@ void *ftpthread(void *arg)
break;
}
}
std::strncpy(ftp->local, local.c_str(), 1024);
ftp->local[1023] = '\0';
int ret2 = std::snprintf(ftp->local, 1024, "%s", local.c_str());
if (ret2 < 0 || ret2 >= 1024)
{
tracet(3, "Error reading ftp local\n");
}
ftp->state = 2; /* ftp completed */
tracet(3, "ftpthread: complete cmd=%s\n", cmd_str.data());