summaryrefslogtreecommitdiffstats
path: root/text-utils/hexdump-display.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
commit1272be04be0cb803eec87f602edb2e3e6f111aea (patch)
treebce17f6478cdd9f3c4ec3d751135dc42786d6a56 /text-utils/hexdump-display.c
parentReleasing progress-linux version 2.39.3-11~progress7.99u1. (diff)
downloadutil-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.tar.xz
util-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'text-utils/hexdump-display.c')
-rw-r--r--text-utils/hexdump-display.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/text-utils/hexdump-display.c b/text-utils/hexdump-display.c
index bc92bd0..c865127 100644
--- a/text-utils/hexdump-display.c
+++ b/text-utils/hexdump-display.c
@@ -250,6 +250,8 @@ void display(struct hexdump *hex)
struct list_head *p, *q, *r;
while ((bp = get(hex)) != NULL) {
+ ssize_t rem = hex->blocksize;
+
fs = &hex->fshead; savebp = bp; saveaddress = address;
list_for_each(p, fs) {
@@ -263,7 +265,7 @@ void display(struct hexdump *hex)
cnt = fu->reps;
- while (cnt) {
+ while (cnt && rem >= 0) {
list_for_each(r, &fu->prlist) {
pr = list_entry(r, struct hexdump_pr, prlist);
@@ -280,12 +282,18 @@ void display(struct hexdump *hex)
print(pr, bp);
address += pr->bcnt;
+
+ rem -= pr->bcnt;
+ if (rem < 0)
+ break;
+
bp += pr->bcnt;
}
--cnt;
}
}
bp = savebp;
+ rem = hex->blocksize;
address = saveaddress;
}
}