}
}
/* 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;
- }
+ errno = 0;
+ if (full_write(file_fd, blockBuf, blockLength) != blockLength) {
+ bb_perror_msg(bb_msg_write_error);
+ goto fatal;
}
timeout = TIMEOUT;
blockBuf[i] = cc;
}
+ cksum_or_crc = read_byte(TIMEOUT);
+ if (cksum_or_crc < 0)
+ goto timeout;
if (do_crc) {
- cksum_or_crc = read_byte(TIMEOUT);
- if (cksum_or_crc < 0)
- goto timeout;
cksum_or_crc = (cksum_or_crc << 8) | read_byte(TIMEOUT);
if (cksum_or_crc < 0)
goto timeout;
- } else {
- cksum_or_crc = read_byte(TIMEOUT);
- if (cksum_or_crc < 0)
- goto timeout;
}
if (blockNo == ((wantBlockNo - 1) & 0xff)) {
}
if (cksum_or_crc != expected) {
bb_error_msg(do_crc ? "crc error, expected 0x%04x, got 0x%04x"
- : "checksum error, expected 0x%02x, got 0x%02x",
- expected, cksum_or_crc);
+ : "checksum error, expected 0x%02x, got 0x%02x",
+ expected, cksum_or_crc);
goto error;
}
continue;
error:
timeout:
+ blockLength = 0;
errors++;
if (errors == MAXERRORS) {
/* Abort */