{"thread":{"id":"51143","subject":"[PATCH 0/2] Fix two issues pointed out by Coverity","startedAt":"2019-05-21T17:50:23Z","lastAt":"2019-05-28T18:25:27Z","messageCount":4,"participants":["Johannes Schindelin via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"376004","messageId":"pull.221.git.gitgitgadget@gmail.com","threadId":"51143","inReplyTo":null,"subject":"[PATCH 0/2] Fix two issues pointed out by Coverity","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-05-21T17:50:19Z","receivedAt":"2019-05-21T17:50:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"I looked very briefly over the issues pointed out by Coverity, and decided\nto pluck these two low-hanging pieces of fruit.\n\nJohannes Schindelin (2):\n  rebase: replace incorrect logical negation by correct bitwise one\n  bisect--helper: verify HEAD could be parsed before continuing\n\n builtin/bisect--helper.c | 5 ++++-\n builtin/rebase.c         | 2 +-\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\n\nbase-commit: aa25c82427ae70aebf3b8f970f2afd54e9a2a8c6\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-221%2Fdscho%2Faddress-coverity-reports-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-221/dscho/address-coverity-reports-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/221\n-- \ngitgitgadget\n"},{"id":"376005","messageId":"aa0acf4c5ff843a480afdb5715fa03186d82a6d1.1558461018.git.gitgitgadget@gmail.com","threadId":"51143","inReplyTo":"pull.221.git.gitgitgadget@gmail.com","subject":"[PATCH 1/2] rebase: replace incorrect logical negation by correct bitwise one","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-05-21T17:50:20Z","receivedAt":"2019-05-21T17:50:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nIn bff014dac7d9 (builtin rebase: support the `verbose` and `diffstat`\noptions, 2018-09-04), we added a line that wanted to remove the\n`REBASE_DIFFSTAT` bit from the flags, but it used an incorrect negation.\n\nFound by Coverity.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/rebase.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex ba3a574e40..db6ca9bd7d 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -1203,7 +1203,7 @@ static int rebase_config(const char *var, const char *value, void *data)\n \t\tif (git_config_bool(var, value))\n \t\t\topts->flags |= REBASE_DIFFSTAT;\n \t\telse\n-\t\t\topts->flags &= !REBASE_DIFFSTAT;\n+\t\t\topts->flags &= ~REBASE_DIFFSTAT;\n \t\treturn 0;\n \t}\n \n-- \ngitgitgadget\n\n"},{"id":"376006","messageId":"f5fa20d2a33e0cacc649c86b540d7d8eeff30a45.1558461018.git.gitgitgadget@gmail.com","threadId":"51143","inReplyTo":"pull.221.git.gitgitgadget@gmail.com","subject":"[PATCH 2/2] bisect--helper: verify HEAD could be parsed before continuing","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-05-21T17:50:21Z","receivedAt":"2019-05-21T17:50:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nIn 06f5608c14e6 (bisect--helper: `bisect_start` shell function partially\nin C, 2019-01-02), we introduced a call to `get_oid()` and did not check\nwhether it succeeded before using its output.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/bisect--helper.c | 5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex e7325fe37f..1fbe156e67 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -570,7 +570,10 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,\n \twrite_file(git_path_bisect_start(), \"%s\\n\", start_head.buf);\n \n \tif (no_checkout) {\n-\t\tget_oid(start_head.buf, &oid);\n+\t\tif (get_oid(start_head.buf, &oid) < 0) {\n+\t\t\tretval = error(_(\"invalid ref: '%s'\"), start_head.buf);\n+\t\t\tgoto finish;\n+\t\t}\n \t\tif (update_ref(NULL, \"BISECT_HEAD\", &oid, NULL, 0,\n \t\t\t       UPDATE_REFS_MSG_ON_ERR)) {\n \t\t\tretval = -1;\n-- \ngitgitgadget\n"},{"id":"376335","messageId":"xmqq5zpu308g.fsf@gitster-ct.c.googlers.com","threadId":"51143","inReplyTo":"aa0acf4c5ff843a480afdb5715fa03186d82a6d1.1558461018.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/2] rebase: replace incorrect logical negation by correct bitwise one","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-05-28T18:25:19Z","receivedAt":"2019-05-28T18:25:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> In bff014dac7d9 (builtin rebase: support the `verbose` and `diffstat`\n> options, 2018-09-04), we added a line that wanted to remove the\n> `REBASE_DIFFSTAT` bit from the flags, but it used an incorrect negation.\n>\n> Found by Coverity.\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>  builtin/rebase.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/builtin/rebase.c b/builtin/rebase.c\n> index ba3a574e40..db6ca9bd7d 100644\n> --- a/builtin/rebase.c\n> +++ b/builtin/rebase.c\n> @@ -1203,7 +1203,7 @@ static int rebase_config(const char *var, const char *value, void *data)\n>  \t\tif (git_config_bool(var, value))\n>  \t\t\topts->flags |= REBASE_DIFFSTAT;\n>  \t\telse\n> -\t\t\topts->flags &= !REBASE_DIFFSTAT;\n> +\t\t\topts->flags &= ~REBASE_DIFFSTAT;\n>  \t\treturn 0;\n>  \t}\n\nObviously correct.  Thanks.\n\nAt this point in the codeflow, the .flags field is not touched by\nparse_options() yet, the configuration codepath only touches that\nfield for REBASE_DIFFSTAT, and because REBASE_DIFFSTAT is not 0,\n\"[rebase] stat = no\", which would want only the REBASE_DIFFSTAT bit\ncleared in the word, can afford to instead assign 0 to the whole\nword without causing any damage, which is funny way for this bug to\nbe hidden for a long time...\n\n\n"}]}