Changeset 2327 in MondoRescue


Ignore:
Timestamp:
Aug 18, 2009, 3:20:37 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3338@localhost: bruno | 2009-08-11 23:03:30 +0200
bkpinfo->zip_suffix, bkpinfo->image_devs and bkpinfo->restore_path are now allocated dynmically

Location:
branches/2.2.10/mondo/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-archive.c

    r2326 r2327  
    28732873    biggiestruct.use_ntfsprog = use_ntfsprog;
    28742874    optimal_set_size = bkpinfo->optimal_set_size;
    2875     if (is_this_file_compressed(biggie_filename)
    2876         || bkpinfo->compression_level == 0) {
     2875    if (is_this_file_compressed(biggie_filename) || bkpinfo->compression_level == 0) {
    28772876        mr_asprintf(suffix, "%s", "");
    2878         //      log_it("%s is indeed compressed :-)", filename);
    28792877        should_I_compress_slices = FALSE;
    28802878    } else {
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2326 r2327  
    11701170
    11711171    if (flag_set['x']) {
    1172         strncpy(bkpinfo->image_devs, flag_val['x'], MAX_STR_LEN / 4);
     1172        mr_asprintf(bkpinfo->image_devs, flag_val['x']);
    11731173        if ((run_program_and_log_output("which ntfsclone", 2)) && (! bkpinfo->restore_data)) {
    11741174            fatal_error("Please install ntfsprogs package/tarball.");
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2326 r2327  
    18941894                finish(1);
    18951895            }
    1896             strncpy(bkpinfo->image_devs, p, MAX_STR_LEN / 4);
    1897             mr_free(p);
     1896            mr_free(bkpinfo->image_devs);
     1897            bkpinfo->image_devs = p;
    18981898        }
    18991899
     
    19731973    log_it("media size = %ld", bkpinfo->media_size[1]);
    19741974    log_it("media type = %s", bkptype_to_string(bkpinfo->backup_media_type));
    1975     log_it("prefix = %s", bkpinfo->prefix);
     1975    if (bkpinfo->prefix) {
     1976        log_it("prefix = %s", bkpinfo->prefix);
     1977    }
    19761978    log_it("compression = %ld", bkpinfo->compression_level);
    1977     log_it("include_paths = '%s'", bkpinfo->include_paths);
    1978     log_it("exclude_paths = '%s'", bkpinfo->exclude_paths);
     1979    if (bkpinfo->include_paths) {
     1980        log_it("include_paths = '%s'", bkpinfo->include_paths);
     1981    }
     1982    if (bkpinfo->exclude_paths) {
     1983        log_it("exclude_paths = '%s'", bkpinfo->exclude_paths);
     1984    }
    19791985    log_it("scratchdir = '%s'", bkpinfo->scratchdir);
    19801986    log_it("tmpdir = '%s'", bkpinfo->tmpdir);
    1981     log_it("image_devs = '%s'", bkpinfo->image_devs);
     1987    if (bkpinfo->image_devs) {
     1988        log_it("image_devs = '%s'", bkpinfo->image_devs);
     1989    }
    19821990    log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device, bkpinfo->boot_loader);
    19831991    if (bkpinfo->media_size[0] < 0) {
  • branches/2.2.10/mondo/src/common/libmondo-filelist.c

    r2325 r2327  
    8787
    8888    /*@ pointers ********************** */
    89     char *ptr;
     89    char *ptr = NULL;
    9090    FILE *fout;
    9191
     
    117117    mr_free(tempfile);
    118118
    119     log_it(bkpinfo->image_devs);
    120 
    121     ptr = bkpinfo->image_devs;
    122 
    123     malloc_string(dev);
    124     while (ptr && *ptr) {
    125         strcpy(dev, ptr);
    126         log_it("Examining imagedev %s", dev);
    127         for (i = 0; i < (int) strlen(dev) && dev[i] != ' '; i++);
    128         dev[i] = '\0';
    129         if (!strlen(dev)) {
    130             continue;
    131         }
    132         fprintf(fout, "%s\n", dev);
    133         log_it("Adding '%s' to biggielist", dev);
    134         if ((ptr = strchr(ptr, ' '))) {
    135             ptr++;
     119    if (bkpinfo->image_devs) {
     120        log_it("image_devs : %s", bkpinfo->image_devs);
     121
     122        ptr = bkpinfo->image_devs;
     123
     124        while (ptr && *ptr) {
     125            mr_asprintf(dev, "%s", ptr);
     126            log_it("Examining imagedev %s", dev);
     127            for (i = 0; i < (int) strlen(dev) && dev[i] != ' '; i++);
     128            dev[i] = '\0';
     129            if (!strlen(dev)) {
     130                mr_free(dev);
     131                continue;
     132            }
     133            fprintf(fout, "%s\n", dev);
     134            log_it("Adding '%s' to biggielist", dev);
     135            if ((ptr = strchr(ptr, ' '))) {
     136                ptr++;
     137            }
     138            mr_free(dev);
    136139        }
    137140    }
     
    139142    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    140143
    141     paranoid_free(dev);
    142144    return (retval);
    143145}
    144 
    145146
    146147
  • branches/2.2.10/mondo/src/common/libmondo-files.c

    r2325 r2327  
    12651265        mr_asprintf(tmp, "Your backup will occupy approximately %s media.", number_to_text((int) (scratchLL + 1)));
    12661266    }
    1267     if (!bkpinfo->image_devs[0] && (scratchLL < 50)) {
     1267    if (scratchLL < 50) {
    12681268        log_to_screen(tmp);
    12691269    }
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2326 r2327  
    479479    if (bkpinfo->use_lzo) {
    480480        mr_asprintf(bkpinfo->zip_exe, "lzop");
    481         strcpy(bkpinfo->zip_suffix, "lzo");
     481        mr_asprintf(bkpinfo->zip_suffix, "lzo");
    482482    } else if (bkpinfo->use_gzip) {
    483483        mr_asprintf(bkpinfo->zip_exe, "gzip");
    484         strcpy(bkpinfo->zip_suffix, "gz");
     484        mr_asprintf(bkpinfo->zip_suffix, "gz");
    485485    } else if (bkpinfo->compression_level != 0) {
    486486        mr_asprintf(bkpinfo->zip_exe, "bzip2");
    487         strcpy(bkpinfo->zip_suffix, "bz2");
     487        mr_asprintf(bkpinfo->zip_suffix, "bz2");
     488    } else {
     489        mr_asprintf(bkpinfo->zip_exe, "none");
     490        mr_asprintf(bkpinfo->zip_suffix, "");
    488491    }
    489492
     
    798801    mr_free(bkpinfo->boot_device);
    799802    mr_free(bkpinfo->zip_exe);
     803    mr_free(bkpinfo->zip_suffix);
     804    mr_free(bkpinfo->image_devs);
    800805    mr_free(bkpinfo->isodir);
    801806    mr_free(bkpinfo->prefix);
     
    804809    mr_free(bkpinfo->include_paths);
    805810    mr_free(bkpinfo->exclude_paths);
     811    mr_free(bkpinfo->restore_path);
    806812    mr_free(bkpinfo->nfs_mount);
    807813    mr_free(bkpinfo->nfs_remote_dir);
     
    829835    bkpinfo->boot_device = NULL;
    830836    bkpinfo->zip_exe = NULL;
    831     bkpinfo->zip_suffix[0] = '\0';
    832     bkpinfo->image_devs[0] = '\0';
     837    bkpinfo->zip_suffix = NULL;
     838    bkpinfo->image_devs = NULL;
    833839    bkpinfo->compression_level = 3;
    834840    bkpinfo->use_lzo = FALSE;
     
    853859    bkpinfo->include_paths = NULL;
    854860    bkpinfo->exclude_paths = NULL;
    855     bkpinfo->restore_path[0] = '\0';
     861    bkpinfo->restore_path = NULL;
    856862    bkpinfo->call_before_iso[0] = '\0';
    857863    bkpinfo->call_make_iso[0] = '\0';
  • branches/2.2.10/mondo/src/common/libmondo-verify.c

    r2326 r2327  
    5555    assert(bkpinfo != NULL);
    5656    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
    57     sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno,
    58             bkpinfo->zip_suffix);
     57    sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno, bkpinfo->zip_suffix);
    5958    if (!does_file_exist(output)) {
    60         sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno,
    61                 bkpinfo->zip_suffix);
     59        sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno, bkpinfo->zip_suffix);
    6260    }
    6361    return (output);
     
    216214    char *command = NULL;
    217215    char *mds = NULL;
    218     char *sz_exe;
     216    char *sz_exe = NULL;
    219217    static char *bufblkA = NULL;
    220218    static char *bufblkB = NULL;
     
    237235    int retval = 0;
    238236
    239     malloc_string(sz_exe);
    240237    if (!bufblkA) {
    241238        if (!(bufblkA = malloc(maxbufsize))) {
     
    254251    if (bkpinfo->compression_level > 0) {
    255252        if (bkpinfo->use_lzo) {
    256             strcpy(sz_exe, "lzop");
     253            mr_asprintf(sz_exe, "lzop");
    257254        } else if (bkpinfo->use_gzip) {
    258             strcpy(sz_exe, "gzip");
     255            mr_asprintf(sz_exe, "gzip");
    259256        } else {
    260             strcpy(sz_exe, "bzip2");
    261         }
    262     } else {
    263         sz_exe[0] = '\0';
     257            mr_asprintf(sz_exe, "bzip2");
     258        }
    264259    }
    265260
     
    289284        // handle slices until end of CD
    290285        if (slice_num == 0) {
    291             log_msg(2, "ISO=%d  bigfile=%ld --START--",
    292                     g_current_media_number, bigfile_num);
     286            log_msg(2, "ISO=%d  bigfile=%ld --START--", g_current_media_number, bigfile_num);
    293287            if (! (fin = fopen(slice_fname(bigfile_num, slice_num, mountpoint, ""), "r"))) {
    294288                log_msg(2, "Cannot open bigfile's info file");
     
    299293                paranoid_fclose(fin);
    300294            }
    301             mr_asprintf(tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
    302             log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
    303             forig = fopen(tmp, "r");
    304             mr_free(tmp);
    305 
    306             if (!forig) {
    307                 log_msg(2, "Failed to open bigfile. Darn.");
    308                 log_to_screen("%s/%s not found on live filesystem",
    309                             bkpinfo->restore_path,
    310                             biggiestruct.filename);
    311                 mr_asprintf(tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);
    312                 system(tmp);
     295            if (bkpinfo->restore_path) {
     296                mr_asprintf(tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
     297                log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
     298                forig = fopen(tmp, "r");
    313299                mr_free(tmp);
    314 
    315                 bigfile_num++;
    316                 slice_num = 0;
    317                 retval++;
     300   
     301                if (!forig) {
     302                    log_msg(2, "Failed to open bigfile. Darn.");
     303                    log_to_screen("%s/%s not found on live filesystem", bkpinfo->restore_path, biggiestruct.filename);
     304                    mr_asprintf(tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);
     305                    system(tmp);
     306                    mr_free(tmp);
     307
     308                    bigfile_num++;
     309                    slice_num = 0;
     310                    retval++;
     311                } else {
     312                    slice_num++;
     313                }
    318314            } else {
    319                 slice_num++;
     315                log_it("Unable to open bigfile as restore_path is NULL");
    320316            }
    321317        } else if (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, "")) &&
     
    327323            slice_num = 0;
    328324        } else {
    329             log_msg(2, "ISO=%d  bigfile=%ld  slice=%ld",
    330                     g_current_media_number, bigfile_num, slice_num);
    331             if (!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) {
     325            log_msg(2, "ISO=%d  bigfile=%ld  slice=%ld", g_current_media_number, bigfile_num, slice_num);
     326            if ((!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) && (sz_exe != NULL)) {
    332327                mr_asprintf(command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE);
    333328            } else {
     
    376371    }
    377372    mr_free(mountpoint);
     373    mr_free(sz_exe);
     374
    378375    last_bigfile_num = bigfile_num;
    379376    last_slice_num = slice_num - 1;
     
    388385        paranoid_free(bufblkB);
    389386    }
    390     paranoid_free(sz_exe);
    391387    return (0);
    392388}
     
    435431        mr_free(bkpinfo->zip_exe);
    436432        mr_asprintf(bkpinfo->zip_exe, "lzop");
    437         strcpy(bkpinfo->zip_suffix, "lzo");
     433        mr_free(bkpinfo->zip_suffix);
     434        mr_asprintf(bkpinfo->zip_suffix, "lzo");
    438435        bkpinfo->use_lzo = TRUE;
    439436        bkpinfo->use_gzip = FALSE;
     
    443440        mr_free(bkpinfo->zip_exe);
    444441        mr_asprintf(bkpinfo->zip_exe, "gzip");
    445         strcpy(bkpinfo->zip_suffix, "gz");
     442        mr_free(bkpinfo->zip_suffix);
     443        mr_asprintf(bkpinfo->zip_suffix, "gz");
    446444        bkpinfo->use_lzo = FALSE;
    447445        bkpinfo->use_gzip = TRUE;
     
    451449        mr_free(bkpinfo->zip_exe);
    452450        mr_asprintf(bkpinfo->zip_exe, "bzip2");
    453         strcpy(bkpinfo->zip_suffix, "bz2");
     451        mr_free(bkpinfo->zip_suffix);
     452        mr_asprintf(bkpinfo->zip_suffix, "bz2");
    454453        bkpinfo->use_lzo = FALSE;
    455454        bkpinfo->use_gzip = FALSE;
     455    }
     456    if (bkpinfo->zip_exe == NULL) {
     457        mr_asprintf(bkpinfo->zip_exe, "none");
     458    }
     459    if (bkpinfo->zip_suffix == NULL) {
     460        mr_asprintf(bkpinfo->zip_suffix, "");
    456461    }
    457462    unlink(outlog);
     
    686691 * Verify all afioballs from the opened tape/CD stream.
    687692 * @param bkpinfo The backup information structure. Fields used:
    688  * - @c bkpinfo->restore_path
    689693 * - @c bkpinfo->tmpdir
    690694 *
     
    880884        mr_free(comment);
    881885
    882         mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
    883         res = verify_a_biggiefile_from_stream(logical_fname, size);
    884         mr_free(logical_fname);
    885 
    886         retval += res;
     886        if (bkpinfo->restore_path) {
     887            mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
     888            res = verify_a_biggiefile_from_stream(logical_fname, size);
     889            mr_free(logical_fname);
     890            retval += res;
     891        } else {
     892            log_it("Unable to verify bigfile as restore_path is NULL");
     893        }
     894
    887895        current_biggiefile_number++;
    888896        g_current_progress++;
  • branches/2.2.10/mondo/src/common/mondostructures.h

    r2326 r2327  
    382382   * bz2, gzip uses gz, etc. Do not include the dot.
    383383   */
    384     char zip_suffix[MAX_STR_LEN / 4];
     384    char *zip_suffix;
    385385
    386386  /**
     
    397397   * This is a useful feature, but use at your own risk.
    398398   */
    399     char image_devs[MAX_STR_LEN / 4];
     399    char *image_devs;
    400400
    401401  /**
     
    519519   * without overwriting the old ones. Ignored during a backup.
    520520   */
    521     char restore_path[MAX_STR_LEN];
     521    char *restore_path;
    522522
    523523  /**
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c

    r2325 r2327  
    667667    chdir(bkpinfo->restore_path);
    668668
    669     mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path);
     669    mr_asprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path);
    670670    run_program_and_log_output(command, FALSE);
    671671    mr_free(command);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2326 r2327  
    895895mr_free(value);
    896896
    897 bkpinfo->zip_suffix[0] = '\0';
    898897value = read_cfg_var(cfg_file, "use-lzo");
    899898if (value && strstr(value, "yes")) {
     
    902901    mr_free(bkpinfo->zip_exe);
    903902    mr_asprintf(bkpinfo->zip_exe, "lzop");
    904     strcpy(bkpinfo->zip_suffix, "lzo");
     903    mr_free(bkpinfo->zip_suffix);
     904    mr_asprintf(bkpinfo->zip_suffix, "lzo");
    905905}
    906906mr_free(value);
     
    912912    mr_free(bkpinfo->zip_exe);
    913913    mr_asprintf(bkpinfo->zip_exe, "gzip");
    914     strcpy(bkpinfo->zip_suffix, "gz");
     914    mr_free(bkpinfo->zip_suffix);
     915    mr_asprintf(bkpinfo->zip_suffix, "gz");
    915916}
    916917mr_free(value);
     
    922923    mr_free(bkpinfo->zip_exe);
    923924    mr_asprintf(bkpinfo->zip_exe, "bzip2");
    924     strcpy(bkpinfo->zip_suffix, "bz2");
     925    mr_free(bkpinfo->zip_suffix);
     926    mr_asprintf(bkpinfo->zip_suffix, "bz2");
    925927}
    926928mr_free(value);
     929
     930if (bkpinfo->zip_exe == NULL) {
     931    mr_asprintf(bkpinfo->zip_exe, "none");
     932}
     933if (bkpinfo->zip_suffix == NULL) {
     934    mr_asprintf(bkpinfo->zip_suffix, "");
     935}
    927936
    928937value = read_cfg_var(cfg_file, "differential");
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2326 r2327  
    360360    char *tmp1 = NULL;
    361361
    362     /* Clean up blkid cache file if they exist */
    363     mr_asprintf(tmp1,"%s/etc/blkid.tab",bkpinfo->restore_path);
    364     (void)unlink(tmp1);
    365     paranoid_free(tmp1);
    366     mr_asprintf(tmp1,"%s/etc/blkid.tab.old",bkpinfo->restore_path);
    367     (void)unlink(tmp1);
    368     paranoid_free(tmp1);
     362    if (bkpinfo->restore_path) {
     363        /* Clean up blkid cache file if they exist */
     364        mr_asprintf(tmp1,"%s/etc/blkid.tab",bkpinfo->restore_path);
     365        (void)unlink(tmp1);
     366        paranoid_free(tmp1);
     367        mr_asprintf(tmp1,"%s/etc/blkid.tab.old",bkpinfo->restore_path);
     368        (void)unlink(tmp1);
     369        paranoid_free(tmp1);
     370    }
    369371}
    370372
     
    375377    char *editor = NULL;
    376378
    377     /* Clean up multiconf cache file if they exist */
    378     mr_asprintf(tmp1,"%s/var/lib/multipath/bindings",bkpinfo->restore_path);
    379     (void)unlink(tmp1);
    380     paranoid_free(tmp1);
     379    if (bkpinfo->restore_path) {
     380        /* Clean up multiconf cache file if they exist */
     381        mr_asprintf(tmp1,"%s/var/lib/multipath/bindings",bkpinfo->restore_path);
     382        (void)unlink(tmp1);
     383        paranoid_free(tmp1);
     384    }
    381385
    382386    /* Edit multipath.conf if needed to adapt wwid */
     
    425429 * @return 0 for success, or the number of errors encountered.
    426430 */
    427 int
    428 interactive_mode(struct mountlist_itself *mountlist,
    429                  struct raidlist_itself *raidlist)
     431int interactive_mode(struct mountlist_itself *mountlist, struct raidlist_itself *raidlist)
    430432{
    431433    int retval = 0;
     
    442444    char *tmp1 = NULL;
    443445    char *fstab_fname;
    444     char *old_restpath;
     446    char *old_restpath = NULL;
    445447
    446448    struct s_node *filelist;
     
    452454    malloc_string(tmp);
    453455    malloc_string(fstab_fname);
    454     malloc_string(old_restpath);
    455456    assert(bkpinfo != NULL);
    456457    assert(mountlist != NULL);
     
    460461
    461462    if (g_text_mode) {
    462         if (!ask_me_yes_or_no
    463             ("Interactive Mode + textonly = experimental! Proceed anyway?"))
    464         {
     463        if (!ask_me_yes_or_no("Interactive Mode + textonly = experimental! Proceed anyway?")) {
    465464            fatal_error("Wise move.");
    466465        }
     
    473472
    474473#ifdef __FreeBSD__
    475     if (strstr
    476         (call_program_and_get_last_line_of_output("cat /tmp/cmdline"),
    477          "noresize"))
     474    if (strstr(call_program_and_get_last_line_of_output("cat /tmp/cmdline"), "noresize"))
    478475#else
    479     if (strstr
    480         (call_program_and_get_last_line_of_output("cat /proc/cmdline"),
    481          "noresize"))
     476    if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "noresize"))
    482477#endif
    483478    {
     
    581576    }
    582577    /* restore */
    583     if ((restore_all =
    584          ask_me_yes_or_no("Do you want me to restore all of your data?")))
    585     {
     578    if ((restore_all = ask_me_yes_or_no("Do you want me to restore all of your data?"))) {
    586579        log_msg(1, "Restoring all data");
    587580        retval += restore_everything(NULL);
    588     } else
    589         if ((restore_all =
    590              ask_me_yes_or_no
    591              ("Do you want me to restore _some_ of your data?"))) {
    592         strcpy(old_restpath, bkpinfo->restore_path);
     581    } else if ((restore_all = ask_me_yes_or_no("Do you want me to restore _some_ of your data?"))) {
     582        mr_asprintf(old_restpath, "%s", bkpinfo->restore_path);
    593583        for (done = FALSE; !done;) {
    594584            unlink("/tmp/filelist.full");
     
    610600                        tmp[0] = '\0';  // so we restore to [blank]/file/name :)
    611601                    }
    612                     strcpy(bkpinfo->restore_path, tmp);
     602                    mr_free(bkpinfo->restore_path);
     603                    mr_asprintf(bkpinfo->restore_path, "%s", tmp);
    613604                    log_msg(1, "Restoring subset");
    614605                    retval += restore_everything(filelist);
    615                     free_filelist(filelist);
    616606                } else {
    617                     strcpy(bkpinfo->restore_path, old_restpath);
    618                     free_filelist(filelist);
     607                    mr_free(bkpinfo->restore_path);
     608                    mr_asprintf(bkpinfo->restore_path, "%s", old_restpath);
    619609                }
     610                free_filelist(filelist);
    620611                mr_free(p);
    621612
    622                 if (!ask_me_yes_or_no
    623                     ("Restore another subset of your backup?")) {
     613                if (!ask_me_yes_or_no("Restore another subset of your backup?")) {
    624614                    done = TRUE;
    625615                }
     
    628618            }
    629619        }
    630         strcpy(old_restpath, bkpinfo->restore_path);
    631     } else {
    632         mvaddstr_and_log_it(g_currentY++,
    633                             0,
    634                             "User opted not to restore any data.                                  ");
     620        mr_free(old_restpath);
     621    } else {
     622        mvaddstr_and_log_it(g_currentY++, 0, "User opted not to restore any data.                                  ");
    635623    }
    636624    if (retval) {
    637         mvaddstr_and_log_it(g_currentY++,
    638                             0,
    639                             "Errors occurred during the restore phase.            ");
     625        mvaddstr_and_log_it(g_currentY++, 0, "Errors occurred during the restore phase.            ");
    640626    }
    641627
     
    685671    paranoid_free(tmp);
    686672    paranoid_free(fstab_fname);
    687     paranoid_free(old_restpath);
    688673    log_it("Leaving interactive_mode()");
    689674    return (retval);
     
    942927    int retval = 0;
    943928
    944   /** malloc **/
    945     char *old_restpath;
     929    char *old_restpath = NULL;
    946930    char *p = NULL;
    947931
    948932    struct mountlist_itself *mountlist = NULL;
    949 //  static
    950933    struct raidlist_itself *raidlist = NULL;
    951934    struct s_node *filelist = NULL;
     
    953936    log_msg(1, "restore_to_live_filesystem() - starting");
    954937    assert(bkpinfo != NULL);
    955     malloc_string(old_restpath);
    956938    mountlist = malloc(sizeof(struct mountlist_itself));
    957939    raidlist = malloc(sizeof(struct raidlist_itself));
     
    960942    }
    961943
    962     strcpy(bkpinfo->restore_path, "/");
     944    mr_free(bkpinfo->restore_path);
     945    mr_asprintf(bkpinfo->restore_path, "/");
    963946    if (!g_restoring_live_from_cd && !g_restoring_live_from_nfs) {
    964947        popup_and_OK
     
    990973    if (!g_restoring_live_from_nfs && (filelist = process_filelist_and_biggielist())) {
    991974        save_filelist(filelist, "/tmp/selected-files.txt");
    992         strcpy(old_restpath, bkpinfo->restore_path);
     975        mr_asprintf(old_restpath, "%s", bkpinfo->restore_path);
    993976        p = popup_and_get_string("Restore path", "Restore files to where? )", bkpinfo->restore_path);
    994977        if (p != NULL) {
    995             strcpy(bkpinfo->restore_path, p);
    996             mr_free(p);
     978            mr_free(bkpinfo->restore_path);
     979            bkpinfo->restore_path = p;
    997980
    998981            log_it("Restoring everything");
    999982            retval += restore_everything(filelist);
    1000             free_filelist(filelist);
    1001             strcpy(bkpinfo->restore_path, old_restpath);
    1002         } else {
    1003             free_filelist(filelist);
    1004         }
    1005         strcpy(bkpinfo->restore_path, old_restpath);
     983        }
     984        free_filelist(filelist);
     985        mr_free(bkpinfo->restore_path);
     986        bkpinfo->restore_path = old_restpath;
    1006987    } else {
    1007988        if (filelist != NULL) {
     
    10221003        eject_device(bkpinfo->media_device);
    10231004    }
    1024     paranoid_free(old_restpath);
    10251005    free(mountlist);
    10261006    free(raidlist);
     
    24272407 * @return 0 for success, or the number of filesets that failed.
    24282408 */
    2429 int
    2430 restore_all_tarballs_from_stream(struct s_node *filelist)
     2409int restore_all_tarballs_from_stream(struct s_node *filelist)
    24312410{
    24322411    int retval = 0;
     
    29042883            g_restoring_live_from_nfs = TRUE;
    29052884        }
     2885        /* Adding an initialisation in order to avoid to hndle NULL pointer later */
     2886        mr_free(bkpinfo->restore_path);
     2887        mr_asprintf(bkpinfo->restore_path, "%s", "/tmp");
     2888
    29062889        log_msg(2, "Calling restore_to_live_filesystem()");
    29072890        retval = restore_to_live_filesystem();
     
    29212904
    29222905        log_it("About to call load_mountlist and load_raidtab");
    2923         strcpy(bkpinfo->restore_path, MNT_RESTORING);
     2906        mr_free(bkpinfo->restore_path);
     2907        mr_asprintf(bkpinfo->restore_path, "%s", MNT_RESTORING);
    29242908        read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
    29252909        retval = load_mountlist(mountlist, g_mountlist_fname);
Note: See TracChangeset for help on using the changeset viewer.