Pull request from mkuoppal: avoid integer overflow when user types digits and they're combined into a number by successively multiplying intermediate value by 10 and adding new digit. Needed to avoid triggering undefined behavior if the value overflows the largest signed integer (actually long int). This is a much more general fix than the code in the pull request, which imposed an arbitrary limit for one aspect of tty input. I'm not convinced that integer.h was the right place to add the new AppendLongDigit() macro. I may not have caught all the places where it is needed. files.c accumulates a value from digits but uses unsigned int, so overflow won't trigger undefined behavior (although it presumably ends up with a different value than what was intended). options.c and coloratt.c accumulate smaller integers and have a limit on the number of digits they'll use, so can't overflow. Fixes #1254
3.8 KiB
3.8 KiB