Re: strcpy -> strlcpy?

看板DFBSD_kernel作者時間21年前 (2005/01/05 08:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串7/13 (看更多)
:It was primarily done in OpenBSD to avoid introducing new bugs. If I :remember right, when we did the complete tree sweep, it caught around 10 :bugs or so in the conversions. More in ports after doing a bulk build. :I wouldn't bother with it if you aren't planning to do a similar mass :conversion to strlcpy-style functions. : :Note that the patch does other things as well; it detects incorrect use of :static buffers if the buffer size specified is larger than the actual :buffer. This has found around 60-70 bugs, mainly in the ports tree (a lot :of them are sscanf string size specifiers which are off-by-one). : :Doing more complicated analyses is a pain in gcc though; I started hacking :on some stuff using CIL by George Necula at Berkeley, which makes static :analysis of real-world C much, much easier. : :-- :Anil Madhavapeddy http://anil.recoil.org It sounds like a better approach to detecting these sorts of bugs would be to have a separate code parser and analysis tool. C is actually very easy to parse (having written a C compiler I can say that with assurance), and even not all that hard to analyze. The hard part is producing the assembly/other output. I'll bet it would be easier then trying to build it directly into the GCC framework. -Matt Matthew Dillon <dillon@backplane.com>
文章代碼(AID): #11spM500 (DFBSD_kernel)
討論串 (同標題文章)
文章代碼(AID): #11spM500 (DFBSD_kernel)