fix possible overrun
authorRudolf Polzer <divverent@xonotic.org>
Fri, 29 Apr 2011 11:59:28 +0000 (13:59 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 29 Apr 2011 11:59:28 +0000 (13:59 +0200)
d0_bignum-tommath.c

index 966bd05..414d5af 100644 (file)
@@ -177,7 +177,8 @@ ssize_t d0_bignum_export_unsigned(const d0_bignum_t *bignum, void *buf, size_t b
                memset(buf, 0, bufsize - count);
                buf += bufsize - count;
        }
-       mp_to_unsigned_bin_n(&bignum->z, buf, &count);
+       bufsize = count;
+       mp_to_unsigned_bin_n(&bignum->z, buf, &bufsize);
        if(bufsize > count)
        {
                // REALLY BAD