Changeset 2700 in MondoRescue


Ignore:
Timestamp:
Jan 27, 2011, 7:31:06 PM (13 years ago)
Author:
Bruno Cornec
Message:

r4176@localhost: bruno | 2011-01-26 18:11:02 +0100

  • Fix buffer overflow with long exclude lines where log between mindi and mondo were exceeding fixed string size used
Location:
branches/2.2.9
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi/analyze-my-lvm

    r2684 r2700  
    142142        list_of_devices=""
    143143        for i in $physical_volumes ; do
    144             fname=/proc/lvm/VGs/$current_VG/PVs/$i
    145             device=`GetValueFromField $fname "name:"`
    146             list_of_devices="$list_of_devices $device"
     144            fname=/proc/lvm/VGs/$current_VG/PVs/$i
     145            device=`GetValueFromField $fname "name:"`
     146            list_of_devices="$list_of_devices $device"
    147147        done
    148148        current_PVs=$list_of_devices
  • branches/2.2.9/mindi/mindi-bkphw

    r2695 r2700  
    5454        chomp($tool);
    5555        $tooldir = dirname($tool);
    56         if (! (-e $tool)) {
     56        if (! (-x $tool)) {
    5757            print "You should install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
    5858            print "Get it from http://www.hp.com/servers/sstoolkit\n";
     
    7373            print TOOLS "$tooldir/bld\n";
    7474        }
    75         if ($tool =~ /\/.hpacucli$/) {
     75        if ($tool =~ /\/hpacucli$/) {
    7676            my $dir=basename($tool);
    7777            $ret = system("export ACUXE_BIN_INSTALLATION_DIR=$dir ; export IM_CFGFILE_PATH=$dir ; export ACUXE_LOCK_FILES_DIR=$dir/locks ; $tool -c $bkpdir/hpacucli.dat");
  • branches/2.2.9/mondo/src/common/libmondo-fork.c

    r2656 r2700  
    379379
    380380    /*@ buffers **************************************************** */
    381     char tmp[MAX_STR_LEN * 2];
    382     char command[MAX_STR_LEN * 2];
     381    char *tmp = NULL;
     382    char *command = NULL;
    383383    char lockfile[MAX_STR_LEN];
    384384
     
    389389    sprintf(lockfile, "%s/mojo-jojo.bla.bla", bkpinfo->tmpdir);
    390390
    391     sprintf(command,
     391    mr_asprintf(&command,
    392392            "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res",
    393393            lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile);
    394394    open_evalcall_form(what_i_am_doing);
    395     sprintf(tmp, "Executing %s", basic_call);
     395    mr_asprintf(&tmp, "Executing %s", basic_call);
    396396    log_msg(2, tmp);
     397    mr_free(tmp);
     398
    397399    if (!(fin = popen(command, "r"))) {
    398400        log_OS_error("Unable to popen-in command");
    399         sprintf(tmp, "Failed utterly to call '%s'", command);
     401        mr_asprintf(&tmp, "Failed utterly to call '%s'", command);
    400402        log_to_screen(tmp);
     403        mr_free(tmp);
     404        mr_free(command);
    401405        return (1);
    402406    }
     
    407411        }
    408412    }
     413    mr_free(command);
    409414#ifdef _XWIN
    410415    /* This only can update when newline goes into the file,
     
    412417    while (does_file_exist(lockfile)) {
    413418        while (!feof(fin)) {
     419            /* TODO: Dead and wrong code */
    414420            if (!fgets(tmp, 512, fin))
    415421                break;
  • branches/2.2.9/mondo/src/common/newt-specific.c

    r2697 r2700  
    471471
    472472        /*@ buffers ********************************************************** */
    473         char *command;
    474         char *tmp;
     473        char *command = NULL;
     474        char *tmp = NULL;
    475475
    476476        /*@ pointers ********************************************************* */
     
    480480        int i = 0;
    481481
    482         malloc_string(command);
    483         malloc_string(tmp);
    484482        assert_string_is_neither_NULL_nor_zerolength(filename);
    485483        assert(grep_for_me != NULL);
    486484
    487485        if (!does_file_exist(filename)) {
    488             paranoid_free(command);
    489             paranoid_free(tmp);
    490486            return;
    491487        }
    492488        if (grep_for_me[0] != '\0') {
    493             sprintf(command, "grep '%s' %s | tail -n%d",
     489            mr_asprintf(&command, "grep '%s' %s | tail -n%d",
    494490                    grep_for_me, filename, g_noof_log_lines);
    495491        } else {
    496             sprintf(command, "tail -n%d %s", g_noof_log_lines,
     492            mr_asprintf(&command, "tail -n%d %s", g_noof_log_lines,
    497493                    filename);
    498494        }
     
    510506                    */
    511507                    if (!strncmp(err_log_lines[i], "root:", 5)) {
    512                         strcpy(tmp, err_log_lines[i] + 6);
    513                         strcpy(err_log_lines[i], tmp);
     508                        mr_asprintf(&tmp, "%s", err_log_lines[i] + 6);
     509                        strncpy(err_log_lines[i], tmp, (size_t)MAX_NEWT_COMMENT_LEN);
     510                        mr_free(tmp);
    514511                    }
    515512                    if (feof(fin)) {
     
    520517            paranoid_pclose(fin);
    521518        }
     519        mr_free(command);
    522520        refresh_log_screen();
    523         paranoid_free(command);
    524         paranoid_free(tmp);
    525521    }
    526522
     
    545541
    546542        va_start(args, fmt);
    547         vsprintf(output, fmt, args);
     543        vsnprintf(output, MAX_STR_LEN-1, fmt, args);
    548544        log_msg(0, output);
    549545        output[80] = '\0';
Note: See TracChangeset for help on using the changeset viewer.