Skip to content

Commit 044a0ac

Browse files
committed
fix atom exhaustion quiz
Signed-off-by: Cocoa <[email protected]>
1 parent 6cd34cb commit 044a0ac

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

modules/5-elixir.livemd

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Mix.install([
77
{:grading_client, path: "#{__DIR__}/grading_client"},
88
:benchwarmer,
9+
:uuid,
910
:kino,
1011
:plug
1112
])
@@ -53,20 +54,18 @@ Beware of functions in applications/libraries that create atoms from input value
5354
_You should get a `true` result when you successfully fix the function._
5455

5556
```elixir
56-
random_number = :rand.uniform(10000)
57-
malicious_user_input = Integer.to_string(random_number)
58-
prev_count = :erlang.system_info(:atom_count)
57+
malicious_user_input = UUID.uuid4()
5958

6059
try do
6160
malicious_user_input
6261
# ONLY CHANGE LINE 8
6362
|> String.to_atom()
6463
rescue
65-
e -> {ArgumentError, e}
64+
_ ->
65+
IO.puts("Are you protected against Atom Exhaustion?")
66+
IO.puts("true")
67+
nil
6668
end
67-
68-
IO.puts("Are you protected against Atom Exhaustion?")
69-
IO.puts(:erlang.system_info(:atom_count) == prev_count)
7069
```
7170

7271
## Serialization and Deserialization

0 commit comments

Comments
 (0)