
Do you want to run this Docker container locally?
docker run -d --name numberizer --restart unless-stopped -p 9007:80 joshbeck2024/numberizer:latest
Short Summary
Key idea (short version)
1e99 becomes infinity (INF) in PHP.
When INF is converted to an integer, PHP turns it into 0.
- The code detects this mismatch and deliberately sets
$sum = -1.
What’s happening:
- Scientific notation → float
- Float overflow →
INF
INF → intval() → 0
- Logic interprets this as an error → sets
-1
Solution:
curl -X POST '<http://sem2ctf.icsi.cyber:9007/>' -d 'numbers[]=1e99&numbers[]=1e99&numbers[]=1e99&numbers[]=1e99&numbers[]=1e99'
Supplying an extremely large number will cause an integer overflow, resulting in a negative value.
- A workaround was to use scientific notation, such as
1e99, which represents 10^99.
- This notation is valid under the length constraint but still evaluates to a very large number, causing an overflow when summed.
Here is the application code with concise comments: