&> "$TS_OUTPUT" <<< "@@@@"
ts_finalize_subtest
+# 8-byte value match (verifies int64_t color condition)
+ts_init_subtest "8b_hex-1"
+TS_EXPECTED+=$BE_EXT
+printf '\x41\x42\x43\x44\x45\x46\x47\x48' | \
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '1/8 "%016x_L[red:0x4847464544434241]\n"' \
+ &> "$TS_OUTPUT"
+ts_finalize_subtest
+
ts_finalize
/* no offset or offset outside this print unit */
if (offt < 0)
offt = address;
- if (offt < address || offt + clr->range > address + bcnt)
+ if (offt < address || offt + (off_t) clr->range > address + bcnt)
continue;
/* match a string */
match = 1;
/* match a value */
} else if (clr->val != -1) {
- int val = 0;
+ int64_t val = 0;
/* addresses are not part of the input, so we can't
* compare with the contents of bp */
if (pr->flags == F_ADDRESS) {
if (clr->val == address)
match = 1;
- } else {
+ } else if (clr->range <= sizeof(val)) {
memcpy(&val, bp + offt - address, clr->range);
if (val == clr->val)
match = 1;
errno = 0;
end = NULL;
if (cfmt[1] == 'x' || cfmt[1] == 'X')
- hcnext->val = strtoul(cfmt + 2, &end, 16);
+ hcnext->val = strtoll(cfmt + 2, &end, 16);
else
- hcnext->val = strtoul(cfmt, &end, 8);
+ hcnext->val = strtoll(cfmt, &end, 8);
if (errno || end == cfmt)
badfmt(fmt);
cfmt = end;
++cfmt;
errno = 0;
- hcnext->range =
- strtoul(cfmt, &cfmt, 10) - hcnext->offt + 1;
+ unsigned long end_offt = strtoul(cfmt, &cfmt, 10);
if (errno)
badfmt(fmt);
- /* offset range must be between 0 and format byte count */
- if (hcnext->range < 0)
+ if (end_offt < (unsigned long) hcnext->offt)
badcnt("_L");
+ hcnext->range = end_offt - hcnext->offt + 1;
/* the offset extends over several print units, clone
* the condition, link it in and adjust the address/offset */
- while (hcnext->range > bcnt) {
+ while (hcnext->range > (size_t) bcnt) {
hc = xcalloc(1, sizeof(struct hexdump_clr));
memcpy(hc, hcnext, sizeof(struct hexdump_clr));
hcnext->offt = (off_t)-1;
/* check if the string we're looking for is the same length as the range */
- if (hcnext->str && (int)strlen(hcnext->str) != hcnext->range)
+ if (hcnext->str && strlen(hcnext->str) != hcnext->range)
badcnt("_L");
/* link in another condition */
struct list_head colorlist; /* next color unit */
const char *fmt; /* the color, UL_COLOR_* */
off_t offt; /* offset of range where unit is valid... */
- int range; /* ... and range length */
- int val; /* value ... */
+ size_t range; /* ... and range length */
+ int64_t val; /* value ... */
char *str; /* ... or string to match */
int invert; /* invert condition? */
};