[mw-devel] [Git][arthur/mw][master] sprintf(out,"%2ldd%2ldh",t/86400, (t%86400)/3600); overflowed static char out[7]…

Dom Rushbrook psycodom at sucs.org
Mon Aug 1 06:48:51 BST 2016


Dom Rushbrook pushed to branch master at Justin Mitchell / mw


Commits:
39c45210 by Dom Rushbrook at 2016-08-01T06:44:01+01:00
sprintf(out,"%2ldd%2ldh",t/86400, (t%86400)/3600); overflowed static char out[7] when t > 100days as %2ld only states a minimum width.
Changed out to allow for the longest possible string that sprintf can make from a 64bit unsigned long '106751991167300d15h' (20 chars including the null)
Fixes #22

- - - - -


1 changed file:

- src/client/who.c


Changes:

=====================================
src/client/who.c
=====================================
--- a/src/client/who.c
+++ b/src/client/who.c
@@ -30,7 +30,7 @@ extern struct user * const user;
 
 char *itime(unsigned long t)
 {
-	static char out[7];
+	static char out[20];
 
 	if (t>=3600*48) sprintf(out,"%2ldd%2ldh",t/86400, (t%86400)/3600);
 	else



View it on GitLab: https://projects.sucs.org/arthur/mw/commit/39c45210ab749d4b770db990e18d961fe520c9ad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20160801/fe5bd7ab/attachment.html>


More information about the mw-devel mailing list