@aktau I looked at the code again and think we should keep the old version for the `len` computation and replace `memcpy` with `xstpncpy`. 

We would now only get problems, if `maxlen` would be bigger than the allocated range for `str` and `str` would not be `NUL` terminated. These problems are also present in the vim code, but we cannot detect them (__cannot__ use `STRLEN`).

`maxlen` seems always not to be larger than the allocated range for `str` (see the start of the only possible call chain `msg_outtrans_len_attr` -> `msg_puts_attr_len` -> `redir_write` -> `write_reg_contents` for `maxlen != -1`).