+ /* If last block, remove padding */
+ if (blockBegin == EOT) {
+ /* Data blocks can be padded with ^Z characters */
+ /* This code tries to detect and remove them */
+ if (blockLength >= 3
+ && blockBuf[blockLength - 1] == PAD
+ && blockBuf[blockLength - 2] == PAD
+ && blockBuf[blockLength - 3] == PAD
+ ) {
+ while (blockLength
+ && blockBuf[blockLength - 1] == PAD
+ ) {
+ blockLength--;
+ }
+ }
+ }
+ /* Write previously received block */
+ if (blockLength) {
+ errno = 0;
+ if (full_write(file_fd, blockBuf, blockLength) != blockLength) {
+ bb_perror_msg("can't write to file");
+ goto fatal;
+ }
+ }
+