update header before the write

pull/23/head
Gerard Wagener 2018-12-04 16:40:59 +01:00
parent 0978d5cc0f
commit fe8ca6a9a7
1 changed files with 2 additions and 2 deletions

View File

@ -183,11 +183,11 @@ void d4_transfert(d4_t* d4)
hmac_sha256_update(d4->ctx, (const unsigned char*)&d4->header,
sizeof(d4_header_t));
hmac_sha256_update(d4->ctx, (const unsigned char*)buf, nread);
write(d4->destination.fd, &d4->header, sizeof(d4->header));
write(d4->destination.fd,buf,nread);
hmac_sha256_final(d4->ctx, hmac, SZHMAC);
//Add it to the header
memcpy(d4->header.hmac, hmac, SZHMAC);
write(d4->destination.fd, &d4->header, sizeof(d4->header));
write(d4->destination.fd,buf,nread);
} else{
//FIXME no data available, sleep, abort, retry
break;