Fix text replacement warning

Using strncpy to cut off copying a terminating NUL yields a gcc
warning.  Just use memcpy instead.
This commit is contained in:
Dean Luick
2021-01-17 14:12:58 -06:00
parent 5dc5ece412
commit f63d435c6d
4 changed files with 5 additions and 5 deletions

View File

@@ -157,7 +157,7 @@ VA_DECL(const char *, line)
/* truncate, preserving the final 3 characters:
"___ extremely long text" -> "___ extremely l...ext"
(this may be suboptimal if overflow is less than 3) */
(void) strncpy(pbuf + BUFSZ - 1 - 6, "...", 3);
memcpy(pbuf + BUFSZ - 1 - 6, "...", 3);
/* avoid strncpy; buffers could overlap if excess is small */
pbuf[BUFSZ - 1 - 3] = line[ln - 3];
pbuf[BUFSZ - 1 - 2] = line[ln - 2];