LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] uml: handle unusual results from find_tempdir.
@ 2008-02-05 16:25 Jim Meyering
  2008-02-05 17:02 ` Jeff Dike
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Meyering @ 2008-02-05 16:25 UTC (permalink / raw)
  To: Jeff Dike, linux-kernel Mailing List


An alternative: make find_tempdir set tempdir to default_tempdir
upon malloc failure.

* arch/um/os-Linux/mem.c (make_tempfile): Handle NULL tempdir.
Don't let a long tempdir (e.g., via TMPDIR) provoke heap corruption.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 arch/um/os-Linux/mem.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index e114d09..1458385 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -176,6 +176,9 @@ int __init make_tempfile(const char *template, char **out_tempname,
 	  return -1;

 	find_tempdir();
+	if (tempdir == NULL || strlen(tempdir) >= MAXPATHLEN)
+	  return -1;
+
 	if (template[0] != '/')
 		strcpy(tempname, tempdir);
 	else
--
1.5.4.19.gd3dfd

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] uml: handle unusual results from find_tempdir.
  2008-02-05 16:25 [PATCH] uml: handle unusual results from find_tempdir Jim Meyering
@ 2008-02-05 17:02 ` Jeff Dike
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Dike @ 2008-02-05 17:02 UTC (permalink / raw)
  To: Jim Meyering; +Cc: linux-kernel Mailing List

On Tue, Feb 05, 2008 at 05:25:06PM +0100, Jim Meyering wrote:
> 
> An alternative: make find_tempdir set tempdir to default_tempdir
> upon malloc failure.
> 
> * arch/um/os-Linux/mem.c (make_tempfile): Handle NULL tempdir.
> Don't let a long tempdir (e.g., via TMPDIR) provoke heap corruption.
> 
> Signed-off-by: Jim Meyering <meyering@redhat.com>

Thanks, I'll forward this on.

			Jeff

-- 
Work email - jdike at linux dot intel dot com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-05 17:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-05 16:25 [PATCH] uml: handle unusual results from find_tempdir Jim Meyering
2008-02-05 17:02 ` Jeff Dike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).