You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Though one doesn't normally enter huge numbers, the result can be surprising.
Since the value (as stored in the variable number) is generally cast to int in command.c (which also makes the tests number > 0 before the cast incorrect, in particular), an immediate solution can be to saturate to INT_MAX by replacing the second line by
Note that the consequence is that the values will be limited to INT_MAX for command P ("Go to the line containing byte offset N in the file."). However, this could affect only the viewing of files larger than 2 GB. Ideally, the types in the code should be cleaned up.
The text was updated successfully, but these errors were encountered:
The
cmd_int
function incmdbuf.c
does not check integer overflows:Though one doesn't normally enter huge numbers, the result can be surprising.
Since the value (as stored in the variable
number
) is generally cast toint
incommand.c
(which also makes the testsnumber > 0
before the cast incorrect, in particular), an immediate solution can be to saturate toINT_MAX
by replacing the second line byThis should avoid integer overflows completely.
Note that the consequence is that the values will be limited to
INT_MAX
for commandP
("Go to the line containing byte offset N in the file."). However, this could affect only the viewing of files larger than 2 GB. Ideally, the types in the code should be cleaned up.The text was updated successfully, but these errors were encountered: