dd: Fix backwards comparison when handling short writes

ipos is always ahead of opos, so the left side of this condition
was never true. This only mattered when we get short writes, since
on EOF we always have less than a full output block, so it takes
only one normal write.
This commit is contained in:
Michael Forney 2022-12-04 00:32:21 -08:00
parent 191f7e693b
commit 00995639fe
1 changed files with 1 additions and 1 deletions

2
dd.c
View File

@ -221,7 +221,7 @@ main(int argc, char *argv[])
else
ofull++;
opos += ret;
} while ((eof && ipos < opos) || (!eof && ipos - opos >= obs));
} while (ipos - opos >= (eof ? 1 : obs));
if (opos < ipos)
memmove(buf, buf + opos, ipos - opos);
ipos -= opos;