#993471 mc crashes if ftp server specified on cmdline requires authentication

Package:
mc
Source:
mc
Description:
Midnight Commander - a powerful file manager
Submitter:
Matija Nalis
Date:
2021-09-17 19:09:05 UTC
Severity:
normal
#993471#5
Date:
2021-09-01 19:07:37 UTC
From:
To:
Dear Maintainer,

Trying to specify FTP URL with username crashes mc if invoked from command line.
For example:

  mc /tmp ftp://someuser@192.168.43.1:2121/

mc would start to show the dialog to ask password, and then crash:
┌─────────────────────────── FTP: Password required for someuser ───────────────────────────┐
│ Password:                                                                                 │
│ zsh: segmentation fault  mc /tmp ftp://someuser@192.168.43.1:2121/                        │


   * What exactly did you do (or not do) that was effective (or
     ineffective)?

- When invoked via menus (eg. F9 / Right / FTP link / ftp://mnalis@192.168.43.1:2121/) it asks for password normally and connects.
- if anonymous FTP is attempted (which does not require inputting password) it works.
- if correct password is also specified on command line, it also works
- if incorrect password is specified on command line, it fails as it tries to re-ask the password
- Also, it worked in Buster version of mc just fine. After upgrade to Bullseye it crashes.

In short, it seems to crash only if URL which was specified IN COMMAND LINE requires some user input.

#993471#10
Date:
2021-09-17 19:04:16 UTC
From:
To:
Dear Maintainer,
I tried to have a look and received the backtrace below [3].

As far as I see is 4.8.27 in current testing not affected.

And a 'git bisect' led to the upstream commit [1], which
is tracked in upstream bug [2].
A package 4.8.26 built with this commit is also
working as expected (see attached patch).

Kind regards,
Bernhard



[1] https://github.com/MidnightCommander/mc/commit/0375997c789eef9b6355aadd80aaf4aced68c560

[2] https://midnight-commander.org/ticket/4244

[3]
Program terminated with signal SIGSEGV, Segmentation fault.
#0  widget_set_size (w=0x0, y=y@entry=59, x=<optimized out>, lines=lines@entry=1, cols=cols@entry=19) at widget-common.c:450
450         if (w->owner != NULL && widget_get_state (WIDGET (w->owner), WST_ACTIVE))
(gdb) set width 0
(gdb) set pagination off
(gdb) bt
#0  widget_set_size (w=0x0, y=y@entry=59, x=<optimized out>, lines=lines@entry=1, cols=cols@entry=19) at widget-common.c:450
#1  0x000055d9c539ae14 in setup_cmdline () at layout.c:999
#2  0x000055d9c53f54d0 in set_prompt_string () at common.c:728
#3  set_prompt_string () at common.c:720
#4  read_subshell_prompt () at common.c:1575
#5  0x000055d9c539be56 in do_load_prompt () at layout.c:1473
#6  0x000055d9c539bee6 in load_prompt (fd=<optimized out>, unused=<optimized out>) at layout.c:1502
#7  0x000055d9c5397a4a in check_selects (select_set=select_set@entry=0x7ffe62e65cd0) at key.c:618
#8  0x000055d9c53998e1 in tty_get_event (event=event@entry=0x7ffe62e65da0, redo_event=0, block=block@entry=1) at key.c:2055
#9  0x000055d9c5380d01 in frontend_dlg_run (h=0x55d9c66744c0) at dialog.c:318
#10 dlg_run (h=h@entry=0x55d9c66744c0) at dialog.c:575
#11 0x000055d9c53ad165 in quick_dialog_skip (quick_dlg=quick_dlg@entry=0x7ffe62e65ed0, nskip=<optimized out>, nskip@entry=1) at quick.c:581
#12 0x000055d9c53c01c6 in quick_dialog (quick_dlg=0x7ffe62e65ed0) at ../../lib/widget/quick.h:353
#13 fg_input_dialog_help (header=0x55d9c66732c0 "FTP: Passwort benötigt für ftpuser", text=<optimized out>, help=0x55d9c5428833 "[Input Line Keys]", history_name=<optimized out>, def_text=0x55d9c542e960 "", strip_password=0, completion_flags=INPUT_COMPLETE_NONE) at wtools.c:226
#14 0x000055d9c53c0eeb in input_dialog (header=header@entry=0x55d9c66732c0 "FTP: Passwort benötigt für ftpuser", text=<optimized out>, history_name=history_name@entry=0x55d9c542872a "mc.vfs.password", def_text=def_text@entry=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>, completion_flags=completion_flags@entry=INPUT_COMPLETE_NONE) at wtools.c:506
#15 0x000055d9c53be3f4 in vfs_get_password (msg=msg@entry=0x55d9c66732c0 "FTP: Passwort benötigt für ftpuser") at utilvfs.c:365
#16 0x000055d9c53c5d21 in ftpfs_login_server (me=me@entry=0x55d9c5479e60 <ftpfs_subclass>, super=super@entry=0x55d9c6673210, netrcpass=netrcpass@entry=0x0) at ftpfs.c:643
#17 0x000055d9c53c7bb8 in ftpfs_open_archive_int (super=0x55d9c6673210, me=0x55d9c5479e60 <ftpfs_subclass>) at ftpfs.c:973
#18 ftpfs_open_archive (super=0x55d9c6673210, vpath=<optimized out>, vpath_element=<optimized out>) at ftpfs.c:1028
#19 0x000055d9c53ccb1b in vfs_s_get_path (vpath=vpath@entry=0x55d9c6672f10, archive=archive@entry=0x7ffe62e66450, flags=flags@entry=0) at direntry.c:1207
#20 0x000055d9c53ccc29 in vfs_s_inode_from_path (vpath=vpath@entry=0x55d9c6672f10, flags=flags@entry=5) at direntry.c:398
#21 0x000055d9c53cce01 in vfs_s_opendir (vpath=0x55d9c6672f10) at direntry.c:426
#22 0x000055d9c53cce86 in vfs_s_chdir (vpath=<optimized out>) at direntry.c:496
#23 0x000055d9c5397167 in mc_chdir (vpath=vpath@entry=0x55d9c6672d20) at interface.c:678
#24 0x000055d9c5387f95 in create_panels () at filemanager.c:665
#25 create_file_manager () at filemanager.c:924
#26 do_nc () at filemanager.c:1836
#27 0x000055d9c53754d1 in main (argc=<optimized out>, argv=<optimized out>) at main.c:463