* extfs.c (extfs_init): Fix possible off-by-one buffer underflow
for empty lines in extfs.ini.
Этот коммит содержится в:
родитель
622e6a368e
Коммит
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>
|
2004-06-14 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* tar.c: Eliminate struct hstat, use stack arguments instead.
|
* tar.c: Eliminate struct hstat, use stack arguments instead.
|
||||||
@ -67,7 +72,7 @@
|
|||||||
|
|
||||||
2003-11-14 Andrew V. Samoilov <sav@bcs.zp.ua>
|
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
|
since we want to recover and not abort the program if we don't
|
||||||
have enough memory.
|
have enough memory.
|
||||||
(com_err): Fix implementation.
|
(com_err): Fix implementation.
|
||||||
|
19
vfs/extfs.c
19
vfs/extfs.c
@ -1249,6 +1249,7 @@ static int extfs_init (struct vfs_class *me)
|
|||||||
{
|
{
|
||||||
FILE *cfg;
|
FILE *cfg;
|
||||||
char *mc_extfsini;
|
char *mc_extfsini;
|
||||||
|
char key[256];
|
||||||
|
|
||||||
mc_extfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "extfs.ini");
|
mc_extfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "extfs.ini");
|
||||||
cfg = fopen (mc_extfsini, "r");
|
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
|
* UI is not initialized at this time and message would not
|
||||||
* appear on screen. */
|
* appear on screen. */
|
||||||
if (!cfg) {
|
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);
|
g_free (mc_extfsini);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extfs_no = 0;
|
extfs_no = 0;
|
||||||
while ( extfs_no < MAXEXTFS ) {
|
while (extfs_no < MAXEXTFS && fgets (key, sizeof (key), cfg)) {
|
||||||
char key[256];
|
|
||||||
char *c;
|
char *c;
|
||||||
|
|
||||||
if (!fgets( key, sizeof (key)-1, cfg ))
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Handle those with a trailing ':', those flag that the
|
/* Handle those with a trailing ':', those flag that the
|
||||||
* file system does not require an archive to work
|
* file system does not require an archive to work
|
||||||
*/
|
*/
|
||||||
@ -1281,14 +1278,13 @@ static int extfs_init (struct vfs_class *me)
|
|||||||
g_free (mc_extfsini);
|
g_free (mc_extfsini);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (*key == '#')
|
if (*key == '#' || *key == '\n')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((c = strchr (key, '\n'))){
|
if ((c = strchr (key, '\n'))){
|
||||||
*c = 0;
|
*c-- = 0;
|
||||||
|
} else { /* Last line without newline or strlen (key) > 255 */
|
||||||
c = &key [strlen (key) - 1];
|
c = &key [strlen (key) - 1];
|
||||||
} else {
|
|
||||||
c = key;
|
|
||||||
}
|
}
|
||||||
extfs_need_archive [extfs_no] = !(*c == ':');
|
extfs_need_archive [extfs_no] = !(*c == ':');
|
||||||
if (*c == ':')
|
if (*c == ':')
|
||||||
@ -1296,8 +1292,7 @@ static int extfs_init (struct vfs_class *me)
|
|||||||
if (!(*key))
|
if (!(*key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
extfs_prefixes [extfs_no] = g_strdup (key);
|
extfs_prefixes [extfs_no++] = g_strdup (key);
|
||||||
extfs_no++;
|
|
||||||
}
|
}
|
||||||
fclose(cfg);
|
fclose(cfg);
|
||||||
g_free (mc_extfsini);
|
g_free (mc_extfsini);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user