+ /* 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 */
+ errno = 0;
+ if (full_write(file_fd, blockBuf, blockLength) != blockLength) {
+ bb_perror_msg(bb_msg_write_error);
+ goto fatal;
+ }
+