Mercurial > vim
comparison src/quickfix.c @ 18697:c035b4fa4bc5 v8.1.2340
patch 8.1.2340: quickfix test fails under valgrind and asan
Commit: https://github.com/vim/vim/commit/a106e6cde682bda4ad10ed745acb51975fcb02e0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 24 22:13:58 2019 +0100
patch 8.1.2340: quickfix test fails under valgrind and asan
Problem: Quickfix test fails under valgrind and asan.
Solution: Make sure long line does not overflow IObuff. (Dominique Pelle,
closes #5263) Put back fix for large terminals. (Yegappan
Lakshmanan, closes #5264)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 24 Nov 2019 22:15:03 +0100 |
parents | 022deb0adec9 |
children | d34ec6fe207d |
comparison
equal
deleted
inserted
replaced
18696:a05e744cf4f3 | 18697:c035b4fa4bc5 |
---|---|
4414 int len; | 4414 int len; |
4415 buf_T *errbuf; | 4415 buf_T *errbuf; |
4416 | 4416 |
4417 if (qfp->qf_module != NULL) | 4417 if (qfp->qf_module != NULL) |
4418 { | 4418 { |
4419 STRCPY(IObuff, qfp->qf_module); | 4419 vim_strncpy(IObuff, qfp->qf_module, IOSIZE - 1); |
4420 len = (int)STRLEN(IObuff); | 4420 len = (int)STRLEN(IObuff); |
4421 } | 4421 } |
4422 else if (qfp->qf_fnum != 0 | 4422 else if (qfp->qf_fnum != 0 |
4423 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL | 4423 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL |
4424 && errbuf->b_fname != NULL) | 4424 && errbuf->b_fname != NULL) |
4425 { | 4425 { |
4426 if (qfp->qf_type == 1) // :helpgrep | 4426 if (qfp->qf_type == 1) // :helpgrep |
4427 STRCPY(IObuff, gettail(errbuf->b_fname)); | 4427 vim_strncpy(IObuff, gettail(errbuf->b_fname), IOSIZE - 1); |
4428 else | 4428 else |
4429 { | 4429 { |
4430 // shorten the file name if not done already | 4430 // shorten the file name if not done already |
4431 if (errbuf->b_sfname == NULL | 4431 if (errbuf->b_sfname == NULL |
4432 || mch_isFullName(errbuf->b_sfname)) | 4432 || mch_isFullName(errbuf->b_sfname)) |
4433 { | 4433 { |
4434 if (*dirname == NUL) | 4434 if (*dirname == NUL) |
4435 mch_dirname(dirname, MAXPATHL); | 4435 mch_dirname(dirname, MAXPATHL); |
4436 shorten_buf_fname(errbuf, dirname, FALSE); | 4436 shorten_buf_fname(errbuf, dirname, FALSE); |
4437 } | 4437 } |
4438 STRCPY(IObuff, errbuf->b_fname); | 4438 vim_strncpy(IObuff, errbuf->b_fname, IOSIZE - 1); |
4439 } | 4439 } |
4440 len = (int)STRLEN(IObuff); | 4440 len = (int)STRLEN(IObuff); |
4441 } | 4441 } |
4442 else | 4442 else |
4443 len = 0; | 4443 len = 0; |
4444 IObuff[len++] = '|'; | 4444 |
4445 if (len < IOSIZE - 1) | |
4446 IObuff[len++] = '|'; | |
4445 | 4447 |
4446 if (qfp->qf_lnum > 0) | 4448 if (qfp->qf_lnum > 0) |
4447 { | 4449 { |
4448 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum); | 4450 vim_snprintf((char *)IObuff + len, IOSIZE - len, "%ld", qfp->qf_lnum); |
4449 len += (int)STRLEN(IObuff + len); | 4451 len += (int)STRLEN(IObuff + len); |
4450 | 4452 |
4451 if (qfp->qf_col > 0) | 4453 if (qfp->qf_col > 0) |
4452 { | 4454 { |
4453 sprintf((char *)IObuff + len, " col %d", qfp->qf_col); | 4455 vim_snprintf((char *)IObuff + len, IOSIZE - len, |
4456 " col %d", qfp->qf_col); | |
4454 len += (int)STRLEN(IObuff + len); | 4457 len += (int)STRLEN(IObuff + len); |
4455 } | 4458 } |
4456 | 4459 |
4457 sprintf((char *)IObuff + len, "%s", | 4460 vim_snprintf((char *)IObuff + len, IOSIZE - len, "%s", |
4458 (char *)qf_types(qfp->qf_type, qfp->qf_nr)); | 4461 (char *)qf_types(qfp->qf_type, qfp->qf_nr)); |
4459 len += (int)STRLEN(IObuff + len); | 4462 len += (int)STRLEN(IObuff + len); |
4460 } | 4463 } |
4461 else if (qfp->qf_pattern != NULL) | 4464 else if (qfp->qf_pattern != NULL) |
4462 { | 4465 { |
4463 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len); | 4466 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len); |
4464 len += (int)STRLEN(IObuff + len); | 4467 len += (int)STRLEN(IObuff + len); |
4465 } | 4468 } |
4466 IObuff[len++] = '|'; | 4469 if (len < IOSIZE - 2) |
4467 IObuff[len++] = ' '; | 4470 { |
4471 IObuff[len++] = '|'; | |
4472 IObuff[len++] = ' '; | |
4473 } | |
4468 | 4474 |
4469 // Remove newlines and leading whitespace from the text. | 4475 // Remove newlines and leading whitespace from the text. |
4470 // For an unrecognized line keep the indent, the compiler may | 4476 // For an unrecognized line keep the indent, the compiler may |
4471 // mark a word with ^^^^. | 4477 // mark a word with ^^^^. |
4472 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text, | 4478 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text, |