G
gamehack
Hi all,
I've been testing out a small function and surprisingly it does not
work okay. Here's the full code listing:
#include "stdlib.h"
#include "stdio.h"
char* escaped_byte_cstr_ref(char byte);
int main (int argc, const char * argv[])
{
char* t = escaped_byte_cstr_ref('!');
printf(t);
free(t);
return 0;
}
char* escaped_byte_cstr_ref(char byte)
{
char buff[3];
sprintf(buff, "%X", byte);
char* str = malloc(4);
str[0] = '%';
str[1] = buff[0];
str[2] = buff[1];
str[3] = 0x0;
return str;
}
The program does not print anything - neither in bash nor in gdb.
Although I do remember getting it running on XP with migw(currently I'm
testing on OS X).
Thanks for your help,
gamehack
I've been testing out a small function and surprisingly it does not
work okay. Here's the full code listing:
#include "stdlib.h"
#include "stdio.h"
char* escaped_byte_cstr_ref(char byte);
int main (int argc, const char * argv[])
{
char* t = escaped_byte_cstr_ref('!');
printf(t);
free(t);
return 0;
}
char* escaped_byte_cstr_ref(char byte)
{
char buff[3];
sprintf(buff, "%X", byte);
char* str = malloc(4);
str[0] = '%';
str[1] = buff[0];
str[2] = buff[1];
str[3] = 0x0;
return str;
}
The program does not print anything - neither in bash nor in gdb.
Although I do remember getting it running on XP with migw(currently I'm
testing on OS X).
Thanks for your help,
gamehack