<?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>114499</bug_id>
          
          <creation_ts>2005-12-04 22:06 0000</creation_ts>
          <short_desc>sys-apps/texinfo: patch for insecure temporary file creation changes texindex behavior</short_desc>
          <delta_ts>2006-02-07 22:30:54 0000</delta_ts>
          
          
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Core system</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>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>jaervosz@gentoo.org</reporter>
          <assigned_to>base-system@gentoo.org</assigned_to>
          <cc>security@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-12-04 22:06:37 0000</bug_when>
            <thetext>Seems like there might be problems with the patch on bug #106105 
 
It looks like the fix for CAN-2005-3011 (texinfo predictable temporary  
files issue) being used by ubuntu and others is incorrect (see below).  
  
Does anyone have a better and/or officially blessed (does texinfo have  
a maintainer?) patch for this?  
  
Colin Percival  
  
-------- Original Message --------  
Subject: [csjp@FreeBSD.org: Re: Ubuntu patch for texinfo (CAN-2005-3011)]  
Date: Sat, 3 Dec 2005 19:11:12 +0000  
From: Christian S.J. Peron &lt;csjp@freebsd.org&gt;  
To: secteam@freebsd.org  
  
Colin / team  
  
I sent this message to Martin Pitt a while ago, but I have not recieved  
any response. Who owns texinfo?  
  
I am sure we can roll our own fix but I would rather whoever maintains this  
program provide a security fix.  
  
  
Any ideas?  
  
----- Forwarded message from &quot;Christian S.J. Peron&quot; &lt;csjp@FreeBSD.org&gt; -----  
  
From: &quot;Christian S.J. Peron&quot; &lt;csjp@FreeBSD.org&gt;  
To: martin.pitt@canonical.com  
Date: Sun, 13 Nov 2005 05:43:34 +0000  
Subject: Re: Ubuntu patch for texinfo (CAN-2005-3011)  
  
On Don, 06 Okt 2005, Martin Pitt wrote:  
&gt; Since the previously proposed patch is very intrusive and not really  
&gt; appropriate for a security update, I created my own minimal patch:  
&gt;   
&gt;   http://patches.ubuntu.com/patches/texinfo.CAN-2005-3011.diff  
  
After discussing this fix with some of my colleagues, it appears that  
your fix makes it impossible to unlink the temporary files.  
  
void  
flush_tempfiles (int to_count)  
{  
  if (keep_tempfiles)  
    return;  
  while (last_deleted_tempcount &lt; to_count)  
    unlink (maketempname (++last_deleted_tempcount));  
}  
  
flush_tempfiles would result in texindex exiting via EEXIST, because now  
maketempname actually creates the files with the O_EXCL flag. Although  
this fixes the race condition, it changes the behavior of the program.  
  
Was this intentional or am I missing something here?  
  
--   
Christian S.J. Peron  
csjp@FreeBSD.ORG  
FreeBSD Committer  
FreeBSD Security Team  
  
----- End forwarded message -----  
  
--   
Christian S.J. Peron  
csjp@FreeBSD.ORG  
FreeBSD Committer  
FreeBSD Security Team  
_______________________________________________________  
Please think twice when forwarding, cc:ing, or bcc:ing  
security-team messages.  Ask if you are unsure.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-12-05 00:34:04 0000</bug_when>
            <thetext>http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/texinfo/ 
 
texinfo-4.8-owl-texindex-tmp.diff is our current patch.  Older versions 
of it (for older versions of texinfo) may be found in the Attic. 
Originally, this was a part of texinfo-4.0-owl-tmp.diff, which I entered 
with this comment: 
 
* Wed Jan 03 2001 Solar Designer &lt;solar-at-owl.openwall.com&gt; 
- Patch to create temporary files safely. 
- Give offline sorting in texindex a chance to work (fixed a bug in there; 
did anyone ever test that code, it certainly looks like not). 
 
This patch has the disadvantage of producing a spurious link-time warning 
about mktemp() (although the surrounding code makes this call safe). 
This is because we still had glibc 2.1.3 at the time.  This should be 
updated to use mkdtemp() now (the change is trivial). 
 
--  
/sd </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-12-09 06:56:41 0000</bug_when>
            <thetext>Ccing vapier so that he doublechecks Gentoo&apos;s status on this.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-12-13 10:18:01 0000</bug_when>
            <thetext>vapier: any hint on our vulnerability status here ?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-12-20 04:06:19 0000</bug_when>
            <thetext>We use a patch based on Martin Pitt&apos;s one.
Apparently would be better to use the patch from Openwall, which I&apos;ll attach here.

Note that this is not a security issue, since Martin Pitt&apos;s patch solves the security problem, it just changes the way texindex is supposed to work, so it would be a bug.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-12-20 04:07:41 0000</bug_when>
            <thetext>Created an attachment (id=75188)
texinfo-4.8-owl-texindex-tmp.diff

New patch, from Owl</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2006-02-07 22:30:54 0000</bug_when>
            <thetext>4.8-r3 uses the patch here</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>75188</attachid>
            <date>2005-12-20 04:07 0000</date>
            <desc>texinfo-4.8-owl-texindex-tmp.diff</desc>
            <filename>texinfo-4.8-owl-texindex-tmp.diff</filename>
            <type>text/plain</type>
            <data encoding="base64">ZGlmZiAtcHVOciB0ZXhpbmZvLTQuOC5vcmlnL3V0aWwvdGV4aW5kZXguYyB0ZXhpbmZvLTQuOC91
dGlsL3RleGluZGV4LmMKLS0tIHRleGluZm8tNC44Lm9yaWcvdXRpbC90ZXhpbmRleC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bHQsIHMxKTsKICAgc3RyY3B5IChyZXN1bHQgKyBs
ZW4xLCBzMik7Ci0gICoocmVzdWx0ICsgbGVuMSArIGxlbjIpID0gMDsKKyAgcmVzdWx0W2xlbjEg
KyBsZW4yXSA9ICdcMCc7CiAKICAgcmV0dXJuIHJlc3VsdDsKIH0K
</data>        

          </attachment>
    </bug>

</bugzilla>