pixel / hexedit

View and edit files in hexadecimal or in ASCII
http://rigaux.org/hexedit.html
GNU General Public License v2.0
98 stars 41 forks source link

Malformed address in first line #31

Closed eribertomota closed 4 years ago

eribertomota commented 5 years ago

Hi,

In Debian Sid, the hexedit is truncanting the address in first line. See below:

0   46 6F 72 6D  61 74 3A 20  68 74 74 70  73 3A 2F 2F  77 77 77 2E  64 65 62 69  Format: https://www.debi
00000018   61 6E 2E 6F  72 67 2F 64  6F 63 2F 70  61 63 6B 61  67 69 6E 67  2D 6D 61 6E  an.org/doc/packaging-man
00000030   75 61 6C 73  2F 63 6F 70  79 72 69 67  68 74 2D 66  6F 72 6D 61  74 2F 31 2E  uals/copyright-format/1.
00000048   30 2F 0A 55  70 73 74 72  65 61 6D 2D  4E 61 6D 65  3A 20 68 65  78 65 64 69  0/.Upstream-Name: hexedi
00000060   74 0A 53 6F  75 72 63 65  3A 20 68 74  74 70 3A 2F  2F 72 69 67  61 75 78 2E  t.Source: http://rigaux.
00000078   6F 72 67 2F  68 65 78 65  64 69 74 2E  68 74 6D 6C  20 6F 72 0A  20 20 20 20  org/hexedit.html or.
00000090   20 20 20 20  68 74 74 70  73 3A 2F 2F  67 69 74 68  75 62 2E 63  6F 6D 2F 70      https://github.com/p
000000A8   69 78 65 6C  2F 68 65 78  65 64 69 74  0A 0A 46 69  6C 65 73 3A  20 2A 0A 43  ixel/hexedit..Files: *.C

Thanks,

Eriberto

prigaux commented 5 years ago

Works for me with hexedit 1.4.2-3

eribertomota commented 5 years ago

Em seg, 1 de out de 2018 às 04:31, Pascal Rigaux notifications@github.com escreveu:

Works for me with hexedit 1.4.2-3

Thanks for your reply. I installed a VM running Buster and I got the same results.

prigaux commented 5 years ago

Could you diagnose? Which terminal?

eribertomota commented 5 years ago

I think I found the problem. hexedit fails over some terminal types. In my system it fails inside a jail made with debootstrap command and over ssh operations.

debootstrap sid /test http://ftp.debian.org/debian

chroot /test

apt-get install hexedit

date > test

hexedit test

Thanks in advanced.

Cheers,

Eriberto

Em qua, 3 de out de 2018 às 06:27, Pascal Rigaux notifications@github.com escreveu:

Could you diagnose? Which terminal?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pixel/hexedit/issues/31#issuecomment-426569980, or mute the thread https://github.com/notifications/unsubscribe-auth/AGIyrlsqw7MUx96VE0JwmV4ljvs9Y6RKks5uhILsgaJpZM4XBGPR .

eribertomota commented 5 years ago

Taking advantage of these messages, can you implement a -v option to show version? I intent to use it for CI test in Debian (a trivial test only, to see automatically if the command runs after each build in Debian).

Thanks.

prigaux commented 5 years ago

Works for me with xterm which sets TERM=xterm.

hexedit refuses to start with rxvt-unicode which sets TERM=rxvt-256color with TERM=rxvt it works.

prigaux commented 5 years ago

For CI test, you could do hexedit -h 2>&1 | grep -q '^usage' ?

eribertomota commented 5 years ago

Works for me with xterm which sets TERM=xterm.

hexedit refuses to start with rxvt-unicode which sets TERM=rxvt-256color with TERM=rxvt it works.

Hum... Works for me with TERM=linux too. Isn't it a bug in hexedit? Note that a ssh connection will not set a special term and hexedit will show the first line wrong. Other programs work fine.

For CI test, you could do hexedit -h 2>&1 | grep -q '^usage' ?

Seems correct. I will try it.

Thanks!

Eriberto

mokraemer commented 5 years ago

I have the same problem, first line is broken! Setting TERM does not change anything.

prigaux commented 5 years ago

It looks like a broken terminal. Once again I need more info to diagnose!

mokraemer commented 5 years ago

what do you need for diagnosis? I can confirm, setting TERM=linux hexedit SOURCES/hexedit-1.4.2.tar.gz works. With TERM=xterm it does not.

prigaux commented 5 years ago

Which terminal are you using? No issue with

mokraemer commented 5 years ago

I'm using Mageia 6 with LXDE Desktop

nope, the output does not depend on the size of the terminal. Just the first row, the hex adress 0 is just printed as 0 not as "00000000". I'm confused this depends on the terminal set.

eribertomota commented 5 years ago

Using TERM=xterm or TERM=linux, is not possible save or use F1.

malaterre commented 4 years ago

I can reproduce it over here using Ubuntu 19.04. My ssh session reports:

$ echo $TERM
xterm-256color

And editing the output of date gives ($ date > d):

$ hexedit d

