GNU bug report logs - #13098
[PATCH] cut.c: Fix memory leak

Previous Next

Package: coreutils;

Reported by: Cojocaru Alexandru <xojoc <at> gmx.com>

Date: Thu, 6 Dec 2012 02:17:01 UTC

Severity: normal

Tags: patch

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #28 received at 13098 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: xojoc <at> gmx.com, 13098 <at> debbugs.gnu.org
Subject: Re: bug#13098: [PATCH] cut.c: Fix memory leak
Date: Mon, 10 Dec 2012 00:16:18 +0100
Pádraig Brady wrote:

> On 12/08/2012 08:27 PM, Jim Meyering wrote:
>> +# 2^31-1
>
>> +# From coreutils-8.10 through 8.20, this would make cut try to allocate
>> +# a 256MiB bit vector.  With a 20MB limit on VM, the following would fail.
>> +(ulimit -v 20000; : | cut -b2147483647- > err 2>&1) || fail=1
>> +
>> +compare /dev/null err || fail=1
>
> Perhaps use INT_MAX from getlimits?
> In either case +1

Good idea.  Thanks for the review.
Pushed.  Here's the delta.

diff --git a/tests/misc/cut-huge-to-eol-range.sh b/tests/misc/cut-huge-to-eol-range.sh
index fea8505..4e3ee03 100755
--- a/tests/misc/cut-huge-to-eol-range.sh
+++ b/tests/misc/cut-huge-to-eol-range.sh
@@ -19,11 +19,11 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ cut
 require_ulimit_
+getlimits_

-# 2^31-1
 # From coreutils-8.10 through 8.20, this would make cut try to allocate
 # a 256MiB bit vector.  With a 20MB limit on VM, the following would fail.
-(ulimit -v 20000; : | cut -b2147483647- > err 2>&1) || fail=1
+(ulimit -v 20000; : | cut -b$INT_MAX- > err 2>&1) || fail=1

 compare /dev/null err || fail=1




This bug report was last modified 12 years and 222 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.