Re: Trouble with va_list processing



thierrydollar wrote:
I have written another example of the problem with va_list

And here is the result

format = %s
arg[] = hello
format = %s
arg[] = ä ↕


Here is the source code

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

//---------------------------------------------------------------------------
void add (char *format, ...)
{
va_list args;
va_start (args, format);

printf("format = %s\n",format);
printf("arg[] = %s\n", va_arg (args, char *));
}
//---------------------------------------------------------------------------
void set (char *format, ...)
{
va_list args;
va_start (args, format);
add(format, args);
}
//---------------------------------------------------------------------------
int main()
{
char txt[] = "hello";
add ("%s",txt);
set ("%s",txt);

return 0;
}
//---------------------------------------------------------------------------

Please read http://cfaj.freeshell.org/google/
Thank you!


--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
.



Relevant Pages

  • Re: Konvertierung eines float in einen char
    ... drawTextOnPosition(GLfloat x, GLfloat y, char *format,...) ... vsprintf(buffer, format, args); ... glPushMatrix(); ...
    (de.comp.lang.c)
  • Re: Help with va_list, va_start
    ... void FormatTest(const TCHAR* format, ...) ... wvsprintf(buf, format, args); ... > // The test code ...
    (microsoft.public.vc.language)
  • Passing Variable Args
    ... void Log(const char* format, ...) ... va_list args; ... void DoLog1(const char* format, va_list* args) ...
    (comp.lang.c)
  • [Full-disclosure] Re: Format string in Doomsday 1.8.6
    ... Both Con_Message and conPrintf are vulnerable to a format string ... buffer = malloc; ... void conPrintf(int flags, const char *format, va_list args) ... vsprintf(message_buf, str, args); ...
    (Full-Disclosure)
  • Re: Format string in Doomsday 1.8.6
    ... Both Con_Message and conPrintf are vulnerable to a format string ... buffer = malloc; ... void conPrintf(int flags, const char *format, va_list args) ... vsprintf(message_buf, str, args); ...
    (Bugtraq)