[hackers] [sbase][PATCH] dd: fix for ibs * count < obs

From: phoebos <ben_AT_bvnf.space>
Date: Tue, 22 Nov 2022 16:28:34 +0000

Previously, running `dd ibs=1 count=1` read 512 bytes rather than 1.
---
 dd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dd.c b/dd.c
index 6061048..4081eca 100644
--- a/dd.c
+++ b/dd.c
_AT_@ -174,7 +174,7 @@ main(int argc, char *argv[])
 		/* XXX: handle non-seekable files */
 	}
 	while (!eof && (count == -1 || ifull + ipart < count)) {
-		while (ipos - opos < obs) {
+		while (ipos - opos < obs && ifull + ipart < count) {
 			ret = read(ifd, buf + ipos, ibs);
 			if (ret == 0) {
 				eof = 1;
-- 
2.38.1
Received on Tue Nov 22 2022 - 17:28:34 CET

This archive was generated by hypermail 2.3.0 : Tue Nov 22 2022 - 17:36:33 CET