diff options
author | Kenta Sato <tosainu.maple@gmail.com> | 2023-05-08 18:26:03 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-05-08 18:26:03 +0100 |
commit | c28e7a2b2f23dbd246a1ad7ad7aaa6f7ab2e5887 (patch) | |
tree | 2489c969d5feeda7cce01cdb55684de7e4089858 /src/job.c | |
parent | d619d6a9c6fa0e4295c817a88f84f0bab9457bbe (diff) |
patch 9.0.1527: crash when using negative value for term_colsv9.0.1527
Problem: Crash when using negative value for term_cols.
Solution: Check for invalid term_cols value. (Kenta Sato, closes #12362)
Diffstat (limited to 'src/job.c')
-rw-r--r-- | src/job.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -272,7 +272,8 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2) *lp = tv_get_number(item); if (*lp < 0) { - semsg(_(e_invalid_value_for_argument_str_str), hi->hi_key, tv_get_string(item)); + semsg(_(e_invalid_value_for_argument_str_str), + hi->hi_key, tv_get_string(item)); return FAIL; } } @@ -444,10 +445,19 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2) } else if (STRCMP(hi->hi_key, "term_cols") == 0) { + int error = FALSE; + if (!(supported2 & JO2_TERM_COLS)) break; opt->jo_set2 |= JO2_TERM_COLS; - opt->jo_term_cols = tv_get_number(item); + opt->jo_term_cols = tv_get_number_chk(item, &error); + if (error) + return FAIL; + if (opt->jo_term_cols < 0 || opt->jo_term_cols > 1000) + { + semsg(_(e_invalid_value_for_argument_str), "term_cols"); + return FAIL; + } } else if (STRCMP(hi->hi_key, "vertical") == 0) { |