mirror of git://git.suckless.org/sbase
dd: Consider block count in inner read loop
When ibs is smaller than obs, checking the block count in the outer loop is not sufficient; we need to break out of the inner read loop once we've read the specified number of blocks. Thanks to phoebos for reporting this issue.
This commit is contained in:
parent
00995639fe
commit
fb16e7c6ad
6
dd.c
6
dd.c
|
@ -173,8 +173,12 @@ main(int argc, char *argv[])
|
||||||
eprintf("lseek:");
|
eprintf("lseek:");
|
||||||
/* XXX: handle non-seekable files */
|
/* XXX: handle non-seekable files */
|
||||||
}
|
}
|
||||||
while (!eof && (count == -1 || ifull + ipart < count)) {
|
while (!eof) {
|
||||||
while (ipos - opos < obs) {
|
while (ipos - opos < obs) {
|
||||||
|
if (ifull + ipart == count) {
|
||||||
|
eof = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
ret = read(ifd, buf + ipos, ibs);
|
ret = read(ifd, buf + ipos, ibs);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
eof = 1;
|
eof = 1;
|
||||||
|
|
Loading…
Reference in New Issue