Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Aug 2004 12:02:36 -0700
From:      Sean McNeil <sean@mcneil.com>
To:        obrien@freebsd.org
Cc:        current@freebsd.org
Subject:   Re: bsdtar core dumps
Message-ID:  <1093460556.82060.5.camel@server.mcneil.com>
In-Reply-To: <20040825181730.GJ53710@dragon.nuxi.com>
References:  <1092777586.92327.9.camel@server.mcneil.com> <1093369220.10362.6.camel@server.mcneil.com> <20040824200225.V517@beagle.kn.op.dlr.de> <1093371600.10464.23.camel@server.mcneil.com> <20040824205417.L517@beagle.kn.op.dlr.de> <1093377802.43728.11.camel@server.mcneil.com> <1093385848.84723.2.camel@server.mcneil.com> <20040825181730.GJ53710@dragon.nuxi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 2004-08-25 at 11:17, David O'Brien wrote:
> On Tue, Aug 24, 2004 at 03:17:28PM -0700, Sean McNeil wrote:
> > > > SM>> You cannot use a va_list twice. As soon as someone call
> > > > va_arg() on the SM>> ap all the aps in the calling functions get
> > > > invalid. The only thing that SM>> can and must be done is that the
> > > > function that did the va_start() must SM>> call va_end.
> ...
> > I missed one in vfwprintf.c.  I needs a va_end(orgap) just like above.
> > 
> > Also, I've searched all of src and found one additional place that there
> > is a va_copy without a va_end.
> > 
> > contrib/gnu-sort/lib/version-etc.c
> > 
> > All other uses appear to be properly matched.
> 
> Can you please make a new, complete patch?
> I'll commit it ASAP.

Thanks David,

Here are are the patches of all unmatched/missing va_copy/va_end and
core dump fix to libarchive:

*** ./contrib/gnu-sort/lib/version-etc.c.orig   Wed Aug 11 23:55:32 2004
--- ./contrib/gnu-sort/lib/version-etc.c        Wed Aug 25 11:56:22 2004
*************** Written by %s, %s, %s,\n%s, %s, %s, %s,\
*** 140,146 ****
                authors);
        break;
      }
!   va_end (authors);
    putc ('\n', stream);

    fputs (version_etc_copyright, stream);
--- 140,148 ----
                authors);
        break;
      }
! #ifdef va_copy
!   va_end (tmp_authors);
! #endif
    putc ('\n', stream);

    fputs (version_etc_copyright, stream);
*************** version_etc (FILE *stream,
*** 175,178 ****
--- 177,181 ----

    va_start (authors, version);
    version_etc_va (stream, command_name, package, version, authors);
+   va_end (authors);
  }
*** ./lib/libarchive/archive_string_sprintf.c.orig      Fri Aug 13 20:45:45 2004
--- ./lib/libarchive/archive_string_sprintf.c   Wed Aug 25 11:55:46 2004
*************** __archive_string_vsprintf(struct archive
*** 47,65 ****
      va_list ap)
  {
        size_t l;

        if (fmt == NULL) {
                as->s[0] = 0;
                return;
        }

        l = vsnprintf(as->s, as->buffer_length, fmt, ap);
        /* If output is bigger than the buffer, resize and try again. */
        if (l+1 >= as->buffer_length) {
                __archive_string_ensure(as, l + 1);
!               l = vsnprintf(as->s, as->buffer_length, fmt, ap);
        }
        as->length = l;
  }

  /*
--- 47,68 ----
      va_list ap)
  {
        size_t l;
+       va_list ap1;

        if (fmt == NULL) {
                as->s[0] = 0;
                return;
        }

+       va_copy(ap1,ap);
        l = vsnprintf(as->s, as->buffer_length, fmt, ap);
        /* If output is bigger than the buffer, resize and try again. */
        if (l+1 >= as->buffer_length) {
                __archive_string_ensure(as, l + 1);
!               l = vsnprintf(as->s, as->buffer_length, fmt, ap1);
        }
        as->length = l;
+       va_end(ap1);
  }

  /*
*** ./lib/libc/stdio/vfprintf.c.orig    Tue Jun  8 05:03:48 2004
--- ./lib/libc/stdio/vfprintf.c Wed Aug 25 11:55:30 2004
*************** error:
*** 1237,1242 ****
--- 1237,1243 ----
        if (dtoaresult != NULL)
                freedtoa(dtoaresult);
  #endif
+       va_end(orgap);
        if (convbuf != NULL)
                free(convbuf);
        if (__sferror(fp))
*** ./lib/libc/stdio/vfwprintf.c.orig   Tue Jun  8 05:03:48 2004
--- ./lib/libc/stdio/vfwprintf.c        Wed Aug 25 11:55:30 2004
*************** number:                 if ((dprec = prec) >= 0)
*** 1232,1237 ****
--- 1232,1238 ----
        }
  done:
  error:
+       va_end(orgap);
        if (convbuf != NULL)
                free(convbuf);
        if (__sferror(fp))




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1093460556.82060.5.camel>