public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: Jeff Dike <jdike@addtoit.com>,
	linux-kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] uml: handle unusual results from find_tempdir.
Date: Tue, 05 Feb 2008 17:25:06 +0100	[thread overview]
Message-ID: <87d4rb8j6l.fsf@rho.meyering.net> (raw)


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

             reply	other threads:[~2008-02-05 16:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-05 16:25 Jim Meyering [this message]
2008-02-05 17:02 ` [PATCH] uml: handle unusual results from find_tempdir Jeff Dike

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d4rb8j6l.fsf@rho.meyering.net \
    --to=jim@meyering.net \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox