Re: [PATCH] tmpfs: support SEEK_DATA and SEEK_HOLE (reprise)

2012-11-29 Thread Jim Meyering
Dave Chinner wrote: ... >> So, yes, GNU cp will soon use this feature. > > It would be nice if utilities like grep used it, too, because having > grep burn gigabytes of memory scanning holes in large files and > then going OOM is, well, kind of nasty: > > $ xfs_io -f -c "truncate 1t" blah > $ ls -l

Re: [PATCH] tmpfs: support SEEK_DATA and SEEK_HOLE (reprise)

2012-11-28 Thread Jim Meyering
Jeff Liu wrote: > On 11/29/2012 12:15 PM, Jim Meyering wrote: >> Hugh Dickins wrote: >>> On Thu, 29 Nov 2012, Jaegeuk Hanse wrote: >> ... >>>> But this time in which scenario will use it? >>> >>> I was not very convinced by the grep argument

Re: [PATCH] tmpfs: support SEEK_DATA and SEEK_HOLE (reprise)

2012-11-28 Thread Jim Meyering
Hugh Dickins wrote: > On Thu, 29 Nov 2012, Jaegeuk Hanse wrote: ... >> But this time in which scenario will use it? > > I was not very convinced by the grep argument from Jim and Paul: > that seemed to be grep holding on to a no-arbitrary-limits dogma, > at the expense of its users, causing an absu

Re: [PATCH] bfa: avoid buffer overrun for 12-byte model name

2012-10-14 Thread Jim Meyering
Jim Meyering wrote: > Jim Meyering wrote: >> Krishna Gudipati wrote: >>>> -Original Message- >>>> From: Jim Meyering [mailto:j...@meyering.net] >>>> Sent: Monday, August 20, 2012 9:55 AM >>>> To: linux-kernel@vger.kernel.org >&

Re: [PATCH] bfa: avoid buffer overrun for 12-byte model name

2012-10-14 Thread Jim Meyering
Jim Meyering wrote: > Krishna Gudipati wrote: >>> -Original Message- >>> From: Jim Meyering [mailto:j...@meyering.net] >>> Sent: Monday, August 20, 2012 9:55 AM >>> To: linux-kernel@vger.kernel.org >>> Cc: Jim Meyering; Jing Huang; Kris

Re: [PATCH] kmemleak: avoid buffer overrun: NUL-terminate strncpy-copied command

2012-08-28 Thread Jim Meyering
Dan Carpenter wrote: > On Fri, Aug 24, 2012 at 01:23:29PM +0200, Jim Meyering wrote: >> In that case, what would you think of a patch to use strcpy instead? >> >> - strncpy(object->comm, current->comm, sizeof(object->comm)); >> +

Re: [PATCH] kmemleak: avoid buffer overrun: NUL-terminate strncpy-copied command

2012-08-24 Thread Jim Meyering
Catalin Marinas wrote: > On Mon, Aug 20, 2012 at 05:55:22PM +0100, Jim Meyering wrote: >> From: Jim Meyering >> >> strncpy NUL-terminates only when the length of the source string >> is smaller than the size of the destination buffer. >> The two other strncpy uses

[PATCHv2] fs/9p: avoid debug OOPS when reading a long symlink

2012-08-21 Thread Jim Meyering
Reading a symlink longer than the given buffer, a p9_debug use would try to print the link name (not NUL-terminated) using a %s format. Use %.*s instead, and replace the strncpy+strnlen with functionally equivalent strlen+memcpy. Signed-off-by: Jim Meyering --- V1 provoked a warning due to

Re: a few strncpy-related patches

2012-08-20 Thread Jim Meyering
Andi Kleen wrote: > Jim Meyering writes: > >> I've seen a few too many cases of strncpy misuse. >> Looking through linux sources, I spotted/fixed these: >> >> [PATCH] ACPI: remove unwarranted use of strncpy >> [PATCH] fs/9p: avoid debug OOPS when reading

Re: [PATCH] bfa: avoid buffer overrun for 12-byte model name

2012-08-20 Thread Jim Meyering
Krishna Gudipati wrote: >> -Original Message- >> From: Jim Meyering [mailto:j...@meyering.net] >> Sent: Monday, August 20, 2012 9:55 AM >> To: linux-kernel@vger.kernel.org >> Cc: Jim Meyering; Jing Huang; Krishna Gudipati; James E.J. Bottomley; linux- >

Re: [PATCH] cifs: remove misleading strncpy: each name has length < 16

2012-08-20 Thread Jim Meyering
Jim Meyering wrote: > From: Jim Meyering > > Each of the protocols[i].name strings (statically declared above) > has length less than 16, so this use of strncpy is misleading: > strncpy(pSMB->DialectsArray+count, protocols[i].name, 16); > Besides, if a new name were adde

Re: [PATCH] cifs: remove misleading strncpy: each name has length < 16

2012-08-20 Thread Jim Meyering
Bastien ROUCARIES wrote: > Le 20 août 2012 19:29, "Jim Meyering" a écrit : >> >> From: Jim Meyering >> >> Each of the protocols[i].name strings (statically declared above) >> has length less than 16, so this use of strncpy is misleading: >>   str

[PATCH] fs/9p: avoid debug OOPS when reading a long symlink

2012-08-20 Thread Jim Meyering
From: Jim Meyering Reading a symlink longer than the given buffer, a p9_debug use would try to print the link name (not NUL-terminated) using a %s format. Use %.*s instead, and replace the strncpy+strnlen with functionally equivalent strlen+memcpy. Signed-off-by: Jim Meyering --- fs/9p

a few strncpy-related patches

2012-08-20 Thread Jim Meyering
I've seen a few too many cases of strncpy misuse. Looking through linux sources, I spotted/fixed these: [PATCH] ACPI: remove unwarranted use of strncpy [PATCH] fs/9p: avoid debug OOPS when reading a long symlink [PATCH] kmemleak: avoid buffer overrun: NUL-terminate strncpy-copied [PATCH] bfa: avoi

[PATCH] kmemleak: avoid buffer overrun: NUL-terminate strncpy-copied command

2012-08-20 Thread Jim Meyering
From: Jim Meyering strncpy NUL-terminates only when the length of the source string is smaller than the size of the destination buffer. The two other strncpy uses (just preceding) happen to be ok with the current TASK_COMM_LEN (16), because the literals "hardirq" and "softirq&qu

[PATCH] bfa: avoid buffer overrun for 12-byte model name

2012-08-20 Thread Jim Meyering
From: Jim Meyering we use strncpy to copy a model name of length up to 15 (16, if you count the NUL), into a buffer of size 12 (BFA_FCS_PORT_SYMBNAME_MODEL_SZ). However, strncpy does not always NUL-terminate, so whenever the original model string has strlen >= 12, the following strncat re

[PATCH] cifs: remove misleading strncpy: each name has length < 16

2012-08-20 Thread Jim Meyering
From: Jim Meyering Each of the protocols[i].name strings (statically declared above) has length less than 16, so this use of strncpy is misleading: strncpy(pSMB->DialectsArray+count, protocols[i].name, 16); Besides, if a new name were added with length N >= 16, the existing strncpy-usin

[PATCH] ACPI: remove unwarranted use of strncpy

2012-08-20 Thread Jim Meyering
From: Jim Meyering strncpy is best avoided in general. Here, using strcpy would have been clearer and semantically equivalent, but we can do better still by removing it: i.e., use kstrdup in place of kzalloc+strncpy. Signed-off-by: Jim Meyering --- drivers/acpi/sysfs.c | 3 +-- 1 file

[PATCH] 9p: handle kstrdup and match_strdup failure

2008-02-19 Thread Jim Meyering
;. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- FYI, my first crack at cleaning up v9fs_parse_options removed the match_strdup call altogether, but was more invasive in that it added a new function, match_strcmp and made the existing match_number function public. The patch below

[PATCH] usbaudio: handle kcalloc failure

2008-02-19 Thread Jim Meyering
* sound/usb/usbaudio.c (check_hw_params_convention): Handle kcalloc failure. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- sound/usb/usbaudio.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 8fa9356..b

handle memory allocation failure

2008-02-19 Thread Jim Meyering
Hello, I spotted a few unchecked memory allocation failures recently, and went looking for more. I found and fixed seven others. I posted them all in one change-set, here: Thanks again to Markus Armbruster for a rigorous review. Subject: [PATCH] Handle memory allocation failure. http://t

[PATCH] hfsplus: handle match_strdup failure

2008-02-19 Thread Jim Meyering
* fs/hfsplus/options.c (hfsplus_parse_options): Handle match_strdup failure. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- fs/hfsplus/options.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c index dc64fac..9

[PATCH] hfs: handle match_strdup failure

2008-02-19 Thread Jim Meyering
* fs/hfs/super.c (parse_options): Handle match_strdup failure, twice. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- fs/hfs/super.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/hfs/super.c b/fs/hfs/super.c index 32de44e..8cf6797 100644 --- a/

[PATCH] affs: handle match_strdup failure

2008-02-19 Thread Jim Meyering
* fs/affs/super.c (parse_options): Remove useless initialization. Handle match_strdup failure. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- fs/affs/super.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/affs/super.c b/fs/affs/super.c index d2dc047..0

[PATCH] alpha: handle kcalloc failure

2008-02-19 Thread Jim Meyering
* arch/alpha/kernel/module.c (module_frob_arch_sections): Handle kcalloc failure. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- arch/alpha/kernel/module.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/mo

[PATCH] lib: Handle failed malloc.

2008-02-19 Thread Jim Meyering
* lib/inflate.c (inflate_dynamic): Don't deref NULL upon failed malloc. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- 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("http://vger.kern

[PATCH] Handle memory allocation failure.

2008-02-08 Thread Jim Meyering
on Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Fri, 8 Feb 2008 15:23:35 +0100 Subject: [PATCH] Handle memory allocation failure. * arch/alpha/kernel/module.c (module_frob_arch_sections): Handle kcalloc failure. * fs/9p/v9fs.c (v9fs_parse_options): Handle kstrdup and match_

[PATCH] uml: handle unusual results from find_tempdir.

2008-02-05 Thread Jim Meyering
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-

[PATCH] uml: Handle failed malloc.

2008-02-05 Thread Jim Meyering
* arch/um/os-Linux/mem.c (make_tempfile): Don't deref NULL upon failed malloc. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- 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 @@ -1

[PATCH] lib/inflate.c: Handle failed malloc.

2008-02-05 Thread Jim Meyering
* lib/inflate.c (inflate_dynamic): Don't deref NULL upon failed malloc. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- 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("http://vger.kern