{"thread":{"id":"48692","subject":"[PATCH] list-objects: check if filter is NULL before using","startedAt":"2018-06-11T21:51:36Z","lastAt":"2018-06-12T17:47:11Z","messageCount":2,"participants":["Jonathan Tan","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"349948","messageId":"20180611215126.205944-1-jonathantanmy@google.com","threadId":"48692","inReplyTo":null,"subject":"[PATCH] list-objects: check if filter is NULL before using","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-06-11T21:51:26Z","receivedAt":"2018-06-11T21:51:36Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"In partial_clone_get_default_filter_spec(), the\ncore_partial_clone_filter_default variable may be NULL; ensure that it\nis not NULL before using it.\n\nSigned-off-by: Jonathan Tan <jonathantanmy@google.com>\n---\nThis was noticed by someone else at $DAY_JOB when trying to use a\npartial clone with no core.partialclonefilter set.\n---\n list-objects-filter-options.c | 2 ++\n t/t0410-partial-clone.sh      | 8 ++++++++\n 2 files changed, 10 insertions(+)\n\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex 6a3cc985c4..c0e2bd6a06 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -146,6 +146,8 @@ void partial_clone_get_default_filter_spec(\n \t/*\n \t * Parse default value, but silently ignore it if it is invalid.\n \t */\n+\tif (!core_partial_clone_filter_default)\n+\t\treturn;\n \tgently_parse_list_objects_filter(filter_options,\n \t\t\t\t\t core_partial_clone_filter_default,\n \t\t\t\t\t NULL);\ndiff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh\nindex cc18b75c03..4984ca583d 100755\n--- a/t/t0410-partial-clone.sh\n+++ b/t/t0410-partial-clone.sh\n@@ -23,7 +23,15 @@ promise_and_delete () {\n \tdelete_object repo \"$HASH\"\n }\n \n+test_expect_success 'extensions.partialclone without filter' '\n+\ttest_create_repo server &&\n+\tgit clone --filter=\"blob:none\" \"file://$(pwd)/server\" client &&\n+\tgit -C client config --unset core.partialclonefilter &&\n+\tgit -C client fetch origin\n+'\n+\n test_expect_success 'missing reflog object, but promised by a commit, passes fsck' '\n+\trm -rf repo &&\n \ttest_create_repo repo &&\n \ttest_commit -C repo my_commit &&\n \n-- \n2.17.0.582.gccdcbd54c4\n\n"},{"id":"349995","messageId":"xmqqfu1raodi.fsf@gitster-ct.c.googlers.com","threadId":"48692","inReplyTo":"20180611215126.205944-1-jonathantanmy@google.com","subject":"Re: [PATCH] list-objects: check if filter is NULL before using","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-06-12T17:47:05Z","receivedAt":"2018-06-12T17:47:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Tan <jonathantanmy@google.com> writes:\n\n> In partial_clone_get_default_filter_spec(), the\n> core_partial_clone_filter_default variable may be NULL; ensure that it\n> is not NULL before using it.\n>\n> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>\n> ---\n> This was noticed by someone else at $DAY_JOB when trying to use a\n> partial clone with no core.partialclonefilter set.\n\nThanks, will queue.\n\n> ---\n>  list-objects-filter-options.c | 2 ++\n>  t/t0410-partial-clone.sh      | 8 ++++++++\n>  2 files changed, 10 insertions(+)\n>\n> diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\n> index 6a3cc985c4..c0e2bd6a06 100644\n> --- a/list-objects-filter-options.c\n> +++ b/list-objects-filter-options.c\n> @@ -146,6 +146,8 @@ void partial_clone_get_default_filter_spec(\n>  \t/*\n>  \t * Parse default value, but silently ignore it if it is invalid.\n>  \t */\n> +\tif (!core_partial_clone_filter_default)\n> +\t\treturn;\n>  \tgently_parse_list_objects_filter(filter_options,\n>  \t\t\t\t\t core_partial_clone_filter_default,\n>  \t\t\t\t\t NULL);\n> diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh\n> index cc18b75c03..4984ca583d 100755\n> --- a/t/t0410-partial-clone.sh\n> +++ b/t/t0410-partial-clone.sh\n> @@ -23,7 +23,15 @@ promise_and_delete () {\n>  \tdelete_object repo \"$HASH\"\n>  }\n>  \n> +test_expect_success 'extensions.partialclone without filter' '\n> +\ttest_create_repo server &&\n> +\tgit clone --filter=\"blob:none\" \"file://$(pwd)/server\" client &&\n> +\tgit -C client config --unset core.partialclonefilter &&\n> +\tgit -C client fetch origin\n> +'\n> +\n>  test_expect_success 'missing reflog object, but promised by a commit, passes fsck' '\n> +\trm -rf repo &&\n>  \ttest_create_repo repo &&\n>  \ttest_commit -C repo my_commit &&\n"}]}