svn commit: r234416 - head/usr.bin/top

Konstantin Belousov kib at FreeBSD.org
Wed Apr 18 10:23:43 UTC 2012


Author: kib
Date: Wed Apr 18 10:23:42 2012
New Revision: 234416
URL: http://svn.freebsd.org/changeset/base/234416

Log:
  Fix string buffer overflow when preparing the line of output.
  
  PR:	bin/161739
  Submitted by:	Jeremy Chadwick <freebsd jdc parodius com>
  MFC after:	1 week

Modified:
  head/usr.bin/top/machine.c

Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c	Wed Apr 18 09:42:14 2012	(r234415)
+++ head/usr.bin/top/machine.c	Wed Apr 18 10:23:42 2012	(r234416)
@@ -933,7 +933,7 @@ format_next_process(caddr_t handle, char
 		p_tot = rup->ru_inblock + rup->ru_oublock + rup->ru_majflt;
 		s_tot = total_inblock + total_oublock + total_majflt;
 
-		sprintf(fmt, io_Proc_format,
+		snprintf(fmt, sizeof(fmt), io_Proc_format,
 		    pp->ki_pid,
 		    jid_buf,
 		    namelength, namelength, (*get_userid)(pp->ki_ruid),
@@ -961,7 +961,7 @@ format_next_process(caddr_t handle, char
 		snprintf(thr_buf, sizeof(thr_buf), "%*d ",
 		    sizeof(thr_buf) - 2, pp->ki_numthreads);
 
-	sprintf(fmt, proc_fmt,
+	snprintf(fmt, sizeof(fmt), proc_fmt,
 	    pp->ki_pid,
 	    jid_buf,
 	    namelength, namelength, (*get_userid)(pp->ki_ruid),


More information about the svn-src-all mailing list