On Sun, May 31, 2020 at 07:24:24PM -0400, Christos Zoulas wrote: > Module Name: src > Committed By: christos > Date: Sun May 31 23:24:24 UTC 2020 > > Modified Files: > src/lib/libedit: terminal.c tty.c > > Log Message: > use strlcpy() instead of strncpy() for gcc happiness > ...
> @@ -1319,10 +1319,8 @@ terminal_settc(EditLine *el, int argc __ > if (argv == NULL || argv[1] == NULL || argv[2] == NULL) > return -1; > > - strncpy(what, ct_encode_string(argv[1], &el->el_scratch), sizeof(what)); > - what[sizeof(what) - 1] = '\0'; > - strncpy(how, ct_encode_string(argv[2], &el->el_scratch), sizeof(how)); > - how[sizeof(how) - 1] = '\0'; > + strlcpy(what, ct_encode_string(argv[1], &el->el_scratch), sizeof(what)); > + strlcpy(how, ct_encode_string(argv[2], &el->el_scratch), sizeof(how)); > This feels not good. strncpy->strlcpy has repercussions like how strlcpy doesn't zero out the remaining length and thus leaks uninitialized data. There has to be a reasonable way to handle these warnings instead of rototilling which str*cpy function is used.