git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 00/26] Address a couple of issues identified by Coverity

From
Stefan Beller <sbeller@google.com>
Date
Apr 26, 2017, 21:34 UTC
Message-ID
<CAGZ79kbbHshh4=WC2ymG15=W5oq98b3KTV4zxiTx0LgCLeYwfQ@mail.gmail.com>
In-Reply-To
<cover.1493237937.git.johannes.schindelin@gmx.de>

On Wed, Apr 26, 2017 at 1:19 PM, Johannes Schindelin <johannes.schindelin@gmx.de> wrote:

> I recently registered the git-for-windows fork with Coverity to ensure
> that even the Windows-specific patches get some static analysis love.

YAY! How do you trigger the coverity scan? (via travis or uploading a tarball manually every once in a while?) Can you talk about the setup? I'm interested in that as I run coverity for Junios pu branch, plus a couple patches on top[1].

[1] https://github.com/stefanbeller/git/commits/coverity
>
> While at it, I squashed a couple of obvious issues in the part that is
> not Windows-specific.
Thanks.
Show 6 quoted lines
> Note: while this patch series squashes some of those issues, the
> remaining issues are not necessarily all false positives (e.g. Coverity
> getting fooled by our FLEX_ARRAY trick into believing that the last
> member of the struct is indeed a 0 or 1 size array) or intentional (e.g.
> builtins not releasing memory because exit() is called right after
> returning from the function that leaks memory).

For the latter I think we could get away with maintaining patches on a dedicated coverity branch (which I do currently, just not in an extensive manner). For the first, I think we can just compile with FLEX_ARRAY defined as an insanely large number. I'll experiment with that.

Show 22 quoted lines
> Notable examples of the remaining issues are:
>
> - a couple of callers of shorten_unambiguous_ref() assume that they do
>   not have to release the memory returned from that function, often
>   assigning the pointer to a `const` variable that typically does not
>   hold a pointer that needs to be free()d. My hunch is that we will want
>   to convert that function to have a fixed number of static buffers and
>   use those in a round robin fashion à la sha1_to_hex().
>
> - pack-redundant.c seems to have hard-to-reason-about code paths that
>   may eventually leak memory. Essentially, the custody of the allocated
>   memory is not clear at all.
>
> - fast-import.c calls strbuf_detach() on the command_buf without any
>   obvious rationale. Turns out that *some* code paths assign
>   command_buf.buf to a `recent_command` which releases the buffer later.
>   However, from a cursory look it appears to me as if there are some
>   other code paths that skip that assignment, effectively causing a memory
>   leak once strbuf_detach() is called.
>
> Sadly, I lack the time to pursue those remaining issues further.
>

