From 301230f8fde94b5b80e9dfba51816ede340e6b64 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Sat, 10 Jul 2021 10:29:55 +1000 Subject: [PATCH] plugins/radius: Use snprintf in rc_mksid Commit 858976b1fc31 ("radius: Prevent buffer overflow in rc_mksid()") changed sprintf to slprintf to avoid a possible buffer overflow. However, this introduced a bug because slprintf does not currently handle the %lX and %hX formats. Use snprintf instead, which does, as we are not using any of the custom formats that slprintf handles in this instance. Reported-by: Adrian Ban Signed-off-by: Paul Mackerras --- pppd/plugins/radius/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pppd/plugins/radius/util.c b/pppd/plugins/radius/util.c index 740131e..751f819 100644 --- a/pppd/plugins/radius/util.c +++ b/pppd/plugins/radius/util.c @@ -75,7 +75,7 @@ rc_mksid (void) { static char buf[32]; static unsigned short int cnt = 0; - slprintf(buf, sizeof(buf), "%08lX%04X%02hX", + snprintf(buf, sizeof(buf), "%08lX%04X%02hX", (unsigned long int) time (NULL), (unsigned int) getpid (), cnt & 0xFF); -- 2.47.3