copying binary not done properly

This commit is contained in:
maliakal_d 2021-11-11 09:30:53 +01:00
parent 93a86324fb
commit fa822634aa

View File

@ -527,7 +527,7 @@ int writeBinaryFile(char *mess, char *fname, char *buffer,
if ((unitSize + bytesWritten) > filesize) { if ((unitSize + bytesWritten) > filesize) {
writeSize = filesize - bytesWritten; writeSize = filesize - bytesWritten;
} }
size_t bytes = fwrite(buffer, 1, writeSize, fp); size_t bytes = fwrite((buffer + bytesWritten, 1, writeSize, fp);
// write // write
if (bytes != (size_t)writeSize) { if (bytes != (size_t)writeSize) {
@ -543,6 +543,7 @@ int writeBinaryFile(char *mess, char *fname, char *buffer,
LOG(logDEBUG1, LOG(logDEBUG1,
("bytesWritten:%lu filesize:%lu\n", bytesWritten, filesize)); ("bytesWritten:%lu filesize:%lu\n", bytesWritten, filesize));
} }
printf("\n");
if (fclose(fp) != 0) { if (fclose(fp) != 0) {
sprintf(mess, sprintf(mess,
"Could not copy detector server. (closing file pointer)\n"); "Could not copy detector server. (closing file pointer)\n");