[PATCH] Handle unusual results from find_tempdir.
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 [EMAIL PROTECTED] --- 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 - To unsubscribe from this list: send the line unsubscribe linux-ext4 in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Handle failed malloc.
* lib/inflate.c (inflate_dynamic): Don't deref NULL upon failed malloc. * arch/um/os-Linux/mem.c (make_tempfile): Likewise. Signed-off-by: Jim Meyering [EMAIL PROTECTED] --- arch/um/os-Linux/mem.c |2 ++ lib/inflate.c |3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c index 436f8d2..e114d09 100644 --- a/arch/um/os-Linux/mem.c +++ b/arch/um/os-Linux/mem.c @@ -172,6 +172,8 @@ int __init make_tempfile(const char *template, char **out_tempname, which_tmpdir(); tempname = malloc(MAXPATHLEN); + if (tempname == NULL) + return -1; find_tempdir(); if (template[0] != '/') diff --git a/lib/inflate.c b/lib/inflate.c index 845f91d..9762294 100644 --- a/lib/inflate.c +++ b/lib/inflate.c @@ -811,6 +811,9 @@ DEBG(dyn); ll = malloc(sizeof(*ll) * (286+30)); /* literal/length and distance code lengths */ #endif + if (ll == NULL) +return 1; + /* make local bit buffer */ b = bb; k = bk; -- 1.5.4.19.gd3dfd - To unsubscribe from this list: send the line unsubscribe linux-ext4 in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
avoid leak upon failed realloc
Here's a tiny fix to avoid a leak when realloc fails: 2007-06-16 Jim Meyering [EMAIL PROTECTED] * tdb.c (tdb_append): Don't leak a buffer when realloc fails. diff -r 777972a573b3 lib/ext2fs/tdb.c --- a/lib/ext2fs/tdb.c Fri Jun 15 18:05:09 2007 +0200 +++ b/lib/ext2fs/tdb.c Sat Jun 16 19:28:50 2007 +0200 @@ -3460,8 +3460,15 @@ int tdb_append(struct tdb_context *tdb, if (dbuf.dptr == NULL) { dbuf.dptr = (unsigned char *)malloc(new_dbuf.dsize); } else { - dbuf.dptr = (unsigned char *)realloc(dbuf.dptr, -dbuf.dsize + new_dbuf.dsize); + unsigned char *new_dptr + = (unsigned char *)realloc(dbuf.dptr, +dbuf.dsize + new_dbuf.dsize); + if (new_dptr == NULL) { + free(dbuf.dptr); + dbuf.dptr = NULL; + } else { + dbuf.dptr = new_dptr; + } } if (dbuf.dptr == NULL) { Signed-off-by: Jim Meyering [EMAIL PROTECTED] - To unsubscribe from this list: send the line unsubscribe linux-ext4 in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: close /dev/urandom fd (e2fsprogs 1.40-WIP (7-Apr-2007))
Theodore Tso [EMAIL PROTECTED] wrote: On Fri, Jun 15, 2007 at 10:28:40PM +0200, Jim Meyering wrote: The file descriptor opened on /dev/urandom can be closed sooner: Is there a reason why the caching of the open file descriptor for /dev/random is causing you problems? Keeping it open was deliberate. I saw it open at exit, missed the 'static' and thought it was an fd leak. Désolé. - To unsubscribe from this list: send the line unsubscribe linux-ext4 in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html