🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1237

regex.c: uninitialized field causes SEGV

#1237
From: Paul Stravers
Date: Fri, 18 Dec 1992 15:13
36 lines
2146 bytes
This reports a small bug and a fix for GNU regex.c version 0.11.

The POSIX function regcomp(preg, pattern, cflags) does not initialize the field
preg->allocated to 0 before calling regex_compile(). Dependent on the random
value of this field, this causes regex_compile() to abort with a SEGV. Here
is the patch:

------------------------------------------------------------------------------
**************
*** 4683,4690
      = cflags & REG_EXTENDED ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
  
    /* regex_compile will allocate the space for the compiled pattern.  */
    preg->buffer = 0;
    
    /* Don't bother to use a fastmap when searching.  This simplifies the
       REG_NEWLINE case: if we used a fastmap, we'd have to put all the
       characters after newlines into the fastmap.  This way, we just try
--- 4687,4695 -----
      = cflags & REG_EXTENDED ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
  
    /* regex_compile will allocate the space for the compiled pattern.  */
    preg->buffer = 0;
+   preg->allocated = 0;
    
    /* Don't bother to use a fastmap when searching.  This simplifies the
       REG_NEWLINE case: if we used a fastmap, we'd have to put all the
       characters after newlines into the fastmap.  This way, we just try
------------------------------------------------------------------------------

-- 
Delft University of Technology      |  email stravers@donau.et.tudelft.nl
Faculty of Electrical Engineering   |  fax +31 15 786190
Mekelweg 4                          |  ph. +31 15 786280
2628 CD   Delft                     |
the Netherlands                     |
Technical Details
Message-ID: <9212181313.AA18457@muresh.et.tudelft.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!muresh.et.tudelft.NL!stravers

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!muresh.et.tudelft.NL!stravers
From: stravers@muresh.et.tudelft.NL (Paul Stravers)
Subject: regex.c: uninitialized field causes SEGV
Message-ID: <9212181313.AA18457@muresh.et.tudelft.nl>
Sender: gnulists@ai.mit.edu
Reply-To: Paul Stravers <stravers@donau.et.tudelft.nl>
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 18 Dec 1992 15:13:30 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 37