mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
* extfs.c (extfs_init): Fix possible off-by-one buffer underflow
for empty lines in extfs.ini.
This commit is contained in:
parent
622e6a368e
commit
5b290ada65
@ -1,3 +1,8 @@
|
||||
2004-08-14 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||
|
||||
* extfs.c (extfs_init): Fix possible off-by-one buffer underflow
|
||||
for empty lines in extfs.ini.
|
||||
|
||||
2004-06-14 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* tar.c: Eliminate struct hstat, use stack arguments instead.
|
||||
@ -67,7 +72,7 @@
|
||||
|
||||
2003-11-14 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||
|
||||
* undelfs.c (undelfs_loaddel): Use g_try_malloc()/g_try_relloc()
|
||||
* undelfs.c (undelfs_loaddel): Use g_try_malloc()/g_try_realloc()
|
||||
since we want to recover and not abort the program if we don't
|
||||
have enough memory.
|
||||
(com_err): Fix implementation.
|
||||
|
21
vfs/extfs.c
21
vfs/extfs.c
@ -1249,6 +1249,7 @@ static int extfs_init (struct vfs_class *me)
|
||||
{
|
||||
FILE *cfg;
|
||||
char *mc_extfsini;
|
||||
char key[256];
|
||||
|
||||
mc_extfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "extfs.ini");
|
||||
cfg = fopen (mc_extfsini, "r");
|
||||
@ -1257,19 +1258,15 @@ static int extfs_init (struct vfs_class *me)
|
||||
* UI is not initialized at this time and message would not
|
||||
* appear on screen. */
|
||||
if (!cfg) {
|
||||
fprintf(stderr, _("Warning: file %s not found\n"), mc_extfsini);
|
||||
fprintf (stderr, _("Warning: file %s not found\n"), mc_extfsini);
|
||||
g_free (mc_extfsini);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extfs_no = 0;
|
||||
while ( extfs_no < MAXEXTFS ) {
|
||||
char key[256];
|
||||
while (extfs_no < MAXEXTFS && fgets (key, sizeof (key), cfg)) {
|
||||
char *c;
|
||||
|
||||
if (!fgets( key, sizeof (key)-1, cfg ))
|
||||
break;
|
||||
|
||||
/* Handle those with a trailing ':', those flag that the
|
||||
* file system does not require an archive to work
|
||||
*/
|
||||
@ -1281,23 +1278,21 @@ static int extfs_init (struct vfs_class *me)
|
||||
g_free (mc_extfsini);
|
||||
return 0;
|
||||
}
|
||||
if (*key == '#')
|
||||
if (*key == '#' || *key == '\n')
|
||||
continue;
|
||||
|
||||
if ((c = strchr (key, '\n'))){
|
||||
*c = 0;
|
||||
*c-- = 0;
|
||||
} else { /* Last line without newline or strlen (key) > 255 */
|
||||
c = &key [strlen (key) - 1];
|
||||
} else {
|
||||
c = key;
|
||||
}
|
||||
extfs_need_archive [extfs_no] = !(*c == ':');
|
||||
if (*c == ':')
|
||||
*c = 0;
|
||||
*c = 0;
|
||||
if (!(*key))
|
||||
continue;
|
||||
|
||||
extfs_prefixes [extfs_no] = g_strdup (key);
|
||||
extfs_no++;
|
||||
extfs_prefixes [extfs_no++] = g_strdup (key);
|
||||
}
|
||||
fclose(cfg);
|
||||
g_free (mc_extfsini);
|
||||
|
Loading…
Reference in New Issue
Block a user