hi,
i have a problem in storing the data in allocated memory using malloc.
i have structure to store huge data form the serial port.
i have to write the raw data from the serial port in to file after converting the raw into its format[ the data format is usually float type].Code:typedef struct FileData { unsigned char *FRdata; struct FileData *next; }FileData; /*I store the data in FileData->FRdata, by allocating sufficient memory to it*/ Datacur->FRdata=(char *)malloc(sizeof(max_bytes)); for(j=0;bytes_to_read>0;j++,bytes_to_read--) Datacur->FRdata[j]=*Ftemp++; Datacur->next=NULL;
when i print few data before opening a file
there is no change in the data .Code:j=0; printf("read"); while(j<10){ printf("%02x ",Datahead->FRdata[j++]); }
The problem is after , file is openedthe data in the allocated memory{Datahead->FRdata[} has changed { the data that is written to file is different to that of original data.}Code:fptr=fopen(Surveyname,"wt");
where cud be the malicious alteration hapened.
any help on this.



LinkBack URL
About LinkBacks



!!!!!! Thanks iMalc for rightly pointing it out......