Nikolay Pavlov wrote: > 2016-07-17 23:25 GMT+03:00 Bram Moolenaar <[email protected]>: > > > > Patch 7.4.2064 > > Problem: Coverity warns for possible buffer overflow. > > Solution: Use vim_strcat() instead of strcat(). > > Files: src/quickfix.c > > > > > > *** ../vim-7.4.2063/src/quickfix.c 2016-07-17 19:25:00.964690765 +0200 > > --- src/quickfix.c 2016-07-17 22:19:02.545753576 +0200 > > *************** > > *** 2595,2601 **** > > { > > while (STRLEN(buf) < 34) > > STRCAT(buf, " "); > > ! STRCAT(buf, title); > > } > > trunc_string(buf, buf, Columns - 1, IOSIZE); > > msg(buf); > > --- 2595,2601 ---- > > { > > while (STRLEN(buf) < 34) > > STRCAT(buf, " "); > > ! vim_strcat(buf, title, IOSIZE); > > This is rather inefficient code on its own. I would suggest using something > like > > const size_t buf_len = STRLEN(buf); > if (buf_len < 34) > { > memset(buf + buf_len, ' ', 34 - buf_len); > buf[34] = NUL; > } > vim_strcat(buf, title, IOSIZE); > > (may also use memcpy() for vim_strcat(), but doing this properly is > going to take 3 additional lines).
Yeah, that was a quick and short solution. Should have function for this somewhere... -- Computers are not intelligent. They only think they are. /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