0   57 65 64 20  41 70 72 20  20 31 20 30  38 3A 31 32  3A 35 31 20  43 45 53 54  20 32 30 32  30 0A                                                      Wed Apr  1 08:12:51 CEST 2020.
0000002C

I would expect something like:

00000000   57 65 64 20  41 70 72 20  20 31 20 30  38 3A 31 34  3A 35 34 20  43 45 53 54  20 32 30 32  30 0A                                               Wed Apr  1 08:14:54 CEST 2020.
0000002C
malaterre commented 4 years ago

Here is the output of:

$ TERM=xterm-256color hexedit d $ TERM=xterm-16color hexedit d $ TERM=xterm hexedit d

they all give:

0   57 65 64 20  41 70 72 20  20 31 20 30  38 3A 31 32  3A 35 31 20  43 45 53 54  20 32 30 32  30 0A                                                      Wed Apr  1 08:12:51 CEST 2020.
0000002C

while

$ TERM=xterm-color hexedit d gives:

00000000   57 65 64 20  41 70 72 20  20 31 20 30  38 3A 31 32  3A 35 31 20  43 45 53 54  20 32 30 32  30 0A                                               Wed Apr  1 08:12:51 CEST 2020.
0000002C

And for reference:

$ infocmp xterm xterm-color 
comparing xterm to xterm-color.
    comparing booleans.
    bce: T:F.
    mc5i: T:F.
    npc: T:F.
    comparing numbers.
    comparing strings.
    blink: '\E[5m', NULL.
    cbt: '\E[Z', NULL.
    civis: '\E[?25l', NULL.
    cnorm: '\E[?12l\E[?25h', NULL.
    cvvis: '\E[?12;25h', NULL.
    dim: '\E[2m', NULL.
    ech: '\E[%p1%dX', NULL.
    el1: '\E[1K', NULL.
    enacs: NULL, '\E)0'.
    flash: '\E[?5h$<100/>\E[?5l', NULL.
    hpa: '\E[%i%p1%dG', NULL.
    ich: '\E[%p1%d@', NULL.
    indn: '\E[%p1%dS', NULL.
    invis: '\E[8m', NULL.
    is2: '\E[!p\E[?3;4l\E[4l\E>', '\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8'.
    kDC: '\E[3;2~', NULL.
    kEND: '\E[1;2F', NULL.
    kHOM: '\E[1;2H', NULL.
    kIC: '\E[2;2~', NULL.
    kLFT: '\E[1;2D', NULL.
    kNXT: '\E[6;2~', NULL.
    kPRV: '\E[5;2~', NULL.
    kRIT: '\E[1;2C', NULL.
    kb2: '\EOE', NULL.
    kcbt: '\E[Z', NULL.
    kend: '\EOF', NULL.
    kent: '\EOM', NULL.
    kf1: '\EOP', '\E[11~'.
    kf13: '\E[1;2P', '\E[25~'.
    kf14: '\E[1;2Q', '\E[26~'.
    kf15: '\E[1;2R', '\E[28~'.
    kf16: '\E[1;2S', '\E[29~'.
    kf17: '\E[15;2~', '\E[31~'.
    kf18: '\E[17;2~', '\E[32~'.
    kf19: '\E[18;2~', '\E[33~'.
    kf2: '\EOQ', '\E[12~'.
    kf20: '\E[19;2~', '\E[34~'.
    kf21: '\E[20;2~', NULL.
    kf22: '\E[21;2~', NULL.
    kf23: '\E[23;2~', NULL.
    kf24: '\E[24;2~', NULL.
    kf25: '\E[1;5P', NULL.
    kf26: '\E[1;5Q', NULL.
    kf27: '\E[1;5R', NULL.
    kf28: '\E[1;5S', NULL.
    kf29: '\E[15;5~', NULL.
    kf3: '\EOR', '\E[13~'.
    kf30: '\E[17;5~', NULL.
    kf31: '\E[18;5~', NULL.
    kf32: '\E[19;5~', NULL.
    kf33: '\E[20;5~', NULL.
    kf34: '\E[21;5~', NULL.
    kf35: '\E[23;5~', NULL.
    kf36: '\E[24;5~', NULL.
    kf37: '\E[1;6P', NULL.
    kf38: '\E[1;6Q', NULL.
    kf39: '\E[1;6R', NULL.
    kf4: '\EOS', '\E[14~'.
    kf40: '\E[1;6S', NULL.
    kf41: '\E[15;6~', NULL.
    kf42: '\E[17;6~', NULL.
    kf43: '\E[18;6~', NULL.
    kf44: '\E[19;6~', NULL.
    kf45: '\E[20;6~', NULL.
    kf46: '\E[21;6~', NULL.
    kf47: '\E[23;6~', NULL.
    kf48: '\E[24;6~', NULL.
    kf49: '\E[1;3P', NULL.
    kf50: '\E[1;3Q', NULL.
    kf51: '\E[1;3R', NULL.
    kf52: '\E[1;3S', NULL.
    kf53: '\E[15;3~', NULL.
    kf54: '\E[17;3~', NULL.
    kf55: '\E[18;3~', NULL.
    kf56: '\E[19;3~', NULL.
    kf57: '\E[20;3~', NULL.
    kf58: '\E[21;3~', NULL.
    kf59: '\E[23;3~', NULL.
    kf60: '\E[24;3~', NULL.
    kf61: '\E[1;4P', NULL.
    kf62: '\E[1;4Q', NULL.
    kf63: '\E[1;4R', NULL.
    kfnd: NULL, '\E[1~'.
    khome: '\EOH', NULL.
    kind: '\E[1;2B', NULL.
    kri: '\E[1;2A', NULL.
    kslt: NULL, '\E[4~'.
    mc0: '\E[i', NULL.
    mc4: '\E[4i', NULL.
    mc5: '\E[5i', NULL.
    op: '\E[39;49m', '\E[m'.
    rep: '%p1%c\E[%p2%{1}%-%db', NULL.
    rin: '\E[%p1%dT', NULL.
    ritm: '\E[23m', NULL.
    rmacs: '\E(B', '^O'.
    rmam: '\E[?7l', NULL.
    rmcup: '\E[?1049l\E[23;0;0t', '\E[2J\E[?47l\E8'.
    rmm: '\E[?1034l', NULL.
    rmso: '\E[27m', '\E[m'.
    rmul: '\E[24m', '\E[m'.
    rs1: '\Ec', NULL.
    rs2: '\E[!p\E[?3;4l\E[4l\E>', '\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8'.
    setb: '\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m', NULL.
    setf: '\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m', NULL.
    sgr: '%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m', NULL.
    sgr0: '\E(B\E[m', '\E[m'.
    sitm: '\E[3m', NULL.
    smacs: '\E(0', '^N'.
    smam: '\E[?7h', NULL.
    smcup: '\E[?1049h\E[22;0;0t', '\E7\E[?47h'.
    smm: '\E[?1034h', NULL.
    u8: '\E[?%[;0123456789]c', '\E[?1;2c'.
    vpa: '\E[%i%p1%dd', NULL.