Thanks, Stefan

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 64 of 178 in “Address a couple of issues identified by Coverity”
  1. 00/26 Address a couple of issues identified by CoverityJohannes Schindelin, Apr 26, 2017
  2. 01/26 mingw: avoid memory leak when splitting PATHJohannes Schindelin, Apr 26, 2017
  3. 02/26 winansi: avoid use of uninitialized valueJohannes Schindelin, Apr 26, 2017
  4. 03/26 winansi: avoid buffer overrunJohannes Schindelin, Apr 26, 2017
  5. 04/26 add_commit_patch_id(): avoid allocating memory unnecessarilyJohannes Schindelin, Apr 26, 2017
  6. 06/26 get_mail_commit_oid(): avoid resource leakJohannes Schindelin, Apr 26, 2017
  7. Stefan BellerApr 26, 2017
  8. Junio C HamanoApr 27, 2017
  9. Johannes SchindelinApr 28, 2017
  10. Johannes SixtApr 27, 2017
  11. Johannes SchindelinApr 28, 2017
  12. 05/26 git_config_rename_section_in_file(): avoid resource leakJohannes Schindelin, Apr 26, 2017
  13. 08/26 difftool: close file descriptors after readingJohannes Schindelin, Apr 26, 2017
  14. Junio C HamanoApr 27, 2017
  15. Johannes SchindelinApr 28, 2017
  16. 07/26 http-backend: avoid memory leaksJohannes Schindelin, Apr 26, 2017
  17. Junio C HamanoApr 27, 2017
  18. Johannes SchindelinApr 28, 2017
  19. Junio C HamanoMay 1, 2017
  20. Johannes SchindelinMay 1, 2017
  21. 09/26 status: close file descriptor after reading git-rebase-todoJohannes Schindelin, Apr 26, 2017
  22. 10/26 Check for EOF while parsing mailsJohannes Schindelin, Apr 26, 2017
  23. Junio C HamanoApr 27, 2017
  24. Johannes SchindelinApr 28, 2017
  25. Johannes SixtApr 27, 2017
  26. Johannes SchindelinApr 28, 2017
  27. Jeff KingApr 28, 2017
  28. Johannes SchindelinApr 28, 2017
  29. Jeff KingApr 28, 2017
  30. Jeff KingApr 27, 2017
  31. Johannes SchindelinApr 28, 2017
  32. Jeff KingApr 28, 2017
  33. Johannes SchindelinApr 28, 2017
  34. 11/26 cat-file: fix memory leakJohannes Schindelin, Apr 26, 2017
  35. Junio C HamanoApr 27, 2017
  36. Johannes SchindelinApr 28, 2017
  37. 12/26 checkout: fix memory leakJohannes Schindelin, Apr 26, 2017
  38. Junio C HamanoApr 27, 2017
  39. Johannes SchindelinApr 28, 2017
  40. 13/26 split_commit_in_progress(): fix memory leakJohannes Schindelin, Apr 26, 2017
  41. 14/26 setup_bare_git_dir(): fix memory leakJohannes Schindelin, Apr 26, 2017
  42. Stefan BellerApr 26, 2017
  43. Johannes SchindelinApr 27, 2017
  44. Johannes SixtApr 27, 2017
  45. Johannes SchindelinApr 27, 2017
  46. 15/26 setup_discovered_git_dir(): fix memory leakJohannes Schindelin, Apr 26, 2017
  47. 16/26 pack-redundant: plug memory leakJohannes Schindelin, Apr 26, 2017
  48. 17/26 mktree: plug memory leaks reported by CoverityJohannes Schindelin, Apr 26, 2017
  49. 18/26 fast-export: avoid leaking memory in handle_tag()Johannes Schindelin, Apr 26, 2017
  50. Johannes SixtApr 27, 2017
  51. Johannes SchindelinApr 28, 2017
  52. 19/26 receive-pack: plug memory leak in update()Johannes Schindelin, Apr 26, 2017
  53. 20/26 line-log: avoid memory leakJohannes Schindelin, Apr 26, 2017
  54. Johannes SixtApr 27, 2017
  55. Johannes SchindelinApr 28, 2017
  56. 21/26 shallow: avoid memory leakJohannes Schindelin, Apr 26, 2017
  57. 22/26 add_reflog_for_walk: avoid memory leakJohannes Schindelin, Apr 26, 2017
  58. Johannes SixtApr 27, 2017
  59. Johannes SchindelinApr 28, 2017
  60. 23/26 remote: plug memory leak in match_explicit()Johannes Schindelin, Apr 26, 2017
  61. 26/26 submodule_uses_worktrees(): plug memory leakJohannes Schindelin, Apr 26, 2017
  62. 25/26 show_worktree(): plug memory leakJohannes Schindelin, Apr 26, 2017
  63. 24/26 name-rev: avoid leaking memory in the `deref` caseJohannes Schindelin, Apr 26, 2017
  64. Stefan BellerApr 26, 2017
  65. Johannes SchindelinApr 27, 2017
  66. Stefan BellerApr 28, 2017
  67. Automating Coverity, was Re: [PATCH 00/26] Address a couple of issues identified by CoverityJohannes Schindelin, Apr 28, 2017
  68. Lars SchneiderMay 1, 2017
  69. Johannes SchindelinMay 2, 2017
  70. Johannes SchindelinMay 5, 2017
  71. Johannes SchindelinMay 10, 2017
  72. Stefan BellerMay 10, 2017
  73. Johannes SchindelinMay 11, 2017
  74. Johannes SixtApr 27, 2017
  75. Johannes SchindelinApr 28, 2017
  76. 00/25 Address a couple of issues identified by CoverityJohannes Schindelin, Apr 28, 2017
  77. 01/25 mingw: avoid memory leak when splitting PATHJohannes Schindelin, Apr 28, 2017
  78. 02/25 winansi: avoid use of uninitialized valueJohannes Schindelin, Apr 28, 2017
  79. 03/25 winansi: avoid buffer overrunJohannes Schindelin, Apr 28, 2017
  80. 04/25 add_commit_patch_id(): avoid allocating memory unnecessarilyJohannes Schindelin, Apr 28, 2017
  81. 05/25 git_config_rename_section_in_file(): avoid resource leakJohannes Schindelin, Apr 28, 2017
  82. 07/25 difftool: address a couple of resource/memory leaksJohannes Schindelin, Apr 28, 2017
  83. 06/25 get_mail_commit_oid(): avoid resource leakJohannes Schindelin, Apr 28, 2017
  84. 08/25 status: close file descriptor after reading git-rebase-todoJohannes Schindelin, Apr 28, 2017
  85. 09/25 mailinfo & mailsplit: check for EOF while parsingJohannes Schindelin, Apr 28, 2017
  86. Junio C HamanoMay 2, 2017
  87. Johannes SchindelinMay 2, 2017
  88. 10/25 cat-file: fix memory leakJohannes Schindelin, Apr 28, 2017
  89. 11/25 checkout: fix memory leakJohannes Schindelin, Apr 28, 2017
  90. 12/25 split_commit_in_progress(): fix memory leakJohannes Schindelin, Apr 28, 2017
  91. 13/25 setup_bare_git_dir(): help static analysisJohannes Schindelin, Apr 28, 2017
  92. 14/25 setup_discovered_git_dir(): help static analysisJohannes Schindelin, Apr 28, 2017
  93. Junio C HamanoMay 2, 2017
  94. Johannes SchindelinMay 2, 2017
  95. 15/25 pack-redundant: plug memory leakJohannes Schindelin, Apr 28, 2017
  96. 16/25 mktree: plug memory leaks reported by CoverityJohannes Schindelin, Apr 28, 2017
  97. 17/25 fast-export: avoid leaking memory in handle_tag()Johannes Schindelin, Apr 28, 2017
  98. 18/25 receive-pack: plug memory leak in update()Johannes Schindelin, Apr 28, 2017
  99. 19/25 line-log: avoid memory leakJohannes Schindelin, Apr 28, 2017
  100. 20/25 shallow: avoid memory leakJohannes Schindelin, Apr 28, 2017
  101. 22/25 remote: plug memory leak in match_explicit()Johannes Schindelin, Apr 28, 2017
  102. 23/25 name-rev: avoid leaking memory in the `deref` caseJohannes Schindelin, Apr 28, 2017
  103. Junio C HamanoMay 2, 2017
  104. Junio C HamanoMay 2, 2017
  105. Johannes SchindelinMay 2, 2017
  106. Junio C HamanoMay 4, 2017
  107. 24/25 show_worktree(): plug memory leakJohannes Schindelin, Apr 28, 2017
  108. Junio C HamanoMay 2, 2017
  109. 25/25 submodule_uses_worktrees(): plug memory leakJohannes Schindelin, Apr 28, 2017
  110. Junio C HamanoMay 2, 2017
  111. 21/25 add_reflog_for_walk: avoid memory leakJohannes Schindelin, Apr 28, 2017
  112. 00/25 Address a couple of issues identified by CoverityJohannes Schindelin, May 2, 2017
  113. 01/25 mingw: avoid memory leak when splitting PATHJohannes Schindelin, May 2, 2017
  114. René ScharfeMay 3, 2017
  115. Johannes SchindelinMay 4, 2017
  116. 02/25 winansi: avoid use of uninitialized valueJohannes Schindelin, May 2, 2017
  117. René ScharfeMay 3, 2017
  118. Johannes SchindelinMay 4, 2017
  119. 03/25 winansi: avoid buffer overrunJohannes Schindelin, May 2, 2017
  120. 04/25 add_commit_patch_id(): avoid allocating memory unnecessarilyJohannes Schindelin, May 2, 2017
  121. 06/25 get_mail_commit_oid(): avoid resource leakJohannes Schindelin, May 2, 2017
  122. 07/25 difftool: address a couple of resource/memory leaksJohannes Schindelin, May 2, 2017
  123. 05/25 git_config_rename_section_in_file(): avoid resource leakJohannes Schindelin, May 2, 2017
  124. 08/25 status: close file descriptor after reading git-rebase-todoJohannes Schindelin, May 2, 2017
  125. 09/25 mailinfo & mailsplit: check for EOF while parsingJohannes Schindelin, May 2, 2017
  126. 10/25 cat-file: fix memory leakJohannes Schindelin, May 2, 2017
  127. 12/25 split_commit_in_progress(): fix memory leakJohannes Schindelin, May 2, 2017
  128. René ScharfeMay 3, 2017
  129. Johannes SchindelinMay 4, 2017
  130. René ScharfeMay 6, 2017
  131. Johannes SchindelinMay 9, 2017
  132. 11/25 checkout: fix memory leakJohannes Schindelin, May 2, 2017
  133. 16/25 mktree: plug memory leaks reported by CoverityJohannes Schindelin, May 2, 2017
  134. 13/25 setup_bare_git_dir(): help static analysisJohannes Schindelin, May 2, 2017
  135. 15/25 pack-redundant: plug memory leakJohannes Schindelin, May 2, 2017
  136. 17/25 fast-export: avoid leaking memory in handle_tag()Johannes Schindelin, May 2, 2017
  137. 14/25 setup_discovered_git_dir(): plug memory leakJohannes Schindelin, May 2, 2017
  138. Stefan BellerMay 2, 2017
  139. Jeff KingMay 2, 2017
  140. Johannes SchindelinMay 3, 2017
  141. 18/25 receive-pack: plug memory leak in update()Johannes Schindelin, May 2, 2017
  142. 21/25 add_reflog_for_walk: avoid memory leakJohannes Schindelin, May 2, 2017
  143. 22/25 remote: plug memory leak in match_explicit()Johannes Schindelin, May 2, 2017
  144. 20/25 shallow: avoid memory leakJohannes Schindelin, May 2, 2017
  145. 19/25 line-log: avoid memory leakJohannes Schindelin, May 2, 2017
  146. 24/25 show_worktree(): plug memory leakJohannes Schindelin, May 2, 2017
  147. 25/25 submodule_uses_worktrees(): plug memory leakJohannes Schindelin, May 2, 2017
  148. 23/25 name-rev: avoid leaking memory in the `deref` caseJohannes Schindelin, May 2, 2017
  149. 00/25 Address a couple of issues identified by CoverityJohannes Schindelin, May 4, 2017
  150. 04/25 add_commit_patch_id(): avoid allocating memory unnecessarilyJohannes Schindelin, May 4, 2017
  151. 07/25 difftool: address a couple of resource/memory leaksJohannes Schindelin, May 4, 2017
  152. 06/25 get_mail_commit_oid(): avoid resource leakJohannes Schindelin, May 4, 2017
  153. 05/25 git_config_rename_section_in_file(): avoid resource leakJohannes Schindelin, May 4, 2017
  154. 09/25 mailinfo & mailsplit: check for EOF while parsingJohannes Schindelin, May 4, 2017
  155. 08/25 status: close file descriptor after reading git-rebase-todoJohannes Schindelin, May 4, 2017
  156. 02/25 winansi: avoid use of uninitialized valueJohannes Schindelin, May 4, 2017
  157. 01/25 mingw: avoid memory leak when splitting PATHJohannes Schindelin, May 4, 2017
  158. 03/25 winansi: avoid buffer overrunJohannes Schindelin, May 4, 2017
  159. 10/25 cat-file: fix memory leakJohannes Schindelin, May 4, 2017
  160. 11/25 checkout: fix memory leakJohannes Schindelin, May 4, 2017
  161. René ScharfeMay 6, 2017
  162. Junio C HamanoMay 8, 2017
  163. Johannes SchindelinMay 9, 2017
  164. Junio C HamanoMay 9, 2017
  165. 18/25 receive-pack: plug memory leak in update()Johannes Schindelin, May 4, 2017
  166. 19/25 line-log: avoid memory leakJohannes Schindelin, May 4, 2017
  167. 20/25 shallow: avoid memory leakJohannes Schindelin, May 4, 2017
  168. 12/25 split_commit_in_progress(): simplify & fix memory leakJohannes Schindelin, May 4, 2017
  169. 14/25 setup_discovered_git_dir(): plug memory leakJohannes Schindelin, May 4, 2017
  170. 17/25 fast-export: avoid leaking memory in handle_tag()Johannes Schindelin, May 4, 2017
  171. 16/25 mktree: plug memory leaks reported by CoverityJohannes Schindelin, May 4, 2017
  172. 13/25 setup_bare_git_dir(): help static analysisJohannes Schindelin, May 4, 2017
  173. 21/25 add_reflog_for_walk: avoid memory leakJohannes Schindelin, May 4, 2017
  174. 22/25 remote: plug memory leak in match_explicit()Johannes Schindelin, May 4, 2017
  175. 24/25 show_worktree(): plug memory leakJohannes Schindelin, May 4, 2017
  176. 23/25 name-rev: avoid leaking memory in the `deref` caseJohannes Schindelin, May 4, 2017
  177. 25/25 submodule_uses_worktrees(): plug memory leakJohannes Schindelin, May 4, 2017
  178. 15/25 pack-redundant: plug memory leakJohannes Schindelin, May 4, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.