mirror of https://github.com/wolfSSL/wolfBoot.git
tools/delta: check pwrite result in bmpatch
Detect short writes and errors instead of advancing the output offset as if all bytes were written, which could silently corrupt the image.pull/814/head
parent
d977baa60e
commit
103eec95fe
|
|
@ -149,7 +149,15 @@ int main(int argc, char *argv[])
|
|||
if (r < 0)
|
||||
exit(5);
|
||||
if (r > 0) {
|
||||
pwrite(fd1, dest, r, len3);
|
||||
int off = 0;
|
||||
while (off < r) {
|
||||
ssize_t wr = pwrite(fd1, dest + off, r - off, len3 + off);
|
||||
if (wr <= 0) {
|
||||
perror("pwrite");
|
||||
exit(5);
|
||||
}
|
||||
off += (int)wr;
|
||||
}
|
||||
len3 += r;
|
||||
}
|
||||
} while (r > 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue