resultbytelen cannot be 0 when resultbitlen != 0 and as such,
result[resultbytelen - 1] here cannot point to invalid index. However,
this is apparently too complex for static analyzers, so make this more
obvious to avoid false positives.
Signed-off-by: Jouni Malinen <j@w1.fi>
}
/* since we're expanding to a bit length, mask off the excess */
- if (resultbitlen % 8) {
+ if (resultbytelen > 0 && (resultbitlen % 8)) {
u8 mask = 0xff;
mask <<= (8 - (resultbitlen % 8));
result[resultbytelen - 1] &= mask;