[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#700573: marked as done (wheezy-amd64: reusing the same va_list with vsnprintf() gives a print error)



Your message dated Thu, 14 Feb 2013 18:21:18 +0100
with message-id <20130214172118.GA25424@waldi.eu.org>
and subject line Re: Bug#700573: wheezy-amd64: reusing the same va_list with vsnprintf() gives a print error
has caused the Debian Bug report #700573,
regarding wheezy-amd64: reusing the same va_list with vsnprintf() gives a print error
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
700573: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=700573
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: libc6
Version: 2.11.3-4
Severity: normal

/*
   This bugg is not on wheezy-i386, squeeze-i386, squeeze-arm

   Maybe I should not use vsnprintf() twice with the same va_list but it works
elsewhere

   Here is how I use vsnprintf() :
   The error return value of  vsnprintf() is  the  number  of  characters which
would have been written to the final string
   if enough space had been available.
   On squeeze and earlier, I create this normal error to get the length of the
needed buffer.
   To create this error I first call vsnprintf() with size=0  (I tried with
greater sizes but the bugg remained)
   Then I allocate the needed buffer  (like vasprintf does internally) and call
vsnprintf() again with right size.

   Howerver, on wheezy-amd64, this does not work if I use the same va_list for
the two vsnprintf() calls.
   I have to use a second va_list to get it work

   The system information given here is the one of my squeeze internet PC
    the wheezy PC is not connected to internet
    Here are some informations about libc6 in my wheezy-amd64
     wheezy-amd64> ls -l /lib/x86_64-linux-gnu/libc.so.6
              lrwxrwxrwx 1 root root 12 Feb 14 12:21 /lib/x86_64-linux-
gnu/libc.so.6 -> libc-2.13.so

 */

#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>

void trace (const char *chFormat, ...) {
  va_list args1, args2;
  va_start(args1, chFormat);
  va_start(args2, chFormat);

  char buff[100];  // no dynamic allocation for this example

  int iBufSize = vsnprintf(buff, 0, chFormat, args1);  // calculates the
minimum size of the buffer
  vsnprintf(buff, 90, chFormat, args1);                // wrong result when
using the previous va_list: args1 instead of args2
  printf("vsnprintf : buff size= %d\n", iBufSize);      // reports the right
size
  printf("vsnprintf : %s", buff);

  va_end(args1);
  va_end(args2);
}

int main(int argc, char **argv)
{
  int i=8;
  trace("int=%d\n", i);
}

/*
  Wrong in wheezy-amd64 when using the same va_list  args2 = args1
   ./a.out prints:
      vsnprintf : buff size= 6
      vsnprintf : int=1065712984

  OK in wheezy-amd64when using two different va_list  args2 != args1
  OK in squeeze and wheezy-i386 when using the same va_list    args2 = args1
    ./a.out prints:
      vsnprintf : buff size= 6
      vsnprintf : int=8
*/



-- System Information:
Debian Release: 6.0.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.2.35.01 (SMP w/1 CPU core)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libc6 depends on:
ii  libc-bin                      2.11.3-4   Embedded GNU C Library: Binaries
ii  libgcc1                       1:4.4.5-8  GCC support library

Versions of packages libc6 recommends:
ii  libc6-i686                    2.11.3-4   Embedded GNU C Library: Shared lib

Versions of packages libc6 suggests:
ii  debconf [debconf-2.0]         1.5.36.1   Debian configuration management sy
pn  glibc-doc                     <none>     (no description available)
ii  locales                       2.11.3-4   Embedded GNU C Library: National L

-- debconf information:
  glibc/upgrade: true
  glibc/restart-services:
  glibc/disable-screensaver:
  glibc/restart-failed:

--- End Message ---
--- Begin Message ---
On Thu, Feb 14, 2013 at 03:34:02PM +0100, Eric Bart wrote:
>    Maybe I should not use vsnprintf() twice with the same va_list but it works
> elsewhere

Exactly. You must use va_list only once. However you can use va_copy or
how it is called.

>   int iBufSize = vsnprintf(buff, 0, chFormat, args1);  // calculates the
> minimum size of the buffer

You are trying to find vaprintf.

Bastian

-- 
No more blah, blah, blah!
		-- Kirk, "Miri", stardate 2713.6

--- End Message ---

Reply to: