- bufsize_ = count;
- mp_to_unsigned_bin_n((mp_int *) &bignum->z, buf, &bufsize_);
- bufsize = bufsize_;
- if(bufsize > count)
- {
- // REALLY BAD
- // mpz_sizeinbase lied to us
- // buffer overflow
- // there is no sane way whatsoever to handle this
- abort();
- }
- if(bufsize < count)
- {
- // BAD
- // mpz_sizeinbase lied to us
- // move the number
- if(count == 0)
- {
- memset(buf, 0, count);
- }
- else
- {
- memmove(buf + count - bufsize, buf, bufsize);
- memset(buf, 0, count - bufsize);
- }
- }