The mc's built-in samba library which is used to access data across
smb links is taken from an old samba version.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Fix out-of-boundary access to gname if it's shorter than 255 bytes.
Found by Coverity.
Coverity id #331844.
Fix macro name that is used for array size.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Fix out-of-boundary access to uname if it's shorter than 255 bytes.
Found by Coverity.
Coverity id #331835.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Add two widget callbacks:
* (make_global): convert widget coordinates from local (relative to
owner) to global (screen).
* (make_local): convert widget coordinates from global (screen) to
local (relative to owner).
Such conversions are required when nested widgets and groups are added to
or removed from another groups.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
lib/widget/group.c: fix -Wcast-qual warnings:
group.c:199:21: warning: cast from 'const struct Widget *' to 'struct WGroup *' drops const qualifier [-Wcast-qual]
for (iter = GROUP (w)->widgets; iter != NULL; iter = g_list_next (iter))
^
../../lib/widget/group.h:16:29: note: expanded from macro 'GROUP'
^
group.c:231:21: warning: cast from 'const struct Widget *' to 'struct WGroup *' drops const qualifier [-Wcast-qual]
for (iter = GROUP (w)->widgets; iter != NULL; iter = g_list_next (iter))
^
../../lib/widget/group.h:16:29: note: expanded from macro 'GROUP'
^
group.c:263:21: warning: cast from 'const struct Widget *' to 'struct WGroup *' drops const qualifier [-Wcast-qual]
for (iter = GROUP (w)->widgets; iter != NULL; iter = g_list_next (iter))
^
../../lib/widget/group.h:16:29: note: expanded from macro 'GROUP'
^
Found by Clang-11.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
foot is a "fast, lightweight and minimalistic Wayland terminal emulator"
(see https://codeberg.org/dnkl/foot). Add its default TERM value to the
recognized ones. This enables mc to change the terminal window title and
handle mouse events.
(tty_check_term): add support of foot terminal emulator as xterm-compatible.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Alacritty is a "fast, cross-platform, OpenGL terminal emulator" (see
https://github.com/alacritty/alacritty). Add its default TERM value to
the recognized ones. This enables mc to change window title and handle
mouse events.
(tty_check_term): add support of alacritty terminal as xterm-compatible.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The build system runs configure script after switching to another branch
or changeset, which basically means that each git operation which
modifies HEAD will cause a full rebuild. This is highly annoying, in
particular during bisecting.
Solution:
Don't define version in config.h.
Add mc_version member to mc_global_t structure and use it instead of
VERSION macro.
Now only lib/global.c depends on MC version.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(mc_search__g_regex_match_full_safe): fix out of bound read:
g_utf8_get_char_validated() expects a nul-terminated string.
Test case: search for "test" in
https://mirrors.edge.kernel.org/pub/linux/kernel/firmware/linux-firmware-20201218.tar.xz
Found by clang-11
==10142==ERROR: AddressSanitizer: SEGV on unknown address 0x60c001e00000 (pc 0x7ffb352111c0 bp 0x7ffcb5745150 sp 0x7ffcb57450e8 T0)
==10142==The signal is caused by a READ memory access.
#0 0x7ffb352111c0 in g_utf8_get_char_validated (/usr/lib64/libglib-2.0.so.0+0x811c0)
#1 0x851e6d in mc_search__g_regex_match_full_safe /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/search/regex.c:297:22
#2 0x851824 in mc_search__regex_found_cond_one /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/search/regex.c:328:10
#3 0x84b955 in mc_search__regex_found_cond /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/search/regex.c:377:13
#4 0x84aa07 in mc_search__run_regex /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/search/regex.c:955:17
#5 0x848969 in mc_search__run_normal /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/search/normal.c:104:12
#6 0x77270c in mc_search_run /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/search/search.c:308:15
#7 0x514fd9 in search_content /tmp/portage/app-misc/mc-9999/work/mc-9999/src/filemanager/find.c:1123:20
#8 0x511917 in do_search /tmp/portage/app-misc/mc-9999/work/mc-9999/src/filemanager/find.c:1405:26
#9 0x512028 in find_callback /tmp/portage/app-misc/mc-9999/work/mc-9999/src/filemanager/find.c:1597:9
#10 0x7e285f in send_message /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/../../lib/widget/widget-common.h:243:15
#11 0x7e36d8 in frontend_dlg_run /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/dialog.c:307:17
#12 0x7e34c5 in dlg_run /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/dialog.c:583:5
#13 0x510aa1 in run_process /tmp/portage/app-misc/mc-9999/work/mc-9999/src/filemanager/find.c:1755:11
#14 0x50c29e in do_find /tmp/portage/app-misc/mc-9999/work/mc-9999/src/filemanager/find.c:1789:20
#15 0x5098e7 in find_cmd /tmp/portage/app-misc/mc-9999/work/mc-9999/src/filemanager/find.c:1917:17
#16 0x504735 in midnight_execute_cmd /tmp/portage/app-misc/mc-9999/work/mc-9999/src/filemanager/filemanager.c:1251:9
#17 0x502e00 in midnight_callback /tmp/portage/app-misc/mc-9999/work/mc-9999/src/filemanager/filemanager.c:1604:21
#18 0x7eaa5c in send_message /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/../../lib/widget/widget-common.h:243:15
#19 0x7e7ae9 in group_handle_key /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/group.c:442:19
#20 0x7e6a4f in group_default_callback /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/group.c:567:16
#21 0x7e31bf in dlg_key_event /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/dialog.c:251:19
#22 0x7e2c12 in dlg_process_event /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/dialog.c:549:9
#23 0x7e3746 in frontend_dlg_run /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/dialog.c:320:9
#24 0x7e34c5 in dlg_run /tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/dialog.c:583:5
#25 0x502866 in do_nc /tmp/portage/app-misc/mc-9999/work/mc-9999/src/filemanager/filemanager.c:1838:16
#26 0x4ceb15 in main /tmp/portage/app-misc/mc-9999/work/mc-9999/src/main.c:455:21
#27 0x7ffb34f16b49 in __libc_start_main (/lib64/libc.so.6+0x23b49)
#28 0x4230f9 in _start (/tmp/portage/app-misc/mc-9999/work/mc-9999/src/mc+0x4230f9)
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...to free or not to free the string representation
of vfs_path_t object.
It allows to get rid of string duplication in following cases:
vfs_path_t *vpath;
char *path;
...
vpath = vfs_path_from_str (...);
path = g_strdup (vfs_path_as_str (vpath));
vfs_path_free (vpath);
Now we can write:
vfs_path_t *vpath;
char *path;
...
vpath = vfs_path_from_str (...);
path = vfs_path_free (vpath, FALSE);
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(group_default_callback): NULLify list of widgets after destroy.
(dlg_default_callback): do nothing in MSG_INIT and MSG_DESTROY handlers.
(dlg_destroy): send MSG_DESTORY to dialog to allow it destroy it's
private data. MSG_DESTROY is a last message sent to dialog before
desctuction.
(edit_dialog_callback): use MSG_DESTROY instead of MSG_END to deinit
editor.
(midnight_callback): use MSG_DESTROY instead of MSG_DESTORY to deinit
file manager.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Custom .zshrc file is ~/.local/share/mc/.zshrc.
If ZDOTDIR environment variable is not set, set it to ~/.local/share/mc
if a .zshrc is found there. It is the only way to point zsh to an other
rc file than the default.
Thanks Sebastian Gniazdowski <sgniazdowski@gmail.com> for the original
patch.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...because the pointer can't be NULL.
Found by Coverity.
Coverity id #110817.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Save file handle for later close, if valid.
Found by Coverity.
Coverity id #32607.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
In the function vfs_expire(), curr_time and exp_time are declared
guint64. curr_time is initialised with a timestamp and exp_time
with this timestamp minus vfs_timeout seconds. Later there is if
(stamping->time <= exp_time). Prior to commit
a94dd7d2de curr_time was initialised with
a value larger than vfs_timeout seconds, so everything was fine. This
commit changed the initialisation to a timer starting when mc is
started. So for the first vfs_timeout seconds, the result of the
subtraction is negative, but it is a guint64, so we just get a VERY
large unsigned value and the if (stamping->time <= exp_time) is always
true. So mc thinks the vfs hasn't been used recently and goes into an
infinite loop.
If one opens a .rpm file with mc and goes into the CONTENTS.cpio and
then tries to go into the .tar.gz there (this is the usual structure of
a .rpm) after waiting vfs_timeout seconds, everything is fine. However,
before vfs_timeout seconds, mc hangs.
Solution: use g_get_real_time() instead of mc_timer_elapsed().
Thanks nvwarr at hotmail.com for finding out the reason for this bug.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Avoid limitation of file name length.
(vfs_dirent): redefined to use instead of standard "struct direct"
to hold file name of any length.
(vfs_class::readdir): return newly allocated vfs_dirent structure.
Related changes.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This bug was introduced in 2e734e5618.
(dlg_handle_key): fallback to dialog_map if shortcut is not defined in
filemanager/editor/viewer/diffviewer key map.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
In Solaris 11.4 SPARC, TIOCSWINSZ is defined in termios.h.
lib/tty/tty.c: add #include <termios.h>, because TIOCSWINSZ is used in
tty_resize().
Thanks Alexander <shurik005@gmail.com> for the fix.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (complete): rename to input_complete() and move declaration to
input.h.
* input_complete.h: remove.
* (input_free_completions): rename to input_complete_free() and move
definition to input_complete.c.
* lib/widget/input_complete.c: rename variables and function from
query_* to complete_*.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
How to reproduce:
Run `mcedit .` from an empty shell. mc used to show an error banner. Now
it shows black-on-black error message.
do_refresh() function expects that at least one fullscreen dialog (file
manager, editor, etc) is existing in the dialog stack. If query dialog
is created before any fullscreen one, do_refresh() do nothing.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (widget_destroy): new API to destroy widget.
* (group_del_widget): rename to group_remove_widget. Don't destroy
widget after remove it from group.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
WGroup is the base widget for complex objects such as windows, dialog
windows, etc.
Initial steps:
* move widget list of dialog into WGroup class;
* inherit WGroup from Widget;
* inherit WDialog from WGroup.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(do_show_hist): apply new input history and current postition to avoid
use-after-free after call of history_show().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Don't show message "GNU Midnight Commander is already running on this
terminal. Subshell support will be disabled." if standalone
mcedit/mcview/mcdiffview is run from mc. Show this message only in case
of mc run from another mc, as was before commit
41abcbf706 (ticket #3380).
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (widget_destroy): new API to destroy widget.
* (del_widget): don't destroy widget after remove it from dialog.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Each VSF entry is added to VFS using vfs_s_insert_entry() via
g_list_append(). For long lists, a lot of walking through entire list
is performed. To get rid that, change type of vfs_s_inode::subdir from
GList to GQueue.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Fix regression introduced in 37ffc02422.
(tty_got_winch): don't read FIFO, just check whether it os empty or not.
It can be called many times without lost of info about SIGWINCH raises.
(tty_flush_winch): read from FIFO to make it empty.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Bundled libintl did not support linking to internal static
libraries (libmc in our case): directly specified static
libraries are not pulled by libtool and are not usable for
dynamic libraries as PIC-related flags are not passed for
compilation.
This renders bundled libintl library unusable.
The change drops libintl bundling support and always relies
on external libintl (or falls back to disabled NLS).
On a related note gettext-0.20 drops support for bundling
or libintl and this change will ease migration to newer version.
The change is tested on x86_64-gentoo-linux-musl: mc builds
and links all tests successfully. A few tests fail for lack
of NLS support.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
In the menu bar, click on the space character immediately before the
"File" label.
Actual: The "Left" menu opens.
Expected: The "File" menu should open, since when clicking on "File",
this space character on its left is also highlighted.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
S_Lang: pre2.3.3-8 (55f58798c267d76a1b93d0d916027b71a10ac1ee): removed
static buffers dependent upon SLTT_MAX_SCREEN_ROWS/COLS in favor of
dynamically allocated arrays.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Use pipe to collect consecutive raised SIGWINCH events.
Then handle multiple events at a time treating them
as a single one.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Prepare to support CK_Delete in editor and viewer history.
The filepos file contains file positions and bookmarks. We must keep
them.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Based on patch by Filip Sefrna <fsefrna@gmail.com>
added action 'EditorHistory' for call history dialog.
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
* (vfs_s_opendir): test if path is invalid or not ASAP.
* (vfs_s_readlink): likewise.
* (vfs_s_open): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
How to reproduce the bug:
* compile mc with gpm support
* run the gpm daemon on the console
* login to the machine with ssh from console on another machine
* run mc
At this situation, keyboard response will be sluggish and mc will consume
CPU time when idle. The reason is that mc is trying to reopen the Gpm
connection over and over again and gpm will try to close the connection
over and over again (because the user is not on the local console).
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Widget list in the dialog cannot contain empty elements.
Dialog list cannot contain empty elements too.
Therefore simplify some checks.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
fsusage, mountlist: Remove support for Dynix/ptx.
* m4.include/gnulib/fsusage.m4 (gl_FILE_SYSTEM_USAGE): Update comments.
* m4.include/gnulib/ls-mntd-fs.m4 (AC_FUNC_GETMNTENT): Don't test for
libseq.
(gl_LIST_MOUNTED_FILE_SYSTEMS): Don't test for MNTTABNAME.
* lib/stat-size.h: Don't mention the Sequent bug.
* src/filemanager/mountlist.c: Don't test for MNTTABNAME. Remove
_SEQUENT_ case
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>