I'm actually trying to encrypt some files using a c program. So what i did is reading the file, storing the bytes in a variable, spliting the variable into to (to encrypt it using Blowfish), joining the two variables again into one and writing it to a file, but when debugging the program I always get a Segmentation Fault in this part wich is the last one :
newFile = fopen(newPath,"ab+");
fwrite(&srvBuf,1,BUFF_SIZE,newFile);
fclose(newFile);
printf("Finished");
/* Where srvBuf is my encrypted bytes, BUFF_SIZE is the size of the file,
newPath is the new file path */
You should check that
newFile != NULL
Its possible for fopen to fail for many many reasons ( directory does not exist, user lacks permissions etc. )