zserge / partcl

ParTcl - a micro Tcl implementation

Home Page:https://zserge.com/posts/tcl-interpreter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Division by Zero

shrezaei opened this issue · comments

After second round of fuzzing, I realized that you do not check division by zero. It is in tcl_cmd_math() function. You can simply add an if statement and solve the problem.
Additionally, I suggest that you check arguments of math operation before passing it to tcl_int().
Because you used atoi() function in tcl_int() and it basically convert the digits from the beginning of the string until it reaches any non-digit character. That means, you can pass "22sdfe" (which gives 22) or even "sdfdsf" (which gives 0) and it will work. But, it is better to show an error ("?!" string in your app) to let the user know that.?!