mirror of
https://github.com/nzbget/nzbget.git
synced 2025-12-23 22:27:45 -05:00
fix compile warning: -Wstringop-truncation / -Wstringop-overflow
This commit is contained in:
@@ -812,7 +812,8 @@ bool RemoteClient::RequestServerEditQueue(DownloadQueue::EEditAction action, int
|
||||
char *names = trailingData + textLen + idLength;
|
||||
for (CString& name : nameList)
|
||||
{
|
||||
int len = strlen(name);
|
||||
// "len" must be less or equal than: "buffer size" - "already used buffer" - "ending \0"
|
||||
size_t len = strnlen(name, length - (names - trailingData) - 1);
|
||||
strncpy(names, name, len + 1);
|
||||
names += len + 1;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST_CASE("BString", "[NString][Quick]")
|
||||
REQUIRE(!strcmp(str2, "0123456789 Hi, Worl"));
|
||||
|
||||
BString<20> str3;
|
||||
strncpy(str3, "Hello, 0123456789 world", str3.Capacity());
|
||||
memcpy(str3, "Hello, 0123456789 world", str3.Capacity());
|
||||
str3[str3.Capacity()] = '\0';
|
||||
REQUIRE(!strcmp(str3, "Hello, 0123456789 w"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user