mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Fixed segfault with fish operations
Reason: If some directory in fish is a read-only, then mc will crashed Issue: In fish_mkdir added additional check if directory was created. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
9ee5f318ab
commit
33c0d6f022
35
vfs/fish.c
35
vfs/fish.c
@ -1045,8 +1045,31 @@ static int fish_unlink (struct vfs_class *me, const char *path)
|
||||
POSTFIX(OPT_FLUSH);
|
||||
}
|
||||
|
||||
static int fish_exists (struct vfs_class *me, const char *path)
|
||||
{
|
||||
int ret_code;
|
||||
|
||||
PREFIX
|
||||
|
||||
g_snprintf(buf, sizeof(buf),
|
||||
"#ISEXISTS \"/%s\"\n"
|
||||
"ls -l \"/%s\" >/dev/null 2>/dev/null\n"
|
||||
"echo '### '$?\n",
|
||||
rpath, rpath);
|
||||
|
||||
g_free (rpath);
|
||||
|
||||
if ( fish_send_command(me, super, buf, OPT_FLUSH) == 0 )
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int fish_mkdir (struct vfs_class *me, const char *path, mode_t mode)
|
||||
{
|
||||
int ret_code;
|
||||
|
||||
PREFIX
|
||||
|
||||
(void) mode;
|
||||
@ -1056,7 +1079,17 @@ static int fish_mkdir (struct vfs_class *me, const char *path, mode_t mode)
|
||||
"mkdir /%s 2>/dev/null\n"
|
||||
"echo '### 000'\n",
|
||||
rpath, rpath);
|
||||
POSTFIX(OPT_FLUSH);
|
||||
|
||||
g_free (rpath);
|
||||
ret_code = fish_send_command(me, super, buf, OPT_FLUSH);
|
||||
|
||||
if ( ret_code != 0 )
|
||||
return ret_code;
|
||||
|
||||
if ( ! fish_exists (me, path) ){
|
||||
ERRNOR (EACCES, -1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fish_rmdir (struct vfs_class *me, const char *path)
|
||||
|
@ -564,6 +564,10 @@ int mc_##name inarg \
|
||||
char *mpath = vfs_canon_and_translate (path); \
|
||||
if (mpath != NULL) { \
|
||||
vfs = vfs_get_class (mpath); \
|
||||
if (vfs == NULL){ \
|
||||
g_free (mpath); \
|
||||
return -1; \
|
||||
} \
|
||||
result = vfs->name ? (*vfs->name)callarg : -1; \
|
||||
g_free (mpath); \
|
||||
if (result == -1) \
|
||||
@ -618,6 +622,8 @@ ssize_t mc_##name inarg \
|
||||
if (handle == -1) \
|
||||
return -1; \
|
||||
vfs = vfs_op (handle); \
|
||||
if (vfs == NULL) \
|
||||
return -1; \
|
||||
result = vfs->name ? (*vfs->name)callarg : -1; \
|
||||
if (result == -1) \
|
||||
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
||||
|
Loading…
Reference in New Issue
Block a user