[patch] tlb_uv: handle large snprintf() returns

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Dan Carpenter
Date: Monday, August 16, 2010 - 3:55 am

snprintf() returns the number of bytes that *would* have been copied if
the buffer was large enough, so it can be larger than the size of the
buffer.  In this case it's ok, but let's put a cap on it anyway so it's
easier to audit.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c
index 312ef02..5e88b3a 100644
--- a/arch/x86/kernel/tlb_uv.c
+++ b/arch/x86/kernel/tlb_uv.c
@@ -1012,6 +1012,9 @@ static ssize_t tunables_read(struct file *file, char __user *userbuf,
 		timeoutsb4reset, ipi_reset_limit, complete_threshold,
 		congested_response_us, congested_reps, congested_period);
 
+	if (ret > 300)
+		ret = 300;
+
 	return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
 }
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch] tlb_uv: handle large snprintf() returns, Dan Carpenter, (Mon Aug 16, 3:55 am)
Re: [patch] tlb_uv: handle large snprintf() returns, Andrew Morton, (Mon Sep 27, 4:12 pm)
[tip:x86/uv] x86, UV: Use allocated buffer in tlb_uv.c:tun ..., tip-bot for Dan Carp ..., (Mon Oct 4, 1:24 pm)