Hi!
I writed a simple server, that sends an ELF file everytime someone connects to it. But the problem is that this file containts NULL bytes:
Code:
char code[947]={ 127, 69, 76, 70, 1, 1, 1, 0, 0..
The recv(); returns 947. Thats the size of the ELF file. But the problem is when I try to save this file. I try to save it like this:
Code:
recv(sock_fd, buffer, sizeof(buffer..
FILE *fd;
fd = fopen("DATA", "w");
fprintf(fd, buffer);
close(fd)
But it only saves the first 7 bytes, and ends on NULL character. Is there any way to ignore NULL termination? I also try to save it like this:
Code:
FILE *fd;
fd = fopen("DATA", "a");
int i;
for(i=0; i<recv_data_size; i++){
fprintf(fd, &buffer[i]);
}
close(fd);
But then data somehow repeats:
Code:
.ELF...ELF...LF...F........444444 (
There are double ELF's and 4 F's, but there should only be one! Thank you!