diff options
author | Sverker Eriksson <sverker@erlang.org> | 2020-05-26 17:03:27 +0200 |
---|---|---|
committer | Sverker Eriksson <sverker@erlang.org> | 2020-05-26 17:03:27 +0200 |
commit | 0f7b1d45d75050a3b8b165f0b8229d33191d0e8f (patch) | |
tree | dcdb4e2deb21f6a415760e88a98c5460995043d2 | |
parent | 187a47930b2c6c19dc23e9d0322c3135200f4ee3 (diff) | |
parent | 3a0857030005631c0577973f9118abeea63cede8 (diff) | |
download | erlang-0f7b1d45d75050a3b8b165f0b8229d33191d0e8f.tar.gz |
Merge branch 'maint'
-rw-r--r-- | lib/public_key/doc/src/public_key.xml | 4 | ||||
-rw-r--r-- | lib/public_key/src/public_key.erl | 4 | ||||
-rw-r--r-- | lib/public_key/test/public_key_SUITE.erl | 13 | ||||
-rw-r--r-- | lib/stdlib/test/ets_SUITE.erl | 116 |
4 files changed, 78 insertions, 59 deletions
diff --git a/lib/public_key/doc/src/public_key.xml b/lib/public_key/doc/src/public_key.xml index 8a6d0e84ca..3e72f88894 100644 --- a/lib/public_key/doc/src/public_key.xml +++ b/lib/public_key/doc/src/public_key.xml @@ -450,6 +450,10 @@ fun(OtpCert :: #'OTPCertificate'{}, verifying application-specific extensions. If called with an extension unknown to the user application, the return value <c>{unknown, UserState}</c> is to be used.</p> + <warning><p> + Note that user defined custom <c>verify_fun</c> may alter original + path validation error (e.g <c>selfsigned_peer</c>). Use with caution. + </p></warning> </item> <tag>{max_path_length, integer()}</tag> diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl index 117ae613cc..e1f5f7576e 100644 --- a/lib/public_key/src/public_key.erl +++ b/lib/public_key/src/public_key.erl @@ -962,8 +962,8 @@ pkix_path_validation(PathErr, [Cert | Chain], Options0) when is_atom(PathErr)-> Options = proplists:delete(verify_fun, Options0), pkix_path_validation(Otpcert, Chain, [{verify_fun, {VerifyFun, Userstate}}| Options]); - {fail, _} -> - {error, Reason} + {fail, UserReason} -> + {error, UserReason} catch _:_ -> {error, Reason} diff --git a/lib/public_key/test/public_key_SUITE.erl b/lib/public_key/test/public_key_SUITE.erl index f183e92eaf..3b2f1b7184 100644 --- a/lib/public_key/test/public_key_SUITE.erl +++ b/lib/public_key/test/public_key_SUITE.erl @@ -631,6 +631,19 @@ pkix_path_validation(Config) when is_list(Config) -> {ok, _} = public_key:pkix_path_validation(unknown_ca, [Cert1], [{verify_fun, VerifyFunAndState1}]), + + VerifyFunAndState2 = + {fun(_, {bad_cert, selfsigned_peer}, _UserState) -> + {fail, custom_reason}; + (_,{extension, _}, UserState) -> + {unknown, UserState}; + (_, valid, UserState) -> + {valid, UserState} + end, []}, + + {error, custom_reason} = + public_key:pkix_path_validation(selfsigned_peer, [Trusted], [{verify_fun, + VerifyFunAndState2}]), ok. %%-------------------------------------------------------------------- diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl index 3b2dde6b9b..9e5410c10f 100644 --- a/lib/stdlib/test/ets_SUITE.erl +++ b/lib/stdlib/test/ets_SUITE.erl @@ -1278,9 +1278,9 @@ ets_insert_new_with_check(Table, ToInsert) -> t_insert_list_parallel_do(Opts) -> [(fun(I) -> - t_insert_list_parallel_do(Opts, I, 2, 100, 5000), - t_insert_list_parallel_do(Opts, I, 10, 100, 500), - t_insert_list_parallel_do(Opts, I, 1000, 100, 50), + t_insert_list_parallel_do(Opts, I, 2, 100, 500), + t_insert_list_parallel_do(Opts, I, 10, 100, 100), + t_insert_list_parallel_do(Opts, I, 1000, 100, 10), t_insert_list_parallel_do(Opts, I, 50000, 3, 1) end)(InsertFun) || InsertFun <- [fun ets_insert_with_check/2, fun ets_insert_new_with_check/2]]. @@ -5118,7 +5118,7 @@ test_delete_table_while_size_snapshot_helper(TableType) -> Problem -> TopParent ! Problem end || _ <- Pids] end, - 15000), + 100*erlang:system_info(schedulers_online)), receive Problem -> throw(Problem) after 0 -> ok @@ -6853,7 +6853,7 @@ verify_table_load(T) -> false; true -> - io:format("Stats = ~p\n",[Stats]), + io:format("Stats = ~p\n~p\n",[Stats, ets:info(T)]), ok end end. @@ -8134,58 +8134,60 @@ wait_for_memory_deallocations() -> end. etsmem() -> - % The following is done twice to avoid an inconsistent memory - % "snapshot" (see verify_etsmem/2). - lists:foldl( - fun(AttemptNr, PrevEtsMem) -> - AllTabsExceptions = [logger, code], - %% The logger table is excluded from the AllTabs list - %% below because it uses decentralized counters to keep - %% track of the size and the memory counters. This cause - %% ets:info(T,size) and ets:info(T,memory) to trigger - %% allocations and frees that may change the amount of - %% memory that is allocated for ETS. - %% - %% The code table is excluded from the list below - %% because the amount of memory allocated for it may - %% change if the tested code loads a new module. - AllTabs = - lists:sort( - [begin - try ets:info(T, decentralized_counters) of - true -> - ct:fail("Background ETS table (~p) that " - "uses decentralized counters (Add exception?)", - [ets:info(T,name)]); - _ -> ok - catch _:_ -> - ok - end, - {T, - ets:info(T,name), - ets:info(T,size), - ets:info(T,memory), - ets:info(T,type)} - end - || T <- ets:all(), - not lists:member(ets:info(T, name), AllTabsExceptions)]), - wait_for_memory_deallocations(), - EtsAllocSize = erts_debug:alloc_blocks_size(ets_alloc), - ErlangMemoryEts = try erlang:memory(ets) catch error:notsup -> notsup end, - FlxCtrMemUsage = try erts_debug:get_internal_state(flxctr_memory_usage) catch error:badarg -> notsup end, - Mem = {ErlangMemoryEts, EtsAllocSize, FlxCtrMemUsage}, - EtsMem = {Mem, AllTabs}, - case PrevEtsMem of - first -> ok; - _ when PrevEtsMem =:= EtsMem -> ok; - _ -> - io:format("etsmem(): Change in attempt ~p~n~nbefore:~n~p~n~nafter:~n~p~n~n", - [AttemptNr, PrevEtsMem, EtsMem]) - end, - EtsMem - end, - first, - lists:seq(1,2)). + etsmem(get_etsmem(), 1). + +etsmem(PrevEtsMem, Try) when Try < 10 -> + case get_etsmem() of + PrevEtsMem -> + PrevEtsMem; + EtsMem -> + io:format("etsmem(): Change in attempt ~p~n~nbefore:~n~p~n~nafter:~n~p~n~n", + [Try, PrevEtsMem, EtsMem]), + etsmem(EtsMem, Try+1) + end; +etsmem(_, _) -> + ct:fail("Failed to get a stable/consistent memory snapshot"). + +get_etsmem() -> + AllTabsExceptions = [logger, code], + %% The logger table is excluded from the AllTabs list + %% below because it uses decentralized counters to keep + %% track of the size and the memory counters. This cause + %% ets:info(T,size) and ets:info(T,memory) to trigger + %% allocations and frees that may change the amount of + %% memory that is allocated for ETS. + %% + %% The code table is excluded from the list below + %% because the amount of memory allocated for it may + %% change if the tested code loads a new module. + AllTabs = + lists:sort( + [begin + try ets:info(T, decentralized_counters) of + true -> + ct:fail("Background ETS table (~p) that " + "uses decentralized counters (Add exception?)", + [ets:info(T,name)]); + _ -> ok + catch _:_ -> + ok + end, + {T, + ets:info(T,name), + ets:info(T,size), + ets:info(T,memory), + ets:info(T,type)} + end + || T <- ets:all(), + not lists:member(ets:info(T, name), AllTabsExceptions)]), + wait_for_memory_deallocations(), + EtsAllocSize = erts_debug:alloc_blocks_size(ets_alloc), + ErlangMemoryEts = try erlang:memory(ets) + catch error:notsup -> notsup end, + FlxCtrMemUsage = try erts_debug:get_internal_state(flxctr_memory_usage) + catch error:badarg -> notsup end, + Mem = {ErlangMemoryEts, EtsAllocSize, FlxCtrMemUsage}, + {Mem, AllTabs}. verify_etsmem(MI) -> wait_for_test_procs(), |