{"id":444,"date":"2008-10-10T15:58:01","date_gmt":"2008-10-10T13:58:01","guid":{"rendered":"http:\/\/daniel.haxx.se\/blog\/?p=444"},"modified":"2008-10-10T20:24:31","modified_gmt":"2008-10-10T18:24:31","slug":"another-curl-scan-shows-work-to-do","status":"publish","type":"post","link":"https:\/\/daniel.haxx.se\/blog\/2008\/10\/10\/another-curl-scan-shows-work-to-do\/","title":{"rendered":"Another curl scan shows work to do"},"content":{"rendered":"<p>The nice guys on <a href=\"http:\/\/www.coverity.com\/\">Coverity<\/a> did a new scan on curl (the 7.19.0 source code) and they dug a bunch of new flaws. The previous version they checked was 7.16.1, release some 20 months before. The new changes are not only because of how the code has changed in the mean time, but it seems their scanner have improved a bit since the last time as well!<\/p>\n<p>Here&#8217;s a sample view of how libcurl might dereference a NULL pointer with a step-by-step explanation on what conditions that lead to the flaw:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-445\" title=\"coverity-sample\" src=\"http:\/\/daniel.haxx.se\/blog\/wp-content\/uploads\/2008\/10\/coverity-sample.png\" alt=\"\" width=\"400\" height=\"406\" srcset=\"https:\/\/daniel.haxx.se\/blog\/wp-content\/uploads\/2008\/10\/coverity-sample.png 400w, https:\/\/daniel.haxx.se\/blog\/wp-content\/uploads\/2008\/10\/coverity-sample-147x150.png 147w, https:\/\/daniel.haxx.se\/blog\/wp-content\/uploads\/2008\/10\/coverity-sample-295x300.png 295w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>They identify 22 flaws and I found it interesting to compare the top list of bad functions as reported by Coverity with the <a href=\"http:\/\/daniel.haxx.se\/blog\/2008\/10\/07\/curl-cyclomatic-complexity\/\">complexity list<\/a> I showed the other day. First we need to ignore the 9 flaws Coverity found in the &#8216;curl&#8217; tool code (i.e not within the library). Then the 10 remaining functions with flaws marked by Coverity are:<\/p>\n<ul>\n<li>Curl_getinfo (4 flaws, all the other ones have one each)<\/li>\n<li><strong>Curl_cookie_add<\/strong> (present in the complexity top-10 table)<\/li>\n<li><strong>FormAdd<\/strong> (present in the complexity top-10 table)<\/li>\n<li>parsedate<\/li>\n<li>ftp_parse_url_path<\/li>\n<li>tftp_do<\/li>\n<li>resolve_server<\/li>\n<li>curl_easy_pause<\/li>\n<li>add_closure<\/li>\n<li>Curl_connect<\/li>\n<\/ul>\n<p>See? Only two of them were present in that list. The Coverity tool does in fact also count the complexity for each function, and while it doesn&#8217;t match the values <a href=\"http:\/\/www.parisc-linux.org\/~bame\/pmccabe\/overview.html\">pmccabe<\/a> shows exactly, they seem to agree in general about what functions that are the most complex ones.<\/p>\n<p>Ok, now let&#8217;s go work on fixing all these problems&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The nice guys on Coverity did a new scan on curl (the 7.19.0 source code) and they dug a bunch of new flaws. The previous version they checked was 7.16.1, release some 20 months before. The new changes are not only because of how the code has changed in the mean time, but it seems &hellip; <a href=\"https:\/\/daniel.haxx.se\/blog\/2008\/10\/10\/another-curl-scan-shows-work-to-do\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Another curl scan shows work to do<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[196,33],"class_list":["post-444","post","type-post","status-publish","format-standard","hentry","category-curl","tag-coveritycom","tag-curl-and-libcurl"],"_links":{"self":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/comments?post=444"}],"version-history":[{"count":0,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/444\/revisions"}],"wp:attachment":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/media?parent=444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/categories?post=444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/tags?post=444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}