Changeset 2237 in MondoRescue


Ignore:
Timestamp:
Jun 19, 2009, 9:10:17 PM (15 years ago)
Author:
Bruno Cornec
Message:

Fix a bug (seg fault) when a too large mountlist was used. Increased MAXIMUM_DISKS_PER_RAID_DEV which serve as table allocation for drivelist, which should be as big as mountlist in fact ! (which it is still not, but is now sufficently large to be correct). Again dynamic memory allocation is the solution. Or perl ;-)

Location:
branches/2.2.9/mondo/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/libmondo-mountlist.c

    r2236 r2237  
    678678        log_msg(8, "Putting %s with size %lli in list of drives", drive, size);
    679679
     680        /* memory allocation */
    680681        truncdrive = truncate_to_drive_name(drive);
     682        paranoid_free(drive);
     683
    681684        log_msg(8, "drive truncated to %s", truncdrive);
    682685
     
    687690        }
    688691        if (j == noof_drives) {
    689             strncpy(drivelist->el[noof_drives].device, drive, 63);
     692            strncpy(drivelist->el[noof_drives].device, truncdrive, 63);
    690693            drivelist->el[noof_drives].device[63] = '\0';
    691694            log_msg(8,"Adding drive %s to list", drivelist->el[noof_drives].device);
    692695            noof_drives++;
    693696        }
    694         paranoid_free(drive);
    695697        paranoid_free(truncdrive);
     698        if (noof_drives >= MAXIMUM_DISKS_PER_RAID_DEV) {
     699            log_msg(0, "Unable to handle mountlist with more than %d lines", MAXIMUM_DISKS_PER_RAID_DEV);
     700            log_to_screen("Unable to handle a so big mountlist");
     701            finish(1);
     702        }
    696703    }
    697704    drivelist->entries = noof_drives;
  • branches/2.2.9/mondo/src/common/libmondo-string.c

    r2230 r2237  
    843843    char *trunc = NULL;
    844844
     845    assert_string_is_neither_NULL_nor_zerolength(partition);
    845846    mr_asprintf(&trunc, "%s", partition);
    846847
     
    858859#else
    859860
    860     assert_string_is_neither_NULL_nor_zerolength(partition);
    861861    /* first see if it's a devfs style device */
    862862    c = strrchr(trunc, '/');
  • branches/2.2.9/mondo/src/include/my-stuff.h

    r2227 r2237  
    124124#define MAXIMUM_RAID_DEVS 32    ///< The maximum number of RAID devices in the raidlist.
    125125#define MAXIMUM_ADDITIONAL_RAID_VARS 32 ///< The maximum number of additional RAID variables per RAID device in the raidlist.
    126 #define MAXIMUM_DISKS_PER_RAID_DEV 32   ///< The maximum number of disks per RAID device in the raidtab.
     126#define MAXIMUM_DISKS_PER_RAID_DEV 1024 ///< The maximum number of disks per RAID device in the raidtab.
    127127
    128128#define RAIDTAB_FNAME "/etc/raidtab"    ///< The filename of the raidtab file, at least on Linux.
Note: See TracChangeset for help on using the changeset viewer.