RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Ralf S. Engelschall
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   12-Jan-2008 19:56:19
  Branch: HEAD                             Handle: 2008011218561800

  Modified files:
    rpm                     CHANGES
    rpm/rpmio               macro.c

  Log:
    Fix line-continuation handling in macro definition parsing!
    
    The following "rpmmacros" was incorrectly parsed...
    
       1| %foo foo
       2| %bar %{lua: \
       3| print("bar") \
       4| }
       5| %baz baz
       6| %quux quux
    
    ...because the end of macro "%bar" was accidentally found at EOL or next
    blank line only while it should have been found at line 4.
    
    The code bug was that during the processing of character '\' at the end
    of any line (including lines 2 and 3 in the example above) the following
    newline was skipped twice: once because of the (escaping) '\' and once
    again implicitly at the end of line parsing.
    
    The bugfix is that '\' *only* blindly skips the next character if this
    next character is a regular character (not one of the line termination
    characters '\r', '\n' or '\0').
    
    The '\0' case was already handled by the code, but the '\r' and '\n'
    cases were not handled. As a result, characters at column 0 on following
    lines were not checked for special characters at all. Hence the special
    '}' character at column 0 at line 4 was not recognized and line
    continuation proceeded until EOF or next blank line (even if all those
    lines never had a line-continuation character at their end at all).
    
    Although I'm really doing advanced RPM macro hacking, this nasty bug
    never bite me until now because really all(!) of my problematic use
    cases were a final closing '}' character was actually at column 0, by
    coincidence and luckily were followed by a blank line.

  Summary:
    Revision    Changes     Path
    1.2064      +1  -0      rpm/CHANGES
    2.173       +2  -0      rpm/rpmio/macro.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2063 -r1.2064 CHANGES
  --- rpm/CHANGES       12 Jan 2008 13:25:52 -0000      1.2063
  +++ rpm/CHANGES       12 Jan 2008 18:56:18 -0000      1.2064
  @@ -1,4 +1,5 @@
   5.0.0 -> 5.1a1:
  +    - rse: fix line-continuation handling in macro definition parsing
       - rse: implement RPM Lua function util.textwrap() for auto-wrapping 
junks of larger text messages
       - rse: upgrade RPM Lua functions util.rmatch(), util.rsubst() and 
util.rsplit() to new lrexlib 2.2
       - rse: upgrade the RPM Lua extension lrexlib from ancient version 1.1x 
to latest version 2.2
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/macro.c
  ============================================================================
  $ cvs diff -u -r2.172 -r2.173 macro.c
  --- rpm/rpmio/macro.c 9 Jan 2008 00:21:36 -0000       2.172
  +++ rpm/rpmio/macro.c 12 Jan 2008 18:56:18 -0000      2.173
  @@ -378,6 +378,8 @@
            switch (*p) {
                case '\\':
                    switch (*(p+1)) {
  +                     case '\r': /[EMAIL PROTECTED]@*/ break;
  +                     case '\n': /[EMAIL PROTECTED]@*/ break;
                        case '\0': /[EMAIL PROTECTED]@*/ break;
                        default: p++; /[EMAIL PROTECTED]@*/ break;
                    }
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to