coverity/331366: fname_trans_sid: Avoid buffer overrun

Since we're printf()ing into an offset of fname_buf, we need to reduce
the max length by the same amount.
This commit is contained in:
James McCoy 2021-05-06 00:01:43 -04:00
parent 9bdbac6712
commit d4fd139c2a
No known key found for this signature in database
GPG Key ID: DFE691AE331BA3DB

View File

@ -537,7 +537,7 @@ static char_u *fname_trans_sid(const char_u *const name,
if (current_sctx.sc_sid <= 0) {
*error = ERROR_SCRIPT;
} else {
snprintf((char *)fname_buf + 3, FLEN_FIXED + 1, "%" PRId64 "_",
snprintf((char *)fname_buf + i, FLEN_FIXED + 1 - i, "%" PRId64 "_",
(int64_t)current_sctx.sc_sid);
i = (int)STRLEN(fname_buf);
}