wolfssl
wolfssl copied to clipboard
Use signed variable for length calculation in SendTls13Certificate
Description
Use signed variable for length calculation in SendTls13Certificate. Current code uses unsigned len which only works when decremented exactly to zero. Any mistakes in the length handling will underflow and keep looping, allocating memory until the system runs out.
Additional fix brought up by ZD 18267
Prefer to keep length as unsigned if possible as all assignments I've seen are calculated with unsigned. Windows is complaining about signed/unsigned mismatch and needs to be fixed.
So I mean we can keep it unsigned but I feel it is still far riskier. The hang two customers saw would have been prevented with this change, and in general any mistakes in length handling will result in a hang. Any mistakes in further modifications of that code could also result in a hang. Would strongly prefer we not do unsigned len > 0 loop, especially when allocating inside that loop.
Retest this please.