Folks -
I've got a few Yahoo! Messenger .dat files that I'm trying to read. I found this site:
http://www.0xcafefeed.com/2007/12/ya...e-file-format/
that describes the file format. Basically, you have four four-byte integers, then an xor'ed message payload. The payload is different for each message. The fourth integer gives you the length of the message payload in bytes.
My goal is to read these messages in, de-XOR them, and then output them to a file. Reading the four integers is easy, but the idea fails when I get to reading the message itself. Here's the code:
Code:
#include <stdio.h>
#include <stdlib.h>
struct y_mess_header
{
int epoch_time;
int throwaway;
int sender;
int length;
char *text;
};
main()
{
int x,y;
char z;
struct y_mess_header message;
FILE *fp;
fp=fopen("./20081202-xxxxxx.dat","r");
fread(&message,sizeof(message)-4,1,fp);
message.text=(char *)malloc(message.length+1);
printf("Epoch time is: %d \n",message.epoch_time);
printf("Throwaway is: %d \n",message.throwaway);
printf("Sender is: %d \n",message.sender);
printf("Message length is: %d \n",message.length);
y=fread(&message.text,1,message.length,fp);
printf ("Read: %d\n",y);
printf("Array 0 is %c\n",message_text[0]);
}
After the fread() call, any access to the message_text array causes a segfault. I've tried to add a string terminator, which fails; printing one element of the array fails. I'm having trouble seeing what I'm doing wrong here. Does anyone have any idea?
Thanks for the help.