I have the following sample code.
#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
int test(const char *fmt,...)
{
va_list args;
char *vacmd=NULL;
va_start(args,fmt);
vasprintf(&vacmd, fmt, args);
printf("vacmd is %s\n", vacmd);
return 0;
}
int main(void)
{
int ret = 0;
char *cmd="@wilso%nqw";
ret = test(cmd);
}
Output is :
vacmd is @wilsoqw
It removed the %n from the string.
So my question is does vasprintf() works with specials characters or not? or am I missing something?