kokke/tiny-bignum-c

bignum_pow modifies the value of the "b" argument

jgancedo opened this issue · 1 comments

I was running a program in which I observed that the argument b in
void bignum_pow(struct bn* a, struct bn* b, struct bn* c);

had its original value changed to zero after executing this function. Looking at the function code, it seems that the b pointer is directly being decremented within (see lines 524, 533 in bn.c). I guess this is not expected behavior, as b is an input argument.

kokke commented

Hi @jgancedo and thanks for pointing out this flaw.

I have fixed the problem by adding another temporary variable, taking up yet more precious precious stack space ;)

Once again, thank you for pointing it out.