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
Unified · Split
| @@ -1163,13 +1163,13 @@ static void print_buildconf(int flags, int level) · 1162 unmodified lines | ||
| 1163 | 1163 | // Change all the ' --' strings to '~--' so that |
| 1164 | 1164 | // they can be identified as tokens. |
| 1165 | 1165 | while ((conflist = strstr(str, " --")) != NULL) { |
| 1166 | − strncpy(conflist, "~--", 3); | |
| 1166 | + conflist[0] = '~'; | |
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | // Compensate for the weirdness this would cause |
| 1170 | 1170 | // when passing 'pkg-config --static'. |
| 1171 | 1171 | while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) { |
| 1172 | − strncpy(remove_tilde, "pkg-config ", 11); | |
| 1172 | + remove_tilde[sizeof("pkg-config~") - 2] = ' '; | |
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | 1175 | splitconf = strtok(str, "~"); |