dd: Always move excess to beginning of buffer after read/write loops
Otherwise, while we may have enough room for at least one input block, we may not have enough room for an output block.
This commit is contained in:
parent
7ef4038fb5
commit
4b76652eff
7
dd.c
7
dd.c
@ -222,11 +222,10 @@ main(int argc, char *argv[])
|
|||||||
ofull++;
|
ofull++;
|
||||||
opos += ret;
|
opos += ret;
|
||||||
} while ((eof && ipos < opos) || (!eof && ipos - opos >= obs));
|
} while ((eof && ipos < opos) || (!eof && ipos - opos >= obs));
|
||||||
if (len - ipos < ibs) {
|
if (opos < ipos)
|
||||||
memmove(buf, buf + opos, ipos - opos);
|
memmove(buf, buf + opos, ipos - opos);
|
||||||
ipos -= opos;
|
ipos -= opos;
|
||||||
opos = 0;
|
opos = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
summary();
|
summary();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user