|
68 | 68 | unsorted_map_in_map/1, |
69 | 69 | bad_term_to_binary/1, |
70 | 70 | bad_binary_to_term_2/1,safe_binary_to_term2/1, |
| 71 | + non_executable_binary_to_term2/1, |
71 | 72 | bad_binary_to_term/1, bad_terms/1, more_bad_terms/1, |
72 | 73 | big_binary_to_term/1, |
73 | 74 | otp_5484/1,otp_5933/1, |
@@ -99,6 +100,7 @@ all() -> |
99 | 100 | b2t_used_big, t2b_deterministic, |
100 | 101 | t2b_minor_version, |
101 | 102 | bad_binary_to_term_2, safe_binary_to_term2, |
| 103 | + non_executable_binary_to_term2, |
102 | 104 | bad_binary_to_term, bad_terms, t_hash, bad_size, |
103 | 105 | big_binary_to_term, |
104 | 106 | sub_bin_copy, bad_term_to_binary, t2b_system_limit, |
@@ -1210,6 +1212,30 @@ safe_binary_to_term2(Config) when is_list(Config) -> |
1210 | 1212 | bad_bin_to_term(BadExtFun, [safe]), |
1211 | 1213 | ok. |
1212 | 1214 |
|
| 1215 | +%% Test the non_executable option for binary_to_term/2 |
| 1216 | +non_executable_binary_to_term2(Config) when is_list(Config) -> |
| 1217 | + hello = binary_to_term_stress(term_to_binary(hello), [non_executable]), |
| 1218 | + {1,[2,3]} = binary_to_term_stress(term_to_binary({1,[2,3]}), [non_executable]), |
| 1219 | + |
| 1220 | + %% External fun references |
| 1221 | + ExtFun = term_to_binary(fun erlang:length/1), |
| 1222 | + bad_bin_to_term(ExtFun, [non_executable]), |
| 1223 | + |
| 1224 | + %% Anonymous funs |
| 1225 | + Fun0 = term_to_binary(fun() -> ok end), |
| 1226 | + bad_bin_to_term(Fun0, [non_executable]), |
| 1227 | + Fun1 = term_to_binary(fun(X) -> X end), |
| 1228 | + bad_bin_to_term(Fun1, [non_executable]), |
| 1229 | + |
| 1230 | + %% A fun nested inside another term |
| 1231 | + Nested = term_to_binary({wrapper, [fun() -> ok end]}), |
| 1232 | + bad_bin_to_term(Nested, [non_executable]), |
| 1233 | + |
| 1234 | + %% Composing with safe |
| 1235 | + bad_bin_to_term(ExtFun, [safe, non_executable]), |
| 1236 | + hello = binary_to_term_stress(term_to_binary(hello), [safe, non_executable]), |
| 1237 | + ok. |
| 1238 | + |
1213 | 1239 | %% OTP-18306 Decode binary/bitstring with size >= 2Gbyte |
1214 | 1240 | big_binary_to_term(Config) -> |
1215 | 1241 | run_when_enough_resources( |
|
0 commit comments