Fix PCLink Receive for files sized a multiple of 255 bytes

Fix from Paul Reed:
http://lists.inf.ethz.ch/pipermail/oberon/2017/010725.html
This commit is contained in:
Peter De Wachter 2017-10-22 22:00:02 +02:00
parent 7217b49551
commit 3e6ff6c22c

View File

@ -101,18 +101,18 @@ static uint32_t PCLink_RData(const struct RISC_Serial *serial) {
}
} else {
int pos = (rxcount - fnlen - 1) % 256;
if (pos == 0) {
if (pos == 0 || flen == 0) {
if (flen > 255) {
ch = 255;
} else {
ch = (uint8_t)flen;
if (flen == 0) {
mode = 0; unlink(RecName);
}
}
} else {
read(fd, &ch, 1);
flen--;
if (flen == 0) {
mode = 0; unlink(RecName);
}
}
}
}