Samuel-Tyler / fast_ber

A C++11 ASN.1 BER Encoding and Decoding Library
Boost Software License 1.0
84 stars 11 forks source link

Potential infinite loop in Real.hpp #39

Open Thiesius opened 2 years ago

Thiesius commented 2 years ago

There is a possibility of infinite loop in Real.hpp. if the first part of the condition (first_byte & 0xF0) == 0 evaluates as true and exponent is bigger than 0, then for obvious reasons (exponent -= 0) loop never ends.

   /* Mantissa is too small - shift left up to 4 bits */
    int          shift      = 8;
    unsigned int first_byte = double_bytes[1];

    /* Adapt exponent */
    while ((first_byte & 0xF0) == 0 && exponent > (8 - shift))
    {
        exponent -= 8 - shift;
    }