From c4fbf7a36539cc7e71d4fb6eea03229a53b35a97 Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divverent@xonotic.org>
Date: Fri, 29 Apr 2011 13:59:28 +0200
Subject: [PATCH] fix possible overrun

---
 d0_bignum-tommath.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/d0_bignum-tommath.c b/d0_bignum-tommath.c
index 966bd05..414d5af 100644
--- a/d0_bignum-tommath.c
+++ b/d0_bignum-tommath.c
@@ -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
-- 
2.39.5