History

cmdutils: replace strncpy() with direct assignment

Only one character is actually rewritten. Fixes truncation warnings, such as warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation] in gcc 10.2.0

Anton Khirnov committed 5 years ago

Commit b334fd31 parent 7d095791 file · +2 −2Browse files

Unified · Split

fftools/cmdutils.c+2−2
@@ -1163,13 +1163,13 @@ static void print_buildconf(int flags, int level) · 1162 unmodified lines
11631163 // Change all the ' --' strings to '~--' so that
11641164 // they can be identified as tokens.
11651165 while ((conflist = strstr(str, " --")) != NULL) {
1166− strncpy(conflist, "~--", 3);
1166+ conflist[0] = '~';
11671167 }
11681168
11691169 // Compensate for the weirdness this would cause
11701170 // when passing 'pkg-config --static'.
11711171 while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) {
1172− strncpy(remove_tilde, "pkg-config ", 11);
1172+ remove_tilde[sizeof("pkg-config~") - 2] = ' ';
11731173 }
11741174
11751175 splitconf = strtok(str, "~");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t