Changeset 2280


Ignore:
Timestamp:
Jul 20, 2009, 12:27:51 AM (10 years ago)
Author:
bruno
Message:

r3275@localhost: bruno | 2009-07-19 23:23:18 +0200

  • Replace sprintf by mr_asprintf in mondo-rstr-tools.c
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2242 r2280  
    117117************************************************************************/
    118118char *incoming_ptr;
    119 char *question_ptr;
     119char *question_ptr = NULL;
    120120
    121121char incoming[MAX_STR_LEN] = "\0";
    122 char question[MAX_STR_LEN];
    123122
    124123assert_string_is_neither_NULL_nor_zerolength(infname);
     
    131130}
    132131
    133 question_ptr = malloc(sizeof(question));
    134 if (question_ptr == NULL) {
    135 fprintf(stderr, "Out of Memory\n");
    136 exit(EXIT_FAILURE);
    137 }
    138 
    139132memset(incoming_ptr, '\0', sizeof(incoming));
    140 memset(question_ptr, '\0', sizeof(question));
    141 
    142 
    143133
    144134if (!(fin = fopen(infname, "r"))) {
     
    156146}
    157147
    158 sprintf(question_ptr,
    159         "Should I restore the image of %s ?", incoming_ptr);
     148mr_asprintf(&question_ptr, "Should I restore the image of %s ?", incoming_ptr);
    160149
    161150if (ask_me_yes_or_no(question_ptr)) {
     
    167156paranoid_free(incoming_ptr);
    168157incoming_ptr = NULL;
    169 paranoid_free(question_ptr);
    170 question_ptr = NULL;
    171 
    172 
     158mr_free(question_ptr);
    173159paranoid_fclose(fout);
    174160paranoid_fclose(fin);
     
    223209
    224210/** needs malloc **/
    225 char *command;
     211char *command = NULL;
    226212char *file;
    227213char *tmp;
    228214int res;
    229215
    230 malloc_string(command);
    231216malloc_string(file);
    232217malloc_string(tmp);
     
    236221
    237222if (strncmp(preamble, f, strlen(preamble)) == 0) {
    238 strcpy(file, f + strlen(preamble));
     223    strcpy(file, f + strlen(preamble));
    239224} else {
    240 strcpy(file, f);
     225    strcpy(file, f);
    241226}
    242227if (file[0] == '/' && file[1] == '/') {
    243 strcpy(tmp, file);
    244 strcpy(file, tmp + 1);
    245 }
    246 sprintf(tmp,
    247     "Checking to see if f=%s, file=%s, is in the list of biggiefiles",
    248     f, file);
    249 log_msg(2, tmp);
    250 sprintf(command, "grep -E '^%s$' %s", file, list_fname);
     228    strcpy(tmp, file);
     229    strcpy(file, tmp + 1);
     230}
     231log_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles", f, file);
     232mr_asprintf(&command, "grep -E '^%s$' %s", file, list_fname);
    251233res = run_program_and_log_output(command, FALSE);
    252 paranoid_free(command);
     234mt_free(command);
    253235paranoid_free(file);
    254 paranoid_free(tmp);
     236mr_free(tmp);
    255237if (res) {
    256 return (FALSE);
     238    return (FALSE);
    257239} else {
    258 return (TRUE);
     240    return (TRUE);
    259241}
    260242}
     
    277259int iso_fiddly_bits(bool nuke_me_please)
    278260{
    279 char *mount_isodir_command = NULL;
    280 char *tmp, *command;
    281 char *mds = NULL;
    282 int retval = 0, i;
    283 bool already_mounted = FALSE;
     261    char *mount_isodir_command = NULL;
     262    char *command = NULL;
     263    char *mds = NULL;
     264    int retval = 0, i;
     265    bool already_mounted = FALSE;
    284266
    285267assert(bkpinfo != NULL);
    286 malloc_string(tmp);
    287 malloc_string(command);
    288268g_ISO_restore_mode = TRUE;
    289269read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
     
    295275    }
    296276    /* End patch */
    297     sprintf(command, "mkdir -p %s", bkpinfo->isodir);
     277    mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
    298278    run_program_and_log_output(command, 5);
     279    mr_free(command);
    299280    log_msg(2, "Setting isodir to %s", bkpinfo->isodir);
    300281}
     
    315296    mr_strcat(mount_isodir_command, " -o ro %s", bkpinfo->isodir);
    316297    run_program_and_log_output("df -m", FALSE);
    317     sprintf(tmp,
     298    log_msg(1,
    318299        "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?",
    319300        mount_isodir_command);
    320     log_msg(1, tmp);
    321301    if (run_program_and_log_output(mount_isodir_command, FALSE)) {
    322302        popup_and_OK
     
    333313i = what_number_cd_is_this();   /* has the side-effect of calling mount_media() */
    334314mds = media_descriptor_string(bkpinfo->backup_media_type);
    335 sprintf(tmp, "%s #%d has been mounted via loopback mount", mds, i);
    336315mr_free(mds);
    337316
    338 log_msg(1, tmp);
     317log_msg(1, "%s #%d has been mounted via loopback mount", mds, i);
    339318if (i < 0) {
    340319popup_and_OK
     
    344323log_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__,
    345324    bkpinfo->isodir);
    346 paranoid_free(tmp);
    347 paranoid_free(command);
    348325return (retval);
    349326}
     
    377354
    378355/** malloc **/
    379 char *tmp, *command, *mountdir, *mountpoint;
     356char *tmp = NULL;
     357char *command = NULL;
     358char *mountdir = NULL;
     359char *mountpoint = NULL;
    380360char *additional_parameters = NULL;
    381361
     
    383363assert_string_is_neither_NULL_nor_zerolength(mpt);
    384364assert(format != NULL);
    385 malloc_string(tmp);
    386 malloc_string(command);
    387 malloc_string(mountdir);
    388 malloc_string(mountpoint);
    389365
    390366    if (!strcmp(mpt, "/1")) {
    391         strcpy(mountpoint, "/");
     367        mr_asprintf(&mountpoint, "/");
    392368        log_msg(3, "Mommm! SME is being a dildo!");
    393369    } else {
    394         strcpy(mountpoint, mpt);
     370        mr_asprintf(&mountpoint, mpt);
    395371    }
    396372
     
    401377        return (0);
    402378    }
    403     sprintf(tmp, "Mounting device %s   ", device);
     379    mr_asprintf(&tmp, "Mounting device %s   ", device);
    404380    log_msg(1, tmp);
    405381    /* Deal with additional params only if not /proc or /sys */
     
    420396
    421397    if (!strcmp(mountpoint, "swap")) {
    422         sprintf(command, "swapon %s", device);
     398        mr_asprintf(&command, "swapon %s", device);
     399        mr_asprintf(&mountdir, "swap");
    423400    } else {
    424401        if (!strcmp(mountpoint, "/")) {
    425             strcpy(mountdir, MNT_RESTORING);
     402            mr_asprintf(&mountdir, "%s", MNT_RESTORING);
    426403        } else {
    427             sprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint);
    428         }
    429         sprintf(command, "mkdir -p %s", mountdir);
     404            mr_asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint);
     405        }
     406        mr_asprintf(&command, "mkdir -p %s", mountdir);
    430407        run_program_and_log_output(command, FALSE);
    431         sprintf(command, "mount -t %s %s %s %s 2>> %s", format, device,
     408        mr_free(command);
     409
     410        mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device,
    432411                additional_parameters, mountdir, MONDO_LOGFILE);
    433412        log_msg(2, "command='%s'", command);
    434413    }
    435     paranoid_free(additional_parameters);
     414    mr_free(additional_parameters);
    436415
    437416    res = run_program_and_log_output(command, TRUE);
    438417    if (res && (strstr(command, "xattr") || strstr(command, "acl"))) {
    439418        log_msg(1, "Re-trying without the fancy extra parameters");
    440         sprintf(command, "mount -t %s %s %s 2>> %s", format, device,
     419        mr_free(command);
     420        mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device,
    441421            mountdir, MONDO_LOGFILE);
    442422        res = run_program_and_log_output(command, TRUE);
     
    450430        } else {
    451431            log_msg(2, "Retrying w/o the '-t' switch");
    452             sprintf(command, "mount %s %s 2>> %s", device, mountdir,
    453                 MONDO_LOGFILE);
     432            mr_free(command);
     433            mr_asprintf(&command, "mount %s %s 2>> %s", device, mountdir, MONDO_LOGFILE);
    454434            log_msg(2, "2nd command = '%s'", command);
    455435            res = run_program_and_log_output(command, TRUE);
     
    469449    }
    470450
    471 paranoid_free(tmp);
    472 paranoid_free(command);
    473 paranoid_free(mountdir);
    474 paranoid_free(mountpoint);
     451mr_free(tmp);
     452mr_free(command);
     453mr_free(mountdir);
     454mr_free(mountpoint);
    475455
    476456    return (res);
     
    491471{
    492472int retval = 0, lino, res;
    493 char *tmp;
     473char *tmp = NULL;
    494474char *these_failed = NULL;
    495475char *format;
    496476struct mountlist_itself *mountlist = NULL;
    497477
    498 malloc_string(tmp);
    499478malloc_string(format);
    500479
     
    518497                "Again with the /proc - why is this in your mountlist?");
    519498        } else if (is_this_device_mounted(mountlist->el[lino].device)) {
    520             sprintf(tmp, "%s is already mounted",
     499            mr_asprintf(&tmp, "%s is already mounted",
    521500                mountlist->el[lino].device);
    522501            log_to_screen(tmp);
     502            mr_free(tmp);
    523503        } else if (strcmp(mountlist->el[lino].mountpoint, "none")
    524504           && strcmp(mountlist->el[lino].mountpoint, "lvm")
    525505           && strcmp(mountlist->el[lino].mountpoint, "raid")
    526506           && strcmp(mountlist->el[lino].mountpoint, "image")) {
    527             sprintf(tmp, "Mounting %s", mountlist->el[lino].device);
     507            mr_asprintf(&tmp, "Mounting %s", mountlist->el[lino].device);
    528508            update_progress_form(tmp);
     509            mr_free(tmp);
    529510            strcpy(format, mountlist->el[lino].format);
    530511            res = mount_device(mountlist->el[lino].device,
     
    548529                ("format and restore *without* partitioning first. Sorry for the inconvenience.");
    549530        }
    550         sprintf(tmp, "Could not mount device(s) %s- shall I abort?", these_failed);
     531        mr_asprintf(&tmp, "Could not mount device(s) %s- shall I abort?", these_failed);
    551532
    552533        if (!ask_me_yes_or_no(tmp)) {
     
    560541        ("Unable to mount some or all of your partitions.");
    561542        }
     543        mr_free(tmp);
    562544    } else {
    563545        log_to_screen("All partitions were mounted OK.");
     
    571553    run_program_and_log_output("df -m", 3);
    572554    paranoid_free(mountlist);
    573     paranoid_free(tmp);
    574555    paranoid_free(format);
    575556    return (retval);
     
    591572int mount_media()
    592573{
    593 char *mount_cmd;
     574char *mount_cmd = NULL;
    594575int i, res;
    595576#ifdef __FreeBSD__
     
    598579#endif
    599580
    600 malloc_string(mount_cmd);
    601581assert(bkpinfo != NULL);
    602582
     
    604584        || bkpinfo->backup_media_type == udev) {
    605585        log_msg(8, "Tape/udev. Therefore, no need to mount a media.");
    606         paranoid_free(mount_cmd);
    607586        return 0;
    608587    }
     
    610589    if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) {
    611590        log_msg(2, "mount_media() - media already mounted. Fair enough.");
    612         paranoid_free(mount_cmd);
    613591        return (0);
    614592    }
     
    623601        }
    624602#ifdef __FreeBSD__
    625         sprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
    626             bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);
     603        mr_asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);
    627604        mddev = make_vn(mount_cmd);
    628         sprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
     605        mr_free(mount_cmd);
     606
     607        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
    629608#else
    630         sprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s",
    631             bkpinfo->isodir, bkpinfo->nfs_remote_dir,
     609        mr_asprintf(&mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir,
    632610            bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    633611#endif
     
    635613    } else if (bkpinfo->backup_media_type == iso) {
    636614#ifdef __FreeBSD__
    637         sprintf(mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir,
    638             bkpinfo->prefix, g_current_media_number);
     615        mr_asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number);
    639616        mddev = make_vn(mount_cmd);
    640         sprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
     617        mr_free(mount_cmd);
     618
     619        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
    641620#else
    642         sprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
     621        mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
    643622            bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    644623#endif
    645624    } else if (bkpinfo->backup_media_type == usb) {
    646         sprintf(mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);
     625        mr_asprintf(&mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);
    647626    } else if (strstr(bkpinfo->media_device, "/dev/")) {
    648627#ifdef __FreeBSD__
    649         sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
    650         MNT_CDROM);
     628        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
    651629#else
    652         sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",
    653         bkpinfo->media_device, MNT_CDROM);
     630        mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
    654631#endif
    655632    } else {
     
    663640
    664641#ifdef __FreeBSD__
    665     sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
    666         MNT_CDROM);
     642        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
    667643#else
    668     sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",
    669         bkpinfo->media_device, MNT_CDROM);
     644        mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
    670645#endif
    671646    }
     
    682657        }
    683658    }
     659    mr_free(mount_cmd);
    684660
    685661    if (res) {
     
    688664        log_msg(2, "Mounted media drive OK");
    689665    }
    690     paranoid_free(mount_cmd);
    691666    return (res);
    692667}
     
    694669*END_MOUNT_CDROM                                                         *
    695670**************************************************************************/
    696 
    697671
    698672
     
    743717char *value = NULL;
    744718char *tmp = NULL;
     719char *tmp1 = NULL;
    745720char *envtmp1 = NULL;
    746721char *envtmp2 = NULL;
     
    752727t_bkptype media_specified_by_user;
    753728
    754 malloc_string(command);
    755729malloc_string(iso_mnt);
    756730malloc_string(iso_path);
     
    850824        }
    851825        sprintf(bkpinfo->media_device, "%s1", value);
    852         sprintf(tmp, "Backup medium is USB --- dev=%s", bkpinfo->media_device);
    853         log_msg(2, tmp);
     826        log_msg(2, "Backup medium is USB --- dev=%s", bkpinfo->media_device);
    854827    } else if (bkpinfo->backup_media_type == tape
    855828            || bkpinfo->backup_media_type == udev) {
     
    860833        read_cfg_var(cfg_file, "media-size", value);
    861834        bkpinfo->media_size[1] = atol(value);
    862         sprintf(tmp, "Backup medium is TAPE --- dev=%s",
    863                 bkpinfo->media_device);
    864         log_msg(2, tmp);
     835        log_msg(2, "Backup medium is TAPE --- dev=%s", bkpinfo->media_device);
    865836    } else {
    866837        strcpy(bkpinfo->media_device, "/dev/cdrom");    /* we don't really need this var */
     
    953924
    954925read_cfg_var(g_mondo_cfg_file, "please-dont-eject", tmp);
    955 if (tmp[0]
    956 ||
    957 strstr(call_program_and_get_last_line_of_output
    958        ("cat /proc/cmdline"), "donteject")) {
    959 bkpinfo->please_dont_eject = TRUE;
    960 log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
     926if (tmp[0] || strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "donteject")) {
     927    bkpinfo->please_dont_eject = TRUE;
     928    log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
    961929}
    962930
     
    1018986            log_msg(2, "NB: isodir is already mounted");
    1019987            /* Find out where it's mounted */
    1020             sprintf(command,
    1021                     "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3",
    1022                     g_isodir_device);
     988            mr_asprintf(&command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);
    1023989            log_it("command = %s", command);
    1024             log_it("res of it = %s",
    1025                 call_program_and_get_last_line_of_output(command));
    1026             sprintf(iso_mnt, "%s",
    1027                     call_program_and_get_last_line_of_output(command));
     990            log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
     991            sprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command));
     992            mr_free(command);
    1028993        } else {
    1029994            sprintf(iso_mnt, "/tmp/isodir");
    1030             sprintf(tmp, "mkdir -p %s", iso_mnt);
    1031             run_program_and_log_output(tmp, 5);
    1032             sprintf(tmp, "mount %s %s", g_isodir_device, iso_mnt);
    1033             if (run_program_and_log_output(tmp, 3)) {
     995            mr_asprintf(&tmp1, "mkdir -p %s", iso_mnt);
     996            run_program_and_log_output(tmp1, 5);
     997            mr_free(tmp1);
     998
     999            mr_asprintf(&tmp1, "mount %s %s", g_isodir_device, iso_mnt);
     1000            if (run_program_and_log_output(tmp1, 3)) {
    10341001                log_msg(1,
    10351002                        "Unable to mount isodir. Perhaps this is really a CD backup?");
     
    10381005                bkpinfo->isodir[0] = iso_mnt[0] = iso_path[0] = '\0';
    10391006                if (mount_media()) {
     1007                    mr_free(tmp1);
    10401008                    fatal_error
    10411009                        ("Unable to mount isodir. Failed to mount CD-ROM as well.");
     
    10451013                }
    10461014            }
     1015            mr_free(tmp1);
    10471016        }
    10481017        /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */
     
    10721041paranoid_free(value);
    10731042paranoid_free(tmp);
    1074 paranoid_free(command);
    10751043paranoid_free(iso_mnt);
    10761044paranoid_free(iso_path);
     
    11031071
    11041072/** add mallocs**/
    1105 char *command;
     1073char *command = NULL;
    11061074char *tmp;
    11071075int res = 0;
     
    11101078
    11111079assert(bkpinfo != NULL);
    1112 malloc_string(command);
    11131080malloc_string(tmp);
    11141081
     
    11341101    unlink(FILELIST_FULL_STUB);
    11351102    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1136         sprintf(command,
    1137             "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s",
     1103        mr_asprintf(&command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s",
    11381104            bkpinfo->internal_tape_block_size,
    11391105            bkpinfo->media_device,
     
    11451111        log_msg(1, "tarcommand = %s", command);
    11461112        run_program_and_log_output(command, 1);
     1113        mr_free(command);
     1114
    11471115        if (!does_file_exist(FILELIST_FULL_STUB)) {
    11481116            /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    11491117            log_msg(2, "pre-2.2.4 compatible mode on");
    1150             sprintf(command,
     1118            mr_asprintf(&command,
    11511119                "tar -b %ld -zxf %s %s %s %s %s %s",
    11521120                bkpinfo->internal_tape_block_size,
     
    11591127            log_msg(1, "tarcommand = %s", command);
    11601128            run_program_and_log_output(command, 1);
     1129            mr_free(command);
    11611130        }
    11621131    } else {
     
    11671136        log_msg(2, "Back from iotcn");
    11681137        run_program_and_log_output("mount", 1);
    1169         sprintf(command,
     1138        mr_asprintf(&command,
    11701139            "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s",
    11711140            MNT_CDROM,
     
    11781147        log_msg(1, "tarcommand = %s", command);
    11791148        run_program_and_log_output(command, 1);
     1149        mr_free(command);
     1150
    11801151        if (!does_file_exist(FILELIST_FULL_STUB)) {
    11811152            /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    11821153            log_msg(2, "pre-2.2.4 compatible mode on");
    1183             sprintf(command,
     1154            mr_asprintf(&command,
    11841155                "tar -zxf %s/images/all.tar.gz %s %s %s %s %s",
    11851156                MNT_CDROM,
     
    11921163            log_msg(1, "tarcommand = %s", command);
    11931164            run_program_and_log_output(command, 1);
     1165            mr_free(command);
    11941166        }
    11951167        if (!does_file_exist(BIGGIELIST_TXT_STUB)) {
     
    12021174        }
    12031175    }
    1204     sprintf(command, "cp -f %s %s", MONDO_CFG_FILE_STUB,
    1205         g_mondo_cfg_file);
     1176    mr_asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB, g_mondo_cfg_file);
    12061177    run_program_and_log_output(command, FALSE);
    1207 
    1208     sprintf(command, "cp -f %s/%s %s", bkpinfo->tmpdir,
    1209         BIGGIELIST_TXT_STUB, g_biggielist_txt);
     1178    mr_free(command);
     1179
     1180    mr_asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB, g_biggielist_txt);
    12101181    log_msg(1, "command = %s", command);
    12111182    paranoid_system(command);
    1212     sprintf(command, "ln -sf %s/%s %s", bkpinfo->tmpdir,
    1213         FILELIST_FULL_STUB, g_filelist_full);
     1183    mr_free(command);
     1184
     1185    mr_asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir, FILELIST_FULL_STUB, g_filelist_full);
    12141186    log_msg(1, "command = %s", command);
    12151187    paranoid_system(command);
    1216     }
    1217 
    1218     if (am_I_in_disaster_recovery_mode()
     1188    mr_free(command);
     1189}
     1190
     1191if (am_I_in_disaster_recovery_mode()
    12191192    &&
    12201193    /* If it was there, do not overwrite it */
    12211194    (extract_mountlist_stub)
    12221195    &&
    1223     ask_me_yes_or_no("Do you want to retrieve the mountlist as well?"))
    1224     {
    1225         sprintf(command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,
     1196    ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) {
     1197        mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,
    12261198            bkpinfo->tmpdir);
    1227     paranoid_system(command);
     1199        paranoid_system(command);
     1200        mr_free(command);
    12281201    }
    12291202
     
    12481221        log_to_screen("Pre-processing filelist");
    12491222        if (!does_file_exist(g_biggielist_txt)) {
    1250             sprintf(command, "echo -n > %s", g_biggielist_txt);
     1223            mr_asprintf(&command, "echo -n > %s", g_biggielist_txt);
    12511224            paranoid_system(command);
    1252         }
    1253         sprintf(command, "grep -E '^/dev/.*' %s > %s",
     1225            mr_free(command);
     1226        }
     1227        mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s",
    12541228                g_biggielist_txt, g_filelist_imagedevs);
    12551229        paranoid_system(command);
     1230        mr_free(command);
    12561231        exit(0);
    12571232        break;
     
    13011276    }
    13021277
    1303     paranoid_free(command);
    13041278    paranoid_free(tmp);
    13051279    return (filelist);
     
    13221296int backup_crucial_file(char *path_root, char *filename)
    13231297{
    1324     char *tmp;
    1325     char *command;
     1298    char *tmp = NULL;
     1299    char *command = NULL;
    13261300    int res;
    13271301
    1328     malloc_string(tmp);
    1329     malloc_string(command);
    13301302    assert(path_root != NULL);
    13311303    assert_string_is_neither_NULL_nor_zerolength(filename);
    13321304
    1333     sprintf(tmp, "%s/%s", path_root, filename);
    1334     sprintf(command, "cp -f %s %s.pristine", tmp, tmp);
     1305    mr_asprintf(&tmp, "%s/%s", path_root, filename);
     1306    mr_asprintf(&command, "cp -f %s %s.pristine", tmp, tmp);
     1307    mr_free(tmp);
    13351308
    13361309    res = run_program_and_log_output(command, 5);
    1337     paranoid_free(tmp);
    1338     paranoid_free(command);
     1310    mr_free(command);
    13391311    return (res);
    13401312}
     
    14021374    read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);
    14031375    read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
    1404     mr_asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name);
    1405     log_msg(2, tmp);
    1406     paranoid_free(tmp);
     1376    log_msg(2, "run_boot_loader: device='%s', name='%s'", device, name);
    14071377    system("sync");
    14081378
     
    14251395        mr_asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);
    14261396        if (!system(tmp)) {
    1427             paranoid_free(tmp);
     1397            mr_free(tmp);
    14281398            mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
    14291399            res = run_program_and_log_output(tmp, 3);
    14301400        } else {
    1431             log_msg(1,
    1432                     "I'm not running any boot loader. You have a DD boot drive. It's already loaded up.");
    1433         }
    1434         paranoid_free(tmp);
     1401            log_msg(1, "I'm not running any boot loader. You have a DD boot drive. It's already loaded up.");
     1402        }
     1403        mr_free(tmp);
    14351404    }
    14361405#else
     
    14931462{
    14941463  /** malloc **/
    1495     char *command;
     1464    char *command = NULL;
    14961465    char *boot_device;
    14971466    char *rootdev;
    14981467    char *rootdrive;
    14991468    char *conffile;
    1500     char *tmp;
     1469    char *tmp = NULL;
    15011470    char *editor;
    15021471
     
    15041473    int done;
    15051474
    1506     malloc_string(command);
    15071475    malloc_string(boot_device);
    1508     malloc_string(tmp);
    15091476    malloc_string(editor);
    15101477    malloc_string(rootdev);
     
    15151482    strcpy(boot_device, bd);
    15161483
    1517     if (!run_program_and_log_output("which grub-MR", FALSE)) {
    1518         log_msg(1, "Yay! grub-MR found...");
    1519         sprintf(command, "grub-MR %s /tmp/mountlist.txt", boot_device);
    1520         log_msg(1, "command = %s", command);
    1521     } else {
    1522         sprintf(command, "chroot " MNT_RESTORING " grub-install %s",
    1523                 boot_device);
    1524         log_msg(1, "WARNING - grub-MR not found; using grub-install");
    1525     }
    15261484    if (offer_to_run_stabgrub
    15271485        && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?"))
     
    15351493                                 "Please confirm/enter the boot device. If in doubt, try /dev/hda",
    15361494                                 boot_device, MAX_STR_LEN / 4);
    1537             sprintf(command, "stabgrub-me %s", boot_device);
     1495            mr_asprintf(&command, "stabgrub-me %s", boot_device);
    15381496            res = run_program_and_log_output(command, 1);
     1497            mr_free(command);
     1498
    15391499            if (res) {
    15401500                popup_and_OK
     
    15511511                newtSuspend();
    15521512            }
    1553             sprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
     1513            mr_asprintf(&tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
    15541514            paranoid_system(tmp);
    1555             sprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
     1515            mr_free(tmp);
     1516
     1517            mr_asprintf(&tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
    15561518            paranoid_system(tmp);
    1557             sprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
     1519            mr_free(tmp);
     1520
     1521            mr_asprintf(&tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
    15581522            paranoid_system(tmp);
    1559             sprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
     1523            mr_free(tmp);
     1524
     1525            mr_asprintf(&tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
    15601526            paranoid_system(tmp);
     1527            mr_free(tmp);
     1528
    15611529            if (!g_text_mode) {
    15621530                newtResume();
     
    15661534        /* nuke mode */
    15671535    {
     1536        if (!run_program_and_log_output("which grub-MR", FALSE)) {
     1537            log_msg(1, "Yay! grub-MR found...");
     1538            mr_asprintf(&command, "grub-MR %s /tmp/mountlist.txt", boot_device);
     1539            log_msg(1, "command = %s", command);
     1540        } else {
     1541            mr_asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", boot_device);
     1542            log_msg(1, "WARNING - grub-MR not found; using grub-install");
     1543        }
    15681544        mvaddstr_and_log_it(g_currentY,
    15691545                            0,
     
    15711547        log_it("%s",command);
    15721548        res = run_program_and_log_output(command, 1);
     1549        mr_free(command);
     1550
    15731551        if (res) {
    15741552            popup_and_OK
     
    15991577    paranoid_free(rootdrive);
    16001578    paranoid_free(conffile);
    1601     paranoid_free(command);
    16021579    paranoid_free(boot_device);
    1603     paranoid_free(tmp);
    16041580    paranoid_free(editor);
    16051581
     
    16201596{
    16211597  /** malloc **/
    1622     char *command;
    1623     char *tmp;
     1598    char *command = NULL;
     1599    char *tmp = NULL;
    16241600    char *editor;
    16251601
     
    16271603    int done;
    16281604
    1629     malloc_string(command);
    1630     malloc_string(tmp);
    16311605    malloc_string(editor);
    16321606    strcpy(editor, find_my_editor());
     
    16391613                            0,
    16401614                            "Modifying fstab and elilo.conf...                             ");
    1641         sprintf(command, "stabelilo-me");
     1615        mr_asprintf(&command, "stabelilo-me");
    16421616        res = run_program_and_log_output(command, 3);
     1617        mr_free(command);
     1618
    16431619        if (res) {
    16441620            popup_and_OK
     
    16481624                    newtSuspend();
    16491625                }
    1650                 sprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
     1626                mr_asprintf(&tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
    16511627                paranoid_system(tmp);
    1652                 sprintf(tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor);
     1628                mr_free(tmp);
     1629
     1630                mr_asprintf(&tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor);
    16531631                paranoid_system(tmp);
     1632                mr_free(tmp);
     1633
    16541634                if (!g_text_mode) {
    16551635                    newtResume();
     
    16691649        res = TRUE;
    16701650    }
    1671     paranoid_free(command);
    1672     paranoid_free(tmp);
    16731651    paranoid_free(editor);
    16741652    return (res);
     
    16881666{
    16891667  /** malloc **/
    1690     char *command;
    1691     char *tmp;
     1668    char *command = NULL;
     1669    char *tmp = NULL;
    16921670    char *editor;
    16931671
     
    16951673    int done;
    16961674    bool run_lilo_M = FALSE;
    1697     malloc_string(command);
    1698     malloc_string(tmp);
    16991675    malloc_string(editor);
    17001676
     
    17131689                            0,
    17141690                            "Modifying fstab and lilo.conf, and running LILO...                             ");
    1715         sprintf(command, "stablilo-me");
     1691        mr_asprintf(&command, "stablilo-me");
    17161692        res = run_program_and_log_output(command, 3);
     1693        mr_free(command);
     1694
    17171695        if (res) {
    17181696            popup_and_OK
     
    17221700                    newtSuspend();
    17231701                }
    1724                 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1702                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    17251703                paranoid_system(tmp);
    1726                 sprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
     1704                mr_free(tmp);
     1705
     1706                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
    17271707                paranoid_system(tmp);
     1708                mr_free(tmp);
     1709
    17281710                if (!g_text_mode) {
    17291711                    newtResume();
     
    17801762                                   " lilo -M /dev/sda", 3);
    17811763    }
    1782     paranoid_free(command);
    1783     paranoid_free(tmp);
    17841764    paranoid_free(editor);
    17851765    return (res);
     
    18001780{
    18011781  /** malloc **/
    1802     char *command;
     1782    char *command = NULL;
    18031783    char *boot_device;
    1804     char *tmp;
     1784    char *tmp = NULL;
    18051785    char *editor;
    18061786    int res;
    18071787    int done;
    18081788
    1809     malloc_string(command);
    18101789    malloc_string(boot_device);
    1811     malloc_string(tmp);
    18121790    malloc_string(editor);
    18131791    assert_string_is_neither_NULL_nor_zerolength(bd);
     
    18151793    strcpy(editor, find_my_editor());
    18161794    strcpy(boot_device, bd);
    1817     sprintf(command, "raw-MR %s /tmp/mountlist.txt", boot_device);
    1818     log_msg(2, "run_raw_mbr() --- command='%s'", command);
    18191795
    18201796    if (offer_to_hack_scripts
     
    18301806                    newtSuspend();
    18311807                }
    1832                 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1808                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    18331809                paranoid_system(tmp);
     1810                mr_free(tmp);
    18341811                if (!g_text_mode) {
    18351812                    newtResume();
    18361813                }
    1837 //              newtCls();
    18381814            }
    18391815            popup_and_get_string("Boot device",
    18401816                                 "Please confirm/enter the boot device. If in doubt, try /dev/hda",
    18411817                                 boot_device, MAX_STR_LEN / 4);
    1842             sprintf(command, "stabraw-me %s", boot_device);
     1818            mr_asprintf(&command, "stabraw-me %s", boot_device);
    18431819            res = run_program_and_log_output(command, 3);
     1820            mr_free(command);
     1821
    18441822            if (res) {
    18451823                done = ask_me_yes_or_no("Modifications failed. Re-try?");
     
    18511829        /* nuke mode */
    18521830    {
     1831        mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", boot_device);
     1832        log_msg(2, "run_raw_mbr() --- command='%s'", command);
     1833
    18531834        mvaddstr_and_log_it(g_currentY, 0,
    18541835                            "Restoring MBR...                                               ");
    18551836        res = run_program_and_log_output(command, 3);
    1856     }
     1837        mr_free(command);
     1838    }
     1839
    18571840    if (res) {
    18581841        mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
     
    18621845        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    18631846    }
    1864     paranoid_free(command);
    18651847    paranoid_free(boot_device);
    1866     paranoid_free(tmp);
    18671848    paranoid_free(editor);
    18681849    return (res);
     
    18941875    malloc_string(g_mountlist_fname);
    18951876    malloc_string(g_mondo_home);
    1896     /*
    1897     malloc_string(g_tmpfs_mountpt);
    1898     */
    18991877    malloc_string(g_isodir_device);
    19001878    malloc_string(g_isodir_format);
     
    19051883    sprintf(g_filelist_full, "%s/%s", temppath, FILELIST_FULL_STUB);
    19061884    sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", temppath);
    1907 //  sprintf(g_imagedevs_pot, "%s/tmp/imagedevs.pot", temppath);
    1908     sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these",
    1909             temppath);
     1885    sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", temppath);
    19101886    if (bkpinfo->disaster_recovery) {
    19111887        sprintf(g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB);
     
    19131889    } else {
    19141890        sprintf(g_mondo_cfg_file, "%s/%s", temppath, MONDO_CFG_FILE_STUB);
    1915         sprintf(g_mountlist_fname, "%s/%s", temppath,
    1916                 MOUNTLIST_FNAME_STUB);
     1891        sprintf(g_mountlist_fname, "%s/%s", temppath, MOUNTLIST_FNAME_STUB);
    19171892    }
    19181893}
     
    19751950    int i;
    19761951    /* MALLOC * */
    1977     char *tmp;
    1978 
    1979     malloc_string(tmp);
     1952    char *tmp = NULL;
     1953
    19801954    if (does_file_exist("/tmp/NOPAUSE")) {
    19811955        return;
     
    19871961    for (i = 0; i < 20; i++) {
    19881962        g_current_progress = i;
    1989         sprintf(tmp, "You have %d seconds left to abort.", 20 - i);
     1963        mr_asprintf(&tmp, "You have %d seconds left to abort.", 20 - i);
    19901964        update_progress_form(tmp);
     1965        mr_free(tmp);
    19911966        sleep(1);
    19921967    }
    19931968    close_progress_form();
    1994     paranoid_free(tmp);
    19951969}
    19961970
     
    20101984    struct mountlist_itself *mountlist;
    20111985    int retval = 0, lino, res = 0, i;
    2012     char *command;
     1986    char *command = NULL;
    20131987    char *tmp = NULL;
    20141988
    2015     malloc_string(command);
    20161989    assert(p_external_copy_of_mountlist != NULL);
    20171990
     
    20652038        if (is_this_device_mounted(mountlist->el[lino].device)) {
    20662039            if (!strcmp(mountlist->el[lino].mountpoint, "swap")) {
    2067                 sprintf(command, "swapoff %s", mountlist->el[lino].device);
     2040                mr_asprintf(&command, "swapoff %s", mountlist->el[lino].device);
    20682041            } else {
    20692042                if (!strcmp(mountlist->el[lino].mountpoint, "/1")) {
    2070                     sprintf(command, "umount %s/", MNT_RESTORING);
     2043                    mr_asprintf(&command, "umount %s/", MNT_RESTORING);
    20712044                    log_msg(3,
    20722045                            "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight...");
    20732046                } else {
    2074                     sprintf(command, "umount " MNT_RESTORING "%s",
     2047                    mr_asprintf(&command, "umount " MNT_RESTORING "%s",
    20752048                            mountlist->el[lino].mountpoint);
    20762049
     
    20862059            log_msg(10, "The 'umount' command is '%s'", command);
    20872060            res = run_program_and_log_output(command, 3);
     2061            mr_free(command);
    20882062        } else {
    20892063            mr_strcat(tmp, "...not mounted anyway :-) OK");
     
    21122086    }
    21132087    free(mountlist);
    2114     paranoid_free(command);
    21152088    return (retval);
    21162089}
     
    21302103int extract_cfg_file_and_mountlist_from_tape_dev(char *dev)
    21312104{
    2132     char *command;
     2105    char *command = NULL;
    21332106    int res = 0;
    2134 
    2135     malloc_string(command);
    21362107
    21372108    if (bkpinfo->use_obdr) {
     
    21422113    }
    21432114
    2144     sprintf(command,
     2115    mr_asprintf(&command,
    21452116            "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s",
    21462117            dev,
     
    21512122    log_msg(2, "command = '%s'", command);
    21522123    res = run_program_and_log_output(command, -1);
     2124    mr_free(command);
     2125
    21532126    if (res != 0) {
    21542127        if (does_file_exist(MONDO_CFG_FILE_STUB)) {
     
    21572130            /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    21582131            log_msg(2, "pre-2.2.4 compatible mode on");
    2159             sprintf(command,
     2132            mr_asprintf(&command,
    21602133                    "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s",
    21612134                    dev,
     
    21662139            log_msg(2, "command = '%s'", command);
    21672140            res = run_program_and_log_output(command, -1);
     2141            mr_free(command);
     2142
    21682143            if ((res != 0) && (does_file_exist(MONDO_CFG_FILE_STUB))) {
    21692144                res = 0;
     
    21712146        }
    21722147    }
    2173     paranoid_free(command);
    21742148    return (res);
    21752149}
     
    21912165   /** malloc *****/
    21922166    char *device;
    2193     char *command;
    2194     char *cfg_file;
     2167    char *command = NULL;
     2168    char *cfg_file = NULL;
    21952169    char *mounted_cfgf_path;
    2196     char *tmp;
    2197     char *mountpt;
     2170    char *tmp = NULL;
     2171    char *mountpt = NULL;
    21982172    char *ramdisk_fname;
    2199     char *mountlist_file;
     2173    char *mountlist_file = NULL;
    22002174    bool extract_mountlist_stub = FALSE;
    22012175    bool extract_i_want_my_lvm = FALSE;
     
    22042178
    22052179    assert(bkpinfo != NULL);
    2206     malloc_string(cfg_file);
    22072180    malloc_string(mounted_cfgf_path);
    2208     malloc_string(mountpt);
    22092181    malloc_string(ramdisk_fname);
    2210     malloc_string(mountlist_file);
    22112182    malloc_string(device);
    2212     malloc_string(command);
    2213     malloc_string(tmp);
    22142183    log_msg(2, "gcffa --- starting");
    22152184    log_to_screen("I'm thinking...");
    2216     sprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
     2185    mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
    22172186    device[0] = '\0';
    22182187    chdir(bkpinfo->tmpdir);
    2219     strcpy(cfg_file, MONDO_CFG_FILE_STUB);
     2188    mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB);
    22202189    unlink(cfg_file);           // cfg_file[] is missing the '/' at the start, FYI, by intent
     2190    mr_free(cfg_file);
     2191
    22212192    unlink(FILELIST_FULL_STUB);
    22222193    unlink(BIGGIELIST_TXT_STUB);
    2223     sprintf(command, "mkdir -p %s", mountpt);
     2194    mr_asprintf(&command, "mkdir -p %s", mountpt);
    22242195    run_program_and_log_output(command, FALSE);
    2225 
    2226     sprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
    2227     sprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    2228     //   make_hole_for_file( cfg_file );
    2229     //   make_hole_for_file( mountlist_file);
     2196    mr_free(command);
     2197
     2198    mr_asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
     2199    mr_asprintf(^mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    22302200    log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file);
     2201    mr_free(mountpt);
    22312202
    22322203    if (!does_file_exist(cfg_file)) {
     
    22562227                log_msg(2, "media_device is blank; assuming %s");
    22572228            }
    2258             strcpy(tmp, bkpinfo->media_device);
     2229            mr_asprintf(&tmp, bkpinfo->media_device);
    22592230            if (extract_cfg_file_and_mountlist_from_tape_dev
    22602231                (bkpinfo->media_device)) {
     
    22752246                }
    22762247            }
     2248            mr_free(tmp);
    22772249
    22782250            if (!does_file_exist("tmp/mondo-restore.cfg")) {
     
    22942266                log_msg(2,
    22952267                        "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz");
    2296                 sprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);    // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
     2268                mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);   // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
    22972269                run_program_and_log_output(command, TRUE);
     2270                mr_free(command);
     2271
    22982272                if (!does_file_exist(MONDO_CFG_FILE_STUB)) {
    22992273                    /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    23002274                    log_msg(2, "pre-2.2.4 compatible mode on");
    2301                     sprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);  // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
     2275                    mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
    23022276                    run_program_and_log_output(command, TRUE);
     2277                    mr_free(command);
     2278
    23032279                    if (!does_file_exist(MONDO_CFG_FILE_STUB)) {
    23042280                        fatal_error
     
    23102286    if (does_file_exist(MONDO_CFG_FILE_STUB)) {
    23112287        log_msg(1, "gcffa --- great! We've got the config file");
    2312         sprintf(tmp, "%s/%s",
    2313                 call_program_and_get_last_line_of_output("pwd"),
    2314                 MONDO_CFG_FILE_STUB);
    2315         sprintf(command, "cp -f %s %s", tmp, cfg_file);
     2288        mr_asprintf(&tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB);
     2289        mr_asprintf(&command, "cp -f %s %s", tmp, cfg_file);
    23162290        log_it("%s",command);
    2317         if (strcmp(tmp, cfg_file)
    2318             && run_program_and_log_output(command, 1)) {
    2319             log_msg(1,
    2320                     "... but an error occurred when I tried to move it to %s",
    2321                     cfg_file);
     2291        if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) {
     2292            log_msg(1, "... but an error occurred when I tried to move it to %s", cfg_file);
    23222293        } else {
    23232294            log_msg(1, "... and I moved it successfully to %s", cfg_file);
    23242295        }
    2325         sprintf(command, "cp -f %s/%s %s",
    2326             call_program_and_get_last_line_of_output("pwd"),
     2296        mr_free(command);
     2297
     2298        mr_asprintf(&command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"),
    23272299            MOUNTLIST_FNAME_STUB, mountlist_file);
    23282300        log_it("%s",command);
    23292301        if (extract_mountlist_stub) {
    2330             if (strcmp(tmp, cfg_file)
    2331                 && run_program_and_log_output(command, 1)) {
     2302            if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) {
    23322303                log_msg(1, "Failed to get mountlist");
    23332304            } else {
    23342305                log_msg(1, "Got mountlist too");
    2335                 sprintf(command, "cp -f %s %s", mountlist_file,
    2336                         g_mountlist_fname);
     2306
     2307                mr_free(command);
     2308                mr_asprintf(&command, "cp -f %s %s", mountlist_file, g_mountlist_fname);
    23372309                if (run_program_and_log_output(command, 1)) {
    23382310                    log_msg(1, "Failed to copy mountlist to /tmp");
    23392311                } else {
    23402312                    log_msg(1, "Copied mountlist to /tmp as well OK");
    2341                     sprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
     2313                    mr_free(command);
     2314                    mr_asprintf(&command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
    23422315                    run_program_and_log_output(command, 1);
    23432316                }
    23442317            }
    23452318        }
     2319        mr_free(tmp);
     2320        mr_free(command);
    23462321    }
    23472322    run_program_and_log_output("umount " MNT_CDROM, FALSE);
     
    23612336            /* Is this code really useful ??? */
    23622337        if (extract_mountlist_stub) {
    2363             sprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,
     2338            mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,
    23642339                    bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    23652340            run_program_and_log_output(command, FALSE);
    2366         }
    2367     }
    2368 
    2369     sprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
     2341            mr_free(command);
     2342        }
     2343    }
     2344
     2345    mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
     2346    mr_free(cfg_file);
     2347
    23702348    run_program_and_log_output(command, FALSE);
     2349    mr_free(command);
     2350
    23712351    if (extract_mountlist_stub) {
    2372         sprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
     2352        mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
    23732353        run_program_and_log_output(command, FALSE);
    2374     }
    2375     sprintf(command, "cp -f etc/raidtab /etc/");
     2354        mr_free(command);
     2355    }
     2356    mr_free(mountlist_file);
     2357
     2358    mr_asprintf(&command, "cp -f etc/raidtab /etc/");
    23762359    run_program_and_log_output(command, FALSE);
     2360    mr_free(command);
     2361
    23772362    if (extract_i_want_my_lvm) {
    2378         sprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
     2363        mr_asprintf(&command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
    23792364        run_program_and_log_output(command, FALSE);
     2365        mr_free(command);
    23802366    }
    23812367    g_backup_media_type = bkpinfo->backup_media_type;
    23822368    paranoid_free(device);
    2383     paranoid_free(command);
    2384     paranoid_free(tmp);
    2385     paranoid_free(cfg_file);
    23862369    paranoid_free(mounted_cfgf_path);
    2387     paranoid_free(mountpt);
    23882370    paranoid_free(ramdisk_fname);
    2389     paranoid_free(mountlist_file);
    23902371    return (retval);
    23912372}
     
    24162397    struct raidlist_itself *raidlist;
    24172398    int unfinished_mdstat_devices = 9999, i;
    2418     char *screen_message;
    2419 
    2420     malloc_string(screen_message);
     2399    char *screen_message = NULL;
     2400
    24212401    raidlist = malloc(sizeof(struct raidlist_itself));
    24222402
     
    24382418                }
    24392419                log_msg(1,"Sync'ing %s (i=%d)", raidlist->el[i].raid_device, i);
    2440                 sprintf(screen_message, "Sync'ing %s",
    2441                         raidlist->el[i].raid_device);
     2420                mr_asprintf(&screen_message, "Sync'ing %s", raidlist->el[i].raid_device);
    24422421                open_evalcall_form(screen_message);
     2422                mr_free(screen_message);
     2423
    24432424                while (raidlist->el[i].progress < wait_for_percentage) {
    24442425                    log_msg(1,"Percentage sync'ed: %d", raidlist->el[i].progress);
     
    24542435        }
    24552436    }
    2456     paranoid_free(screen_message);
    24572437    paranoid_free(raidlist);
    24582438}
Note: See TracChangeset for help on using the changeset viewer.