Fix x-axis address overflow in histogram (#6563)

This commit is contained in:
Farhan Saiyed 2026-07-23 11:06:28 -04:00 committed by GitHub
parent 3a22989501
commit 78045e8fc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 116 additions and 147 deletions

View file

@ -691,8 +691,14 @@ static void render_visual_xaxis_ruler(RzStrBuf *buf, const RzHistogramInteractiv
if (!tick_cols) {
return;
}
ut32 space;
if ((data_cols > (ut32)addr_w)) {
space = data_cols - addr_w;
} else {
space = 1;
}
for (int t = 0; t < ticks; t++) {
tick_cols[t] = (int)((ut64)t * (data_cols - 1) / (ticks - 1));
tick_cols[t] = (int)((ut64)t * space / (ticks - 1));
}
rz_strbuf_appendf(buf, "%*s", gutter_w, "");
next_tick = 0;

View file

@ -1,40 +1,40 @@
NAME=Internal less
FILE==
CMDS=<<EOF
e scr.interactive=false
pd 1~..
EOF
EXPECT_ERR=<<EOF
Internal less requires scr.interactive=true.
EOF
RUN
NAME=Hud mode
FILE==
CMDS=<<EOF
e scr.interactive=false
pd 1~...
EOF
EXPECT_ERR=<<EOF
Hud mode requires scr.interactive=true.
EOF
RUN
NAME=?** search
FILE==
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=120
e scr.rows=4
e scr.color=0
< \n; ?**
echo
echo
e scr.utf8=false
< \n; ?**
echo
EOF
NAME=Internal less
FILE==
CMDS=<<EOF
e scr.interactive=false
pd 1~..
EOF
EXPECT_ERR=<<EOF
Internal less requires scr.interactive=true.
EOF
RUN
NAME=Hud mode
FILE==
CMDS=<<EOF
e scr.interactive=false
pd 1~...
EOF
EXPECT_ERR=<<EOF
Hud mode requires scr.interactive=true.
EOF
RUN
NAME=?** search
FILE==
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=120
e scr.rows=4
e scr.color=0
< \n; ?**
echo
echo
e scr.utf8=false
< \n; ?**
echo
EOF
EXPECT=<<EOF
[?25l 0> |  0> |
- │ !<command> [<args1> <args2> ...] # Run command via system(3) with raw output. Grepping via '~' automatically forces
@ -46,19 +46,19 @@ EXPECT=<<EOF
use of '!!' instead.
| !!<command> [<args1> <args2> ...] # Run command via system(3) and pipe its stdout to rizin [?25h
EOF
RUN
NAME=?** entire help string on match
FILE=--
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=100
e scr.rows=3
e scr.color=0
< f\n; ?**
echo
EOF
RUN
NAME=?** entire help string on match
FILE=--
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=100
e scr.rows=3
e scr.color=0
< f\n; ?**
echo
EOF
EXPECT=<<EOF
[?25l 0> |  0> |
- │ !<command> [<args1> <args2> ...] # Run command via system(3) with raw output. Grepping via '~'
@ -66,19 +66,19 @@ EXPECT=<<EOF
- │ !<command> [<args1> <args2> ...] # Run command via system(3) with raw output. Grepping via '~'
automatically Forces use oF '!!' instead. [?25h
EOF
RUN
NAME=?** wrapping
FILE=--
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=100
e scr.rows=5
e scr.color=0
< q\n; ?**
echo
EOF
RUN
NAME=?** wrapping
FILE=--
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=100
e scr.rows=5
e scr.color=0
< q\n; ?**
echo
EOF
EXPECT=<<EOF
[?25l 0> |  0> |
- │ !<command> [<args1> <args2> ...] # Run command via system(3) with raw output. Grepping via '~'
@ -90,37 +90,37 @@ EXPECT=<<EOF
│ %lQ <str> # Calculate length of string <str>. Quiet mode stores value in `$?`
register. (Quiet mode) [?25h
EOF
RUN
NAME=?**e search
FILE==
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=120
e scr.rows=3
e scr.color=0
< \n; ?**e
echo
EOF
RUN
NAME=?**e search
FILE==
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=120
e scr.rows=3
e scr.color=0
< \n; ?**e
echo
EOF
EXPECT=<<EOF
[?25l 0> |  0> |
- analysis.apply.signature: bool - enables/disables auto-applying signatures to the loaded binary (see also flirt 
analysis.arch: string,bind - Select the architecture to use [?25h
EOF
RUN
NAME=?*** search
FILE==
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=100
e scr.rows=6
e scr.color=0
< %l\n; ?***
echo
EOF
RUN
NAME=?*** search
FILE==
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=100
e scr.rows=6
e scr.color=0
< %l\n; ?***
echo
EOF
EXPECT=<<EOF
[?25l 0> |  0> |
- ! | Usage: !<command> [<args1> <args2> ...] # Run command via system(3) with raw output.
@ -139,21 +139,21 @@ EXPECT=<<EOF
%L | │ %Lq <str> # Calculate length of string <str>. Quiet mode stores value in `$?` register.
%L | (quiet mode) [?25h
EOF
RUN
NAME=p==v visual histogram interactive (#4431 regression)
FILE=malloc://512
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=80
e scr.rows=12
e scr.color=0
e scr.hist.minimap=true
wx 00112233445566778899aabbccddeeff @ 0
< lq; p==v
echo END
EOF
RUN
NAME=p==v visual histogram interactive (#4431 regression)
FILE=malloc://512
CMDS=<<EOF
e scr.interactive=true
e scr.utf8=true
e scr.columns=80
e scr.rows=12
e scr.color=0
e scr.hist.minimap=true
wx 00112233445566778899aabbccddeeff @ 0
< lq; p==v
echo END
EOF
EXPECT=<<EOF
[?25l ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
@ -164,8 +164,8 @@ EXPECT=<<EOF
85│█
│█
0│▲██████████████████████████████████████████████████████████████████████████
^ ^ ^ ^ ^ ^ ^ ^ ^
0x0 0x0 0x0 0x0 0x0 0x100 0x100 0x100 0
^ ^ ^ ^ ^ ^ ^ ^ ^
0x0 0x0 0x0 0x0 0x0 0x100 0x100 0x100 0x100
Index 0 data 0 0x0 0%[?25l  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 
255│ ▼
@ -175,45 +175,8 @@ Index 0 data 0 0x0 0%
85│ █
│ █
0│█████████████████████████████████████▲█████████████████████████████████████
^ ^ ^ ^ ^ ^ ^ ^ ^
0x0 0x0 0x0 0x0 0x0 0x100 0x100 0x100 0
^ ^ ^ ^ ^ ^ ^ ^ ^
0x0 0x0 0x0 0x0 0x0 0x100 0x100 0x100 0x100
Index 1 data 0 0x100 100%[?25h END
EOF
RUN
NAME=data xrefs outside functions marked as data
FILE=bins/elf/analysis/mipsbe-ip
CMDS=<<EOF
e scr.utf8=false
e scr.color=0
aaa
s 0x4350f8
< q ; Vp
echo END
EOF
EXPECT=<<EOF
[?25l[0x004350f8 [xAdvc]0 90% 115 bins/elf/analysis/mipsbe-ip]> pd $r @ data.004350f8
; XREFS(69)
;-- data.004350f8:
0x004350f8 .dword 0x00430000
; DATA XREF from fcn.004020d0 @ 0x402108
;-- data.004350fc:
0x004350fc .dword 0x00435420 ; section..sdata
; DATA XREF from fcn.004020d0 @ 0x402120
;-- data.00435100:
0x00435100 .dword 0x0043396c ; obj.__DTOR_END
; XREFS(156)
;-- data.00435104:
0x00435104 .dword 0x00420000 ; str.ute_get_ADDRESS___from_ADDRE 
; DATA XREF from sym._init @ 0x402024
; DATA XREF from sym._fini @ 0x41ecd0
;-- data.00435108:
0x00435108 .dword 0x00400000 ; segment.LOAD0 ; segment.ehdr
0x0043510c .dword 0x00000000
0x00435110 .dword 0x00000000
0x00435114 .dword 0x00000000
0x00435118 .dword 0x00000000
; DATA XREF from fcn.00414700 @ +0xbb0
; DATA XREF from sym.rtnl_open_byproto @ 0x41a878 0.0%[?25h END
EOF
RUN
RUN