Poifect! ;-)

(hysterical aside)
The design flaw is with
    expandMacros(spec, spec->macros, spec->lbuf, spec->lbuf_len))
which use the 3rd argument for both input and output.

There are like 3 (checking, yes 3) places that expandMacros() is still
used, all within rpmbuild code paths. Replacing with rpmExpand()
fixes almost all the problems.

And the hysterical design reason for using a static buffer argument as both input and output was that libc5 (in like RHL 4.2 circa 1997) was "buggy".

If you don't see the humor in the above, go read lib/rpmal.c code,
which has exactly the same hysterical raison d'etre.

Sad that OSS code can never be rewritten and improved without
political consensus. Old code has a painful lingering twilight
existence before dying ...

73 de Jeff

On Dec 27, 2007, at 9:16 AM, Ralf S. Engelschall wrote:

  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: 27-Dec-2007 15:16:12
  Branch: HEAD                             Handle: 2007122714161100

  Modified files:
    rpm                     CHANGES macros.in
    rpm/build               parseSpec.c rpmspec.h spec.c

  Log:
make size of line buffer for .spec file parsing run-time configurable
    via macro _spec_line_buffer_size

  Summary:
    Revision    Changes     Path
    1.2022      +1  -0      rpm/CHANGES
    2.130       +1  -1      rpm/build/parseSpec.c
    2.70        +2  -1      rpm/build/rpmspec.h
    2.174       +4  -1      rpm/build/spec.c
    1.221       +5  -1      rpm/macros.in
______________________________________________________________________ ______

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
====================================================================== ======
  $ cvs diff -u -r1.2021 -r1.2022 CHANGES
  --- rpm/CHANGES       27 Dec 2007 09:19:57 -0000      1.2021
  +++ rpm/CHANGES       27 Dec 2007 14:16:11 -0000      1.2022
  @@ -1,4 +1,5 @@
   5.0b3 -> 5.0b4:
+ - rse: make size of line buffer for .spec file parsing run- time configurable via macro _spec_line_buffer_size - rse: improve %patch macro implementation: less expansion redundancy and macro namespace collision avoidance - rse: fix %{uncompress:<file>.lzo} by passing the required "-dc" options to LZOP's lzop(1) - rse: fix %{uncompress:<file>.lzma} by passing the required "-dc" options to LZMA Utils' lzma(1)
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/parseSpec.c
====================================================================== ======
  $ cvs diff -u -r2.129 -r2.130 parseSpec.c
  --- rpm/build/parseSpec.c     20 Dec 2007 23:35:28 -0000      2.129
  +++ rpm/build/parseSpec.c     27 Dec 2007 14:16:11 -0000      2.130
  @@ -231,7 +231,7 @@

/* Don't expand macros (eg. %define) in false branch of %if clause */
        if (spec->readStack->reading &&
- expandMacros(spec, spec->macros, spec->lbuf, sizeof(spec- >lbuf))) { + expandMacros(spec, spec->macros, spec->lbuf, spec- >lbuf_len)) {
                rpmlog(RPMLOG_ERR, _("line %d: %s\n"),
                        spec->lineNum, spec->lbuf);
                return RPMRC_FAIL;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/rpmspec.h
====================================================================== ======
  $ cvs diff -u -r2.69 -r2.70 rpmspec.h
  --- rpm/build/rpmspec.h       18 Dec 2007 19:40:52 -0000      2.69
  +++ rpm/build/rpmspec.h       27 Dec 2007 14:16:11 -0000      2.70
  @@ -117,7 +117,8 @@

   /[EMAIL PROTECTED]@*/
       struct OpenFileInfo * fileStack;
  -    char lbuf[10*BUFSIZ];
  +    char *lbuf;
  +    size_t lbuf_len;
   /[EMAIL PROTECTED]@*/
       char *lbufPtr;
       char nextpeekc;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/spec.c
====================================================================== ======
  $ cvs diff -u -r2.173 -r2.174 spec.c
  --- rpm/build/spec.c  18 Dec 2007 19:40:52 -0000      2.173
  +++ rpm/build/spec.c  27 Dec 2007 14:16:11 -0000      2.174
  @@ -472,7 +472,8 @@
       spec->st = newSt();

       spec->fileStack = NULL;
  -    spec->lbuf[0] = '\0';
+ spec->lbuf_len = (size_t)rpmExpandNumeric("%{? _spec_line_buffer_size}%{!?_spec_line_buffer_size:10000}");
  +    spec->lbuf = (char *)xcalloc(1, spec->lbuf_len);
       spec->line = spec->lbuf;
       spec->nextline = NULL;
       spec->nextpeekc = '\0';
  @@ -527,6 +528,8 @@

       if (spec == NULL) return NULL;

  +    spec->lbuf = _free(spec->lbuf);
  +
       spec->sl = freeSl(spec->sl);
       spec->st = freeSt(spec->st);

  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/macros.in
====================================================================== ======
  $ cvs diff -u -r1.220 -r1.221 macros.in
  --- rpm/macros.in     27 Dec 2007 09:19:57 -0000      1.220
  +++ rpm/macros.in     27 Dec 2007 14:16:11 -0000      1.221
  @@ -1,7 +1,7 @@
   #/*! \page config_macros Default configuration: @USRLIBRPM@/macros
   # \verbatim
   #
  -# $Id: macros.in,v 1.220 2007/12/27 09:19:57 rse Exp $
  +# $Id: macros.in,v 1.221 2007/12/27 14:16:11 rse Exp $
   #
# This is a global RPM configuration file. All changes made here will # be lost when the rpm package is upgraded. Any per-system configuration
  @@ -530,6 +530,10 @@
   # Colon separated list of permitted arbitrary tag names
   %_arbitrary_tags     Class:Track:Trackprog:Foo:Bar:Baz

  +#
  +# Byte size of line buffer for .spec file parsing
  +%_spec_line_buffer_size 10000
  +
#===================================================================== =========
   # ---- Database configuration macros.
   #    Macros used to configure Berkley db parameters.
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [EMAIL PROTECTED]

______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
Developer Communication List                        [email protected]

Reply via email to