vim-patch:9.0.0733: use of strftime() is not safe (#21228)

Problem:    Use of strftime() is not safe.
Solution:   Check the return value of strftime().  Use a larger buffer and
            correctly pass the available space. (Dominique Pellé, closes
            vim/vim#11348)

84d14ccdb5

Co-authored-by: Dominique Pelle <dominique.pelle@gmail.com>
This commit is contained in:
zeertzjq
2022-11-29 11:18:15 +08:00
committed by GitHub
parent 65e8ed45de
commit 7328c4de54
5 changed files with 17 additions and 9 deletions

View File

@@ -8445,9 +8445,7 @@ static void f_strftime(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
p = string_convert(&conv, p, NULL);
}
char result_buf[256];
if (p != NULL) {
(void)strftime(result_buf, sizeof(result_buf), p, curtime_ptr);
} else {
if (p == NULL || strftime(result_buf, sizeof(result_buf), p, curtime_ptr) == 0) {
result_buf[0] = NUL;
}