public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch] statistics: fix string termination
@ 2007-04-10 15:47 Martin Peschke
  0 siblings, 0 replies; only message in thread
From: Martin Peschke @ 2007-04-10 15:47 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-s390

Make sure strsep() in statistic_release_def() finds a terminanal '\0' and
doesn't attempt to access bytes outside the given buffer.

(Patch fixes
statistics-infrastructure-simplify-statistics-debugfs-write-function.patch)

Patch is against 2.6.21-rc6-mm1.

Signed-off-by: Martin Peschke <mp3@de.ibm.com>
---

 statistic.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux/lib/statistic.c
===================================================================
--- linux.orig/lib/statistic.c
+++ linux/lib/statistic.c
@@ -627,9 +627,10 @@ static ssize_t statistic_write_def(struc
 		return -EPIPE;
 	if (*offset + len > 16 * PAGE_SIZE)
 		return -ENOMEM;
-	larger = kmalloc(*offset + len, GFP_KERNEL);
+	larger = kmalloc(*offset + len + 1, GFP_KERNEL);
 	if (!larger)
 		return -ENOMEM;
+	larger[*offset + len] = '\0';
 	memcpy(larger, seq_priv->w_buf, *offset);
 	if (copy_from_user(larger + *offset, buf, len))
 		return -EFAULT;



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-04-10 15:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-10 15:47 [Patch] statistics: fix string termination Martin Peschke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox