<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>200006</bug_id>
          
          <creation_ts>2007-11-22 18:21 0000</creation_ts>
          <short_desc>[patch] mail-filter/procmail (all versions) out of memory crash bug when piping mail through a filter</short_desc>
          <delta_ts>2008-06-15 10:22:51 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Applications</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>gwillen@nerdnet.org</reporter>
          <assigned_to>net-mail@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>gwillen@nerdnet.org</who>
            <bug_when>2007-11-22 18:21:27 0000</bug_when>
            <thetext>When piping mail through a filter, procmail tries to allocate an excessive amount of memory due to a bug. The amount it tries to allocate depends on where its data section gets loaded in memory. On my system it allocates 2GB+, yielding an OUT OF MEMORY crash.

Patch is attached.

Reproducible: Always

Steps to Reproduce:
The bug is 100% reproducible on my system, but it depends where the linker/loader put the data section of the executable. But on systems where it appears:

1. Create a procmail recipe containing a filter (a pipe whose output is not delivered, but recaptured by procmail for further processing.)
2. Run procmail -m recipe
3. Type in a test message, or just press ctrl-D for a blank one
4. Wait for procmail to timeout several times. While it&apos;s doing this you can use strace to watch it allocating gobs of memory.
5. Procmail will bounce the message (for commandline invocation, it will just whine) with an out of memory error.
Actual Results:  
Procmail dies.

Expected Results:  
Procmail delivers a message.

I have found the bug and am attaching a patch for it. It&apos;s one character, so it should be pretty easy to verify as correct. (The variable Stdfilled is used several times very obviously as the length of a buffer, and then for a realloc, &amp;Stdfilled is used as the length of the buffer instead. Remove the &amp; and all is well.)

I have submitted this patch to bug@procmail.org and procmail-dev@procmail.org, but so far no response. (I haven&apos;t given them very long, but there&apos;s no reason this can&apos;t get fixed in Gentoo before upstream gets around to it -- they haven&apos;t released since 2001, so it will take them a while.)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>gwillen@nerdnet.org</who>
            <bug_when>2007-11-22 18:23:12 0000</bug_when>
            <thetext>Created an attachment (id=136693)
Patch to fix the bug.

The change is only one character, and it should be pretty easy to verify as correct.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dertobi123@gentoo.org</who>
            <bug_when>2008-06-15 10:22:51 0000</bug_when>
            <thetext>(In reply to comment #1)
&gt; Created an attachment (id=136693) [edit]
&gt; Patch to fix the bug.
&gt; 
&gt; The change is only one character, and it should be pretty easy to verify as
&gt; correct.
&gt; 

This is fixed in procmail-3.22-r9.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>136693</attachid>
            <date>2007-11-22 18:23 0000</date>
            <desc>Patch to fix the bug.</desc>
            <filename>procmail.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">ZGlmZiAtcmMgcHJvY21haWwtMy4yMi9zcmMvcGlwZXMuYyBwcm9jbWFpbC0zLjIyLWZpeGVkL3Ny
Yy9waXBlcy5jCioqKiBwcm9jbWFpbC0zLjIyL3NyYy9waXBlcy5jICAgVHVlIFNlcCAxMSAwMDo1
ODo0NCAyMDAxCi0tLSBwcm9jbWFpbC0zLjIyLWZpeGVkL3NyYy9waXBlcy5jICAgICBXZWQgTm92
IDIxIDIzOjUzOjM5IDIwMDcKKioqKioqKioqKioqKioqCioqKiAxOTQsMjAwICoqKioKICAgICAg
IG1ha2VibG9jaygmdGVtcCxTdGRmaWxsZWQpOwogICAgICAgdG1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