|
22 | 22 | test_type_conversions/1, |
23 | 23 | test_nested_types/1, |
24 | 24 | test_conversion_depth_guard/1, |
| 25 | + test_embedded_nul_name_rejected/1, |
25 | 26 | test_timeout/1, |
26 | 27 | test_special_floats/1, |
27 | 28 | test_streaming/1, |
@@ -84,6 +85,7 @@ all() -> |
84 | 85 | test_type_conversions, |
85 | 86 | test_nested_types, |
86 | 87 | test_conversion_depth_guard, |
| 88 | + test_embedded_nul_name_rejected, |
87 | 89 | test_timeout, |
88 | 90 | test_special_floats, |
89 | 91 | test_streaming, |
@@ -326,6 +328,16 @@ test_conversion_depth_guard(_Config) -> |
326 | 328 | {ok, 4.0} = py:call(math, sqrt, [16]), |
327 | 329 | ok. |
328 | 330 |
|
| 331 | +%% @doc A code string with an embedded NUL must be rejected, not silently |
| 332 | +%% truncated at the NUL (which would run something other than intended). Exercises |
| 333 | +%% the binary_to_string NUL guard shared by all name/code decoding. |
| 334 | +test_embedded_nul_name_rejected(_Config) -> |
| 335 | + {error, _} = py:eval(<<"1", 0, "+1">>), |
| 336 | + {error, _} = py:exec(<<"x = 1", 0, "; y = 2">>), |
| 337 | + %% Node still alive and clean code still works. |
| 338 | + {ok, 2} = py:eval(<<"1+1">>), |
| 339 | + ok. |
| 340 | + |
329 | 341 | test_timeout(_Config) -> |
330 | 342 | %% Test that timeout works - use time.sleep which guarantees delay |
331 | 343 | %% time.sleep(1) will definitely exceed 100ms timeout |
|
0 commit comments