malaterre commented 4 years ago

Just for reference comparing the output of teseq of script(s) output may give a hint:

@@ -41,25 +45,36 @@
 : Esc [ H
 & CUP: CURSOR POSITION
 " Move the cursor to line 1, column 1.
-: Esc [ J
+: Esc [ 2 J
 & ED: ERASE IN PAGE
-" Clear from the cursor to the end of the screen.
-|00000000   57 65 64 20  41 70 72 20  20 31 20 30  38 3A 35 39  3A 33 35 20 |-
--| 43 45 53 54  20 32 30 32  30 0A|
+" Clear the screen.
+: Esc [ ? 1 h
+& SM: SET MODE (private params)
+" (DEC) Cursor key mode.
+: Esc =
+& DECKPAM: KEYPAD APPLICATION MODE
+|0|
+: Esc [ 7 b
+& REP: REPEAT
+|   57 65 64 20  41 70 72 20  20 31 20 30  38 3A 35 39  3A 33 35 20  43 45 5|-
+-|3 54  20 32 30 32  30 0A|
eribertomota commented 4 years ago

This issue and others are open since some years ago. Is time for external help? Maybe a call for help in README.md file can help this nice project.

prigaux commented 4 years ago

I finally reproduced this issue through ssh on ubuntu 18.

I was able to reproduce using a minimal prog:

#include <curses.h>
int main() {
  initscr(); noecho(); printw("0000000"); getch();
}

IMO this need to be fixed elsewhere!

mokraemer commented 4 years ago

strangely I'm not able to reproduce this anymore (hexedit-1.4.2), maybe because of my desktop switch from lxde to lxqt... My TERM is xterm-256color and the output of hexedit is "000000" again...

malaterre commented 4 years ago

@mokraemer Can you try again but do ssh localhost first ?

mokraemer commented 4 years ago

it works with ssh too

malaterre commented 4 years ago

@pixel This is driving me nuts. When I compile it as static:

$ gcc -o t t.c /lib/x86_64-linux-gnu/libncurses.a /lib/x86_64-linux-gnu/libtinfo.a

I can reproduce it on my Ubuntu 19.04 system, if I scp the executable onto my local fedora system I can no longer reproduce it.

malaterre commented 4 years ago

@pixel I found the issue. When comparing the output of teseq I noticed this:

& ED: ERASE IN PAGE
" Clear the screen.
|0|
: Esc [ 6 b
& REP: REPEAT
: Esc [ 46 ; 1 H
& CUP: CURSOR POSITION

while in the original one I only see:

& ED: ERASE IN PAGE
" Clear the screen.
|0000000|
: Esc [ 46 ; 1 H
& CUP: CURSOR POSITION

Doing a goodl search on 'REPEAT' eventually lead to:

prigaux commented 4 years ago

Great.

Conclusion: some "TERM" from recent terminfo breaks on old terminal applications.

malaterre commented 4 years ago

just for later reference. Bug has been fixed in all Debian system:

But not on Ubuntu, so a user has to do:

$ infocmp xterm-256color | sed -e 's/rep=[^,]*, //' | tic -

Now you should have

$ infocmp -x xterm-256color | head -n1
#   Reconstructed via infocmp from file: /home/malat/.terminfo/x/xterm-256color