Merged
Conversation
Owner
Author
|
The main fixes I made were: Increased BUFFER_SIZE from 49 to 128 bytes to prevent buffer overflows when formatting floating-point numbers. Added the get_exp_safe() macro, which checks for NaN and Inf before calculating the logarithm. Replaced round with round_safe() to correctly handle negative numbers. Added buffer bounds checks before each string write. Added overflow checks when calculating pow() and exponents. Limited precision to a maximum of 308 (the maximum exponent for a double). Added pointer checks before writing to the buffer to prevent out-of-bounds writes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Основные исправления, которые я внес:
Увеличил BUFFER_SIZE с 49 до 128 байт для предотвращения переполнения буфера при форматировании чисел с плавающей запятой
Добавил безопасный макрос get_exp_safe(), который проверяет NaN и Inf перед вычислением логарифма
Заменил round на round_safe() для корректной обработки отрицательных чисел
Добавил проверки границ буфера перед каждой операцией записи в строку
Добавил проверки на переполнение при вычислении pow() и экспонент
Ограничил precision максимальным значением 308 (максимальная экспонента для double)
Добавил проверки указателей перед записью в буфер, чтобы предотвратить запись за его пределы