[PATCH] rlm_mschap: silence gcc buffer overflow detection mechanism

Petr Uzel petr.uzel at suse.cz
Mon Jun 27 09:21:18 CEST 2011


Signed-off-by: Petr Uzel <petr.uzel at suse.cz>
---
 src/modules/rlm_mschap/rlm_mschap.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/rlm_mschap/rlm_mschap.c b/src/modules/rlm_mschap/rlm_mschap.c
index ab9c4b1..da50daa 100644
--- a/src/modules/rlm_mschap/rlm_mschap.c
+++ b/src/modules/rlm_mschap/rlm_mschap.c
@@ -1780,10 +1780,10 @@ static int mschap_authenticate(void * instance, REQUEST *request)
 				 inst->allow_retry);
 
 			if (inst->retry_msg) {
-				snprintf(buffer + 9, sizeof(buffer), " C=");
+				snprintf(buffer + 9, sizeof(buffer) - 9, " C=");
 				for (i = 0; i < 16; i++) {
 					snprintf(buffer + 12 + i*2,
-						 sizeof(buffer), "%02x",
+						 sizeof(buffer) - 12 - i*2, "%02x",
 						 fr_rand() & 0xff);
 				}
 				snprintf(buffer + 12 + 32, sizeof(buffer) - 45,
-- 
1.7.3.4


Petr

--
Petr Uzel
IRC: ptr_uzl @ freenode
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freeradius.org/pipermail/freeradius-devel/attachments/20110627/939d97b2/attachment.pgp>


More information about the Freeradius-Devel mailing list