Changeset 2334 in MondoRescue


Ignore:
Timestamp:
Aug 18, 2009, 5:28:18 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3369@localhost: bruno | 2009-08-18 16:57:27 +0200

  • Transform bout 100 strcpy in dyn. allocation. Quality is improving
  • function figure_out_kernel_path_interactively_if_necessary now return a dynamically allocated string
  • mondoarchive checked with valgrind in text an newt modes
Location:
branches/2.2.10
Files:
25 edited

Legend:

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

    r1885 r2334  
    1010extern int do_that_initial_phase();
    1111extern int do_that_final_phase();
    12 extern int figure_out_kernel_path_interactively_if_necessary(char *kernel);
     12extern char *figure_out_kernel_path_interactively_if_necessary(void);
    1313extern int make_those_slices_phase();
    1414extern int make_those_afios_phase();
  • branches/2.2.10/mondo/src/common/libmondo-archive.c

    r2331 r2334  
    441441
    442442    copy_mondo_and_mindi_stuff_to_scratchdir(); // payload, too, if it exists
     443    mr_free(bkpinfo->kernel_path);
    443444#if __FreeBSD__ == 5
    444445    mr_asprintf(bkpinfo->kernel_path, "/boot/kernel/kernel");
     
    446447    mr_asprintf(bkpinfo->kernel_path, "/kernel");
    447448#elif linux
    448     if (figure_out_kernel_path_interactively_if_necessary(bkpinfo->kernel_path)) {
     449    if ((bkpinfo->kernel_path = figure_out_kernel_path_interactively_if_necessary()) == NULL) {
    449450        fatal_error("Kernel not found. Please specify manually with the '-k' switch.");
    450451    }
     
    854855            use_gzip_sz);       // parameter #20 (STRING)
    855856
     857    mr_free(tmp2);
    856858    mr_free(devs_to_exclude);
    857859    mr_free(last_filelist_number);
  • branches/2.2.10/mondo/src/common/libmondo-archive.h

    r1885 r2334  
    1111int do_that_initial_phase();
    1212int do_that_final_phase();
    13 int figure_out_kernel_path_interactively_if_necessary(char *kernel);
     13char *figure_out_kernel_path_interactively_if_necessary(void);
    1414bool get_bit_N_of_array(char *array, int N);
    1515int make_those_slices_phase();
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2332 r2334  
    886886    if ((flag_set['t'] && !flag_set['d']) && (! bkpinfo->restore_data)) {
    887887        log_it("Hmm! No tape drive specified. Let's see what we can do.");
    888         if ((tmp1 = find_tape_device_and_size(NULL)) == NULL) {
     888        if ((tmp1 = mr_find_tape_device()) == NULL) {
    889889            fatal_error("Tape device not specified. I couldn't find it either.");
    890890        }
     
    11911191
    11921192    if (flag_set['x']) {
    1193         mr_asprintf(bkpinfo->image_devs, flag_val['x']);
     1193        mr_asprintf(bkpinfo->image_devs, "%s", flag_val['x']);
    11941194        if ((run_program_and_log_output("which ntfsclone", 2)) && (! bkpinfo->restore_data)) {
    11951195            fatal_error("Please install ntfsprogs package/tarball.");
     
    12021202
    12031203    if ((flag_set['k']) && (! bkpinfo->restore_data)) {
     1204        mr_free(bkpinfo->kernel_path);
    12041205        mr_asprintf(bkpinfo->kernel_path, "%s", flag_val['k']);
    12051206        if (!strcmp(bkpinfo->kernel_path, "failsafe")) {
     
    15521553    case SIGKILL:
    15531554        mr_asprintf(tmp, "SIGKILL");
    1554         mr_asprintf(tmp2,
    1555                "I seriously have no clue how this signal even got to me. Something's wrong with your system.");
     1555        mr_asprintf(tmp2, "I seriously have no clue how this signal even got to me. Something's wrong with your system.");
    15561556        break;
    15571557    case SIGTERM:
     
    15651565    case SIGSEGV:
    15661566        mr_asprintf(tmp, "SIGSEGV");
    1567         mr_asprintf(tmp2,
    1568                "Internal programming error. Please send a backtrace as well as your log.");
     1567        mr_asprintf(tmp2, "Internal programming error. Please send a backtrace as well as your log.");
    15691568        break;
    15701569    case SIGPIPE:
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2332 r2334  
    131131    mr_free(tmp);
    132132
    133     if (is_this_a_ramdisk) {
    134         if (!does_file_exist("/THIS-IS-A-RAMDISK")) {
    135             log_to_screen("Using /dev/root is stupid of you but I'll forgive you.");
    136             is_this_a_ramdisk = FALSE;
    137         }
    138     }
    139     if (does_file_exist("/THIS-IS-A-RAMDISK")) {
    140         is_this_a_ramdisk = TRUE;
    141     }
    142133    log_msg(1, "Is this a ramdisk? result = %s", (is_this_a_ramdisk) ? "TRUE" : "FALSE");
    143134    return (is_this_a_ramdisk);
     
    515506
    516507    if (g_cdrw_drive_is_here[0]) {
    517         mr_asprintf(cdrw_device, g_cdrw_drive_is_here);
     508        mr_asprintf(cdrw_device, "%s", g_cdrw_drive_is_here);
    518509        log_msg(3, "Been there, done that. Returning %s", cdrw_device);
    519510        return(cdrw_device);
     
    840831
    841832    if (g_dvd_drive_is_here[0]) {
    842         mr_asprintf(output, g_dvd_drive_is_here);
     833        mr_asprintf(output, "%s", g_dvd_drive_is_here);
    843834        log_msg(3, "Been there, done that. Returning %s", output);
    844835        return (output);
     
    15991590
    16001591        mr_free(bkpinfo->media_device);
    1601         if ((!bkpinfo->restore_mode) && ((bkpinfo->media_device = find_tape_device_and_size(NULL)) == NULL)) {
     1592        if ((!bkpinfo->restore_mode) && ((bkpinfo->media_device = mr_find_tape_device()) == NULL)) {
    16021593            log_msg(3, "Ok, using vanilla scsi tape.");
    16031594            mr_asprintf(bkpinfo->media_device, "%s", VANILLA_SCSI_TAPE);
     
    16411632        mr_free(tmp);
    16421633
    1643         bkpinfo->use_obdr = ask_me_yes_or_no
    1644             ("Do you want to activate OBDR support for your tapes ?");
     1634        bkpinfo->use_obdr = ask_me_yes_or_no("Do you want to activate OBDR support for your tapes ?");
    16451635        bkpinfo->media_size[0] = 0;
    16461636        log_msg(4, "media_size[0] = %ld", bkpinfo->media_size[0]);
  • branches/2.2.10/mondo/src/common/libmondo-files-EXT.h

    r2325 r2334  
    1111extern bool does_file_exist(char *filename);
    1212extern void exclude_nonexistent_files(char *inout);
    13 extern int figure_out_kernel_path_interactively_if_necessary(char *kernel);
     13extern char *figure_out_kernel_path_interactively_if_necessary(void);
    1414extern char *find_home_of_exe(char *fname);
    1515extern int get_trackno_from_logfile(char *logfile);
  • branches/2.2.10/mondo/src/common/libmondo-files.c

    r2332 r2334  
    269269 * @return 0 for success, 1 for failure.
    270270 */
    271 int figure_out_kernel_path_interactively_if_necessary(char *kernel)
    272 {
     271char *figure_out_kernel_path_interactively_if_necessary(void) {
     272
    273273    char *tmp = NULL;
    274274    char *command = NULL;;
    275 
    276     if (kernel == NULL) {
    277         mr_asprintf(kernel, "%s", call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null"));
    278     }
     275    char *kernel = NULL;;
     276
     277    mr_asprintf(kernel, "%s", call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null"));
     278   
    279279    // If we didn't get anything back, check whether mindi raised a fatal error
    280280    if (!kernel[0]) {
     
    285285            mr_free(tmp);
    286286            mr_free(command);
     287            mr_free(kernel);
    287288            fatal_error("Mindi gave a fatal error. Please check '/var/log/mindi.log'.");
    288289        }
     
    293294    while (!kernel[0]) {
    294295        if (!ask_me_yes_or_no("Kernel not found or invalid. Choose another?")) {
    295             return (1);
     296            return (NULL);
    296297        }
    297298        tmp = popup_and_get_string("Kernel path", "What is the full path and filename of your kernel, please?", kernel);
     
    304305        log_it("User says kernel is at %s", kernel);
    305306    }
    306     return (0);
     307    return (kernel);
    307308}
    308309
     
    11031104    }
    11041105    *(p++) = '\0';
    1105     mr_asprintf(nfs_server_ipaddr, tmp);
    1106     mr_asprintf(nfs_mount, p);
     1106    mr_asprintf(nfs_server_ipaddr, "%s", tmp);
     1107    mr_asprintf(nfs_mount, "%s", p);
    11071108    mr_free(tmp);
    11081109
     
    11511152        mr_free(nfs_dev);
    11521153
    1153         mr_asprintf(nfs_dev, call_program_and_get_last_line_of_output(command));
     1154        mr_asprintf(nfs_dev, "%s", call_program_and_get_last_line_of_output(command));
    11541155        mr_free(command);
    11551156
  • branches/2.2.10/mondo/src/common/libmondo-files.h

    r2325 r2334  
    1414bool does_file_exist(char *filename);
    1515void exclude_nonexistent_files(char *inout);
    16 int figure_out_kernel_path_interactively_if_necessary(char *kernel);
     16char *figure_out_kernel_path_interactively_if_necessary(void);
    1717char *find_home_of_exe(char *fname);
    1818int get_trackno_from_logfile(char *logfile);
  • branches/2.2.10/mondo/src/common/libmondo-raid.c

    r2324 r2334  
    334334#ifdef __FreeBSD__
    335335    int i, j;
     336    char *org = NULL;
    336337
    337338    fprintf(fout, "\nvolume %s\n", raidrec->volname);
    338339    for (i = 0; i < raidrec->plexes; ++i) {
    339         char org[24];
    340340        switch (raidrec->plex[i].raidlevel) {
    341341        case -1:
    342             strcpy(org, "concat");
     342            mr_asprintf(org, "concat");
    343343            break;
    344344        case 0:
    345             strcpy(org, "striped");
     345            mr_asprintf(org, "striped");
    346346            break;
    347347        case 5:
    348             strcpy(org, "raid5");
     348            mr_asprintf(org, "raid5");
    349349            break;
    350350        }
    351351        fprintf(fout, "  plex org %s", org);
     352        mr_free(org);
     353
    352354        if (raidrec->plex[i].raidlevel != -1) {
    353355            fprintf(fout, " %ik", raidrec->plex[i].stripesize);
     
    356358
    357359        for (j = 0; j < raidrec->plex[i].subdisks; ++j) {
    358             fprintf(fout, "    sd drive %s size 0\n",
    359                     raidrec->plex[i].sd[j].which_device);
     360            fprintf(fout, "    sd drive %s size 0\n", raidrec->plex[i].sd[j].which_device);
    360361        }
    361362    }
     
    501502
    502503            if (get_option_state(argc, argv, "hotspare")) {
    503                 strcpy(raidlist->spares.el[raidlist->spares.entries].name,
    504                        drivename);
    505                 strcpy(raidlist->spares.el[raidlist->spares.entries].
    506                        device, devname);
     504                strcpy(raidlist->spares.el[raidlist->spares.entries].name, drivename);
     505                strcpy(raidlist->spares.el[raidlist->spares.entries].  device, devname);
    507506                raidlist->spares.el[raidlist->spares.entries].index =
    508507                    raidlist->disks.entries;
    509508                raidlist->spares.entries++;
    510509            } else {
    511                 strcpy(raidlist->disks.el[raidlist->disks.entries].name,
    512                        drivename);
    513                 strcpy(raidlist->disks.el[raidlist->disks.entries].device,
    514                        devname);
     510                strcpy(raidlist->disks.el[raidlist->disks.entries].name, drivename);
     511                strcpy(raidlist->disks.el[raidlist->disks.entries].device, devname);
    515512                raidlist->disks.el[raidlist->disks.entries].index =
    516513                    raidlist->disks.entries;
  • branches/2.2.10/mondo/src/common/libmondo-stream-EXT.h

    r2332 r2334  
    55extern int closein_tape();
    66extern int closeout_tape();
    7 extern char *find_tape_device_and_size(char *siz);
     7extern char *mr_find_tape_device(void);
    88extern void insist_on_this_tape_number(int tapeno);
    99extern void log_tape_pos(void);
  • branches/2.2.10/mondo/src/common/libmondo-stream.c

    r2332 r2334  
    253253    char *dev = NULL;
    254254    int res;
    255     char *dev = NULL;
    256255
    257256    log_to_screen("I am looking for your tape streamer. Please wait.");
     
    260259    if (tmp) {
    261260        mr_asprintf(cdr_exe, "cdrecord");
    262 
    263261    } else {
    264262        mr_asprintf(cdr_exe, "dvdrecord");
     
    273271        log_it("Either too few or too many tape streamers for me to detect...");
    274272        mr_asprintf(dev, "%s", VANILLA_SCSI_TAPE);
    275         mr_free(tmp);
    276273        mr_free(tmp);
    277274        return(dev);
     
    350347    } else {
    351348        log_it("At this new point, dev is NULL and res = %d", res);
    352         mr_free(tmp);
    353349    }
    354350
     
    531527    char *tmpdir = NULL;
    532528    char *old_fname = NULL;
    533     char *p;
    534     char suffix[16];
    535529
    536530    bufsize_K = (long long) (1024LL * (1 + g_tape_buffer_size_MB));
    537     if ((p = strrchr(latest_fname, '.'))) {
    538         strcpy(suffix, ++p);
    539     } else {
    540         suffix[0] = '\0';
    541     }
    542531    if (strstr(latest_fname, ".afio.") || strstr(latest_fname, ".star.")) {
    543532        type = fileset;
     
    11861175                  g_tape_stream) / 1024;
    11871176    }
    1188 /*  memcpy((char*)plength_of_incoming_file,(char*)tempblock+7001,sizeof(long long)); */
    1189 /*  for(*plen=0,i=7;i>=0;i--) {*plen<<=8; *plen |= tempblock[7001+i];} */
    11901177    memcpy((char *) plen, tempblock + 7001, sizeof(long long));
    11911178    if (strcmp(tempblock + 6000 + *pcontrol_char, STR_HEADER)) {
     
    11931180    }
    11941181    strcpy(filename, tempblock + 1000);
    1195 /*  strcpy(cksum,tempblock+5555);*/
    1196 /*  log_it( "%s  (reading) fname=%s, filesize=%ld K",
    1197        marker_to_string (*pcontrol_char), filename,
    1198        (long) ((*plen) >> 10));
    1199 */
    12001182    if (*pcontrol_char == BLK_ABORTED_BACKUP) {
    12011183        log_to_screen("I can't verify an aborted backup.");
  • branches/2.2.10/mondo/src/common/libmondo-stream.h

    r2332 r2334  
    77int closein_tape();
    88int closeout_tape();
    9 char *find_tape_device_and_size(char *siz);
     9char *mr_find_tape_device(void);
    1010void insist_on_this_tape_number(int tapeno);
    1111void log_tape_pos(void);
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2323 r2334  
    4545    assert(partno >= 0);
    4646
    47     mr_asprintf(partition, drive);
     47    mr_asprintf(partition, "%s", drive);
    4848    /* is this a devfs device path? */
    4949    c = strrchr(partition, '/');
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2332 r2334  
    170170void clean_up_KDE_desktop_if_necessary(void)
    171171{
    172     char *tmp;
    173 
    174     malloc_string(tmp);
    175     strcpy(tmp,
    176            "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do \
    177 file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \
    178 awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } \
    179 else { print $0;};}' $file.old  > $file ; fi ; done");
     172    char *tmp = NULL;
     173
     174    mr_asprintf(tmp, "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } else { print $0;};}' $file.old  > $file ; fi ; done");
    180175    run_program_and_log_output(tmp, 5);
    181     paranoid_free(tmp);
     176    mr_free(tmp);
    182177}
    183178
     
    227222double get_kernel_version(void)
    228223{
    229     char *p, tmp[200];
     224    char *p = NULL;
     225    char *tmp = NULL;
    230226    double d;
    231227#ifdef __FreeBSD__
     
    233229    d = 5.2;                    // :-)
    234230#else
    235     strcpy(tmp, call_program_and_get_last_line_of_output("uname -r"));
     231    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("uname -r"));
    236232    p = strchr(tmp, '.');
    237233    if (p) {
     
    244240        }
    245241    }
    246 //  log_msg(1, "tmp = '%s'", tmp);
    247242    d = atof(tmp);
     243    mr_free(tmp);
    248244#endif
    249245    log_msg(1, "g_kernel_version = %f", d);
     
    252248
    253249
    254 
    255 
    256 
    257250/**
    258251 * Get the current time.
     
    263256    return (long) time((void *) 0);
    264257}
    265 
    266 
    267 
    268 
    269 
    270258
    271259
     
    411399    char *command = NULL;
    412400    char *mtpt;
    413     char *hostname;
     401    char *hostname = NULL;
    414402    char *ip_address = NULL;
    415403    int retval = 0;
    416404    char *colon;
    417     char *cdr_exe;
     405    char *cdr_exe = NULL;
    418406    char *tmp = NULL;
    419407    char *p = NULL;
     
    431419
    432420    malloc_string(mtpt);
    433     malloc_string(hostname);
    434     malloc_string(cdr_exe);
    435421    bkpinfo->optimal_set_size =
    436422        (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) *
     
    496482        tmp = find_home_of_exe("growisofs");
    497483        if (tmp) {
    498             strcpy(cdr_exe, "growisofs");
     484            mr_asprintf(cdr_exe, "growisofs");
    499485        }                       // unlikely to be used
    500486        else {
     
    560546        tmp = find_home_of_exe("cdrecord");
    561547        if (tmp) {
    562             strcpy(cdr_exe, "cdrecord");
     548            mr_asprintf(cdr_exe, "cdrecord");
    563549        } else {
    564550            mr_free(tmp);
    565551            tmp = find_home_of_exe("dvdrecord");
    566552            if (tmp) {
    567                 strcpy(cdr_exe, "dvdrecord");
     553                mr_asprintf(cdr_exe, "dvdrecord");
    568554            } else {
    569555                mr_free(tmp);
     
    590576    }
    591577#endif
    592         else
    593         {
     578        else {
    594579            mr_asprintf(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);
    595580        }
     
    613598            mr_asprintf(bkpinfo->call_make_iso, "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -", mondo_mkisofs_sz, cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject", extra_cdrom_params, bkpinfo->media_device, bkpinfo->cdrw_speed);
    614599        }
     600        mr_free(cdr_exe);
    615601        paranoid_free(mondo_mkisofs_sz);
    616602        paranoid_free(extra_cdrom_params);
     
    654640            mr_asprintf(iso_path, "%s", iso_tmp + strlen(iso_mnt));
    655641        }
     642        mr_free(iso_mnt);
    656643        mr_free(iso_tmp);
    657644
     
    674661    if (bkpinfo->backup_media_type == nfs) {
    675662        if (bkpinfo->nfs_mount) {
    676             strcpy(hostname, bkpinfo->nfs_mount);
     663            mr_asprintf(hostname, "%s", bkpinfo->nfs_mount);
    677664        } else {
    678665            log_it("nfs_mount is NULL");
    679666            retval++;
    680             strcpy(hostname, "");
     667            mr_asprintf(hostname, "");
    681668        }
    682669        colon = strchr(hostname, ':');
     
    699686            }
    700687        }
     688        mr_free(hostname);
    701689        store_nfs_config();
    702690    }
     
    712700    g_backup_media_type = bkpinfo->backup_media_type;
    713701    paranoid_free(mtpt);
    714     paranoid_free(hostname);
    715     paranoid_free(cdr_exe);
    716702    return (retval);
    717703}
     
    12541240    mr_asprintf(command, "mount | grep -Ew '/boot'");
    12551241    mr_free(tmp);
    1256     mr_asprintf(tmp, call_program_and_get_last_line_of_output(command));
     1242    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    12571243    mr_free(command);
    12581244
  • branches/2.2.10/mondo/src/common/libmondo-verify.c

    r2327 r2334  
    623623    /*@ char ************************************************************ */
    624624    char *test_file = NULL;
    625     char *biggie_cksum;
    626     char *orig_cksum;
     625    char *biggie_cksum = NULL;
     626    char *orig_cksum = NULL;
    627627    char *tmp = NULL;
    628628    char *slice_fnam;
     
    634634    long long slice_siz;
    635635
    636     malloc_string(biggie_cksum);
    637     malloc_string(orig_cksum);
    638636    malloc_string(slice_fnam);
    639637    assert(bkpinfo != NULL);
     
    651649         ctrl_chr != BLK_STOP_A_BIGGIE;
    652650         res =
    653          read_header_block_from_stream(&slice_siz, slice_fnam,
    654                                        &ctrl_chr)) {
     651         read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr)) {
    655652        if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    656653            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
     
    659656        unlink(test_file);
    660657        res =
    661             read_header_block_from_stream(&slice_siz, slice_fnam,
    662                                           &ctrl_chr);
     658            read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
    663659        if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
    664660            log_msg(2, "test_file = %s", test_file);
     
    668664        retval += res;
    669665    }
    670     strcpy(biggie_cksum, slice_fnam);
     666    mr_asprintf(biggie_cksum, "%s", slice_fnam);
    671667    if (biggie_cksum[0] != '\0') {
    672         strcpy(orig_cksum, calc_checksum_of_file(biggie_fname));
     668        mr_asprintf(orig_cksum, "%s", calc_checksum_of_file(biggie_fname));
    673669        if (strcmp(biggie_cksum, orig_cksum)) {
    674670            log_msg(2, "orig cksum=%s; curr cksum=%s", biggie_cksum, orig_cksum);
     
    680676        }
    681677    }
     678    mr_free(biggie_cksum);
    682679    mr_free(test_file);
    683     paranoid_free(biggie_cksum);
    684     paranoid_free(orig_cksum);
     680    mr_free(orig_cksum);
    685681    paranoid_free(slice_fnam);
    686682    return (retval);
  • branches/2.2.10/mondo/src/common/newt-specific.c

    r2331 r2334  
    345345            log_msg(0, "-------FATAL ERROR---------");
    346346            log_msg(0, error_string);
    347             newtFinished();
    348347        }
    349348
     
    395394        }
    396395        if (!g_text_mode) {
    397             if (does_file_exist("/THIS-IS-A-RAMDISK")) {
    398                 log_msg(1, "Calling newtFinished()");
    399                 newtFinished();
    400             } else {
    401                 log_msg(1, "Calling newtSuspend()");
    402                 newtSuspend();
    403             }
     396            log_msg(1, "Calling newtFinished()");
     397            newtFinished();
    404398        }
    405399        printf("Execution run ended; result=%d\n", signal);
     
    444438
    445439        /*@ buffers ********************************************************** */
    446         char *command;
    447         char *tmp;
     440        char *command = NULL;
     441        char *tmp = NULL;
    448442
    449443        /*@ pointers ********************************************************* */
     
    453447        int i = 0;
    454448
    455         malloc_string(command);
    456         malloc_string(tmp);
    457449        assert_string_is_neither_NULL_nor_zerolength(filename);
    458450        assert(grep_for_me != NULL);
    459451
    460452        if (!does_file_exist(filename)) {
    461             paranoid_free(command);
    462             paranoid_free(tmp);
    463453            return;
    464454        }
    465455        if (grep_for_me[0] != '\0') {
    466             sprintf(command, "grep '%s' %s | tail -n%d",
    467                     grep_for_me, filename, g_noof_log_lines);
    468         } else {
    469             sprintf(command, "tail -n%d %s", g_noof_log_lines,
    470                     filename);
     456            mr_asprintf(command, "grep '%s' %s | tail -n%d", grep_for_me, filename, g_noof_log_lines);
     457        } else {
     458            mr_asprintf(command, "tail -n%d %s", g_noof_log_lines, filename);
    471459        }
    472460        fin = popen(command, "r");
     
    483471                    */
    484472                    if (!strncmp(err_log_lines[i], "root:", 5)) {
    485                         strcpy(tmp, err_log_lines[i] + 6);
     473                        mr_asprintf(tmp, "%s", err_log_lines[i] + 6);
    486474                        strcpy(err_log_lines[i], tmp);
     475                        mr_free(tmp);
    487476                    }
    488477                    if (feof(fin)) {
     
    493482            paranoid_pclose(fin);
    494483        }
     484        mr_free(command);
    495485        refresh_log_screen();
    496         paranoid_free(command);
    497         paranoid_free(tmp);
    498486    }
    499487
     
    584572
    585573        /*@ buffers ********************************************************* */
    586         char *title;
    587         char *tmp;
     574        char *title = NULL;
     575        char *tmp = NULL;
    588576
    589577        /*@ initialize ****************************************************** */
    590578        g_isoform_old_progress = -1;
    591579        g_mysterious_dot_counter = 0;
    592         malloc_string(title);
     580
     581        assert(ttl != NULL);
    593582        malloc_string(tmp);
    594 
    595         assert(ttl != NULL);
    596         strcpy(title, ttl);
     583        mr_asprintf(title, "%s", ttl);
    597584        strcpy(g_isoform_header_str, title);
    598585        if (g_text_mode) {
     
    620607        }
    621608        update_evalcall_form(0);
     609        mr_free(title);
    622610        paranoid_free(tmp);
    623         paranoid_free(title);
    624611    }
    625612
     
    641628        /*@ buffers ********************************************************* */
    642629        char *b1c;
    643         char *blurb1;
    644         char *blurb2;
    645         char *blurb3;
     630        char *blurb1 = NULL;
     631        char *blurb2 = NULL;
     632        char *blurb3 = NULL;
    646633
    647634        /*@ initialize ****************************************************** */
    648635        g_mysterious_dot_counter = 0;
    649636
    650         malloc_string(b1c);
    651637        malloc_string(blurb1);
    652638        malloc_string(blurb2);
    653639        malloc_string(blurb3);
     640        malloc_string(b1c);
    654641
    655642        assert(title != NULL);
     
    658645        assert(b3 != NULL);
    659646
    660         strcpy(blurb1, b1);
    661         strcpy(blurb2, b2);
    662         strcpy(blurb3, b3);
     647        strcpy(blurb1,  b1);
     648        strcpy(blurb2,  b2);
     649        strcpy(blurb3,  b3);
    663650        strcpy(b1c, b1);
    664651        center_string(b1c, 80);
     
    695682        update_progress_form_full(blurb1, blurb2, blurb3);
    696683        paranoid_free(b1c);
    697         paranoid_free(blurb1);
    698         paranoid_free(blurb2);
    699         paranoid_free(blurb3);
     684        mr_free(blurb1);
     685        mr_free(blurb2);
     686        mr_free(blurb3);
    700687    }
    701688
     
    11761163
    11771164        /*@ newt ************************************************************ */
    1178         char *title_sz;
    1179         char *minimsg_sz;
     1165        char *title_sz = NULL;
     1166        char *minimsg_sz = NULL;
    11801167        static t_bkptype possible_bkptypes[] =
    11811168            { none, cdr, cdrw, dvd, tape, cdstream, udev, nfs, iso };
     
    11981185        newtComponent myForm;
    11991186
    1200         title_sz = malloc(MAX_NEWT_COMMENT_LEN);
    1201         minimsg_sz = malloc(MAX_NEWT_COMMENT_LEN);
    12021187        outstr = malloc(MAX_NEWT_COMMENT_LEN);
    12031188        if (g_text_mode) {
     
    12171202                }
    12181203            }
    1219             paranoid_free(title_sz);
    1220             paranoid_free(minimsg_sz);
    12211204            paranoid_free(outstr);
    12221205            return (backup_type);
     
    12241207        newtDrawRootText(18, 0, WELCOME_STRING);
    12251208        if (restoring) {
    1226             strcpy(title_sz,
    1227                    "Please choose the backup media from which you want to read data.");
    1228             strcpy(minimsg_sz, "Read from:");
    1229         } else {
    1230             strcpy(title_sz,
    1231                    "Please choose the backup media to which you want to archive data.");
    1232             strcpy(minimsg_sz, "Backup to:");
     1209            mr_asprintf(title_sz, "Please choose the backup media from which you want to read data.");
     1210            mr_asprintf(minimsg_sz, "Read from:");
     1211        } else {
     1212            mr_asprintf(title_sz, "Please choose the backup media to which you want to archive data.");
     1213            mr_asprintf(minimsg_sz, "Backup to:");
    12331214        }
    12341215        newtPushHelpLine(title_sz);
     
    12661247        }
    12671248        newtPopHelpLine();
    1268         paranoid_free(title_sz);
    1269         paranoid_free(minimsg_sz);
     1249        mr_free(title_sz);
     1250        mr_free(minimsg_sz);
    12701251        paranoid_free(outstr);
    12711252        return (output);
  • branches/2.2.10/mondo/src/include/my-stuff.h

    r2329 r2334  
    236236 */
    237237#define MAX_TAPECAT_FNAME_LEN 32
    238 
    239 //#define strcpy(y,x) strncpy(y, x, sizeof(y)-1)
    240 
    241238
    242239/**
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2331 r2334  
    192192    char *incoming;
    193193    char *command;
    194     char *lvscan_sz;
    195     char *lvremove_sz;
    196     char *pvscan_sz;
    197     char *vgscan_sz;
    198     char *vgcreate_sz;
    199     char *vgchange_sz;
    200     char *vgremove_sz;
    201 //  char *do_this_last;
     194    char *lvscan_sz = NULL;
     195    char *lvremove_sz = NULL;
     196    char *pvscan_sz = NULL;
     197    char *vgscan_sz = NULL;
     198    char *vgchange_sz = NULL;
     199    char *vgremove_sz = NULL;
    202200
    203201    /** char **************************************************/
     
    229227    malloc_string(tmp);
    230228    malloc_string(incoming);
    231     malloc_string(lvscan_sz);
    232     malloc_string(lvremove_sz);
    233     malloc_string(vgscan_sz);
    234     malloc_string(pvscan_sz);
    235     malloc_string(vgcreate_sz);
    236     malloc_string(vgchange_sz);
    237     malloc_string(vgremove_sz);
    238     command = malloc(512);
     229    command = malloc(1024);
    239230
    240231    log_it("STARTING");
     
    243234    if (tmp1)   // found it :) cool
    244235    {
    245         strcpy(lvscan_sz, "lvm lvscan");
    246         strcpy(lvremove_sz, "lvm lvremove");
    247         strcpy(vgscan_sz, "lvm vgscan");
    248         strcpy(pvscan_sz, "lvm pvscan");
    249         strcpy(vgcreate_sz, "lvm vgcreate");
    250         strcpy(vgchange_sz, "lvm vgchange");
    251         strcpy(vgremove_sz, "lvm vgremove -f");
     236        mr_asprintf(lvscan_sz, "lvm lvscan");
     237        mr_asprintf(lvremove_sz, "lvm lvremove");
     238        mr_asprintf(vgscan_sz, "lvm vgscan");
     239        mr_asprintf(pvscan_sz, "lvm pvscan");
     240        mr_asprintf(vgchange_sz, "lvm vgchange");
     241        mr_asprintf(vgremove_sz, "lvm vgremove -f");
    252242    } else {
    253         strcpy(lvscan_sz, "lvscan");
    254         strcpy(lvremove_sz, "lvremove");
    255         strcpy(vgscan_sz, "vgscan");
    256         strcpy(pvscan_sz, "pvscan");
    257         strcpy(vgcreate_sz, "vgcreate");
    258         strcpy(vgchange_sz, "vgchange");
    259         strcpy(vgremove_sz, "vgremove");
     243        mr_asprintf(lvscan_sz, "lvscan");
     244        mr_asprintf(lvremove_sz, "lvremove");
     245        mr_asprintf(vgscan_sz, "vgscan");
     246        mr_asprintf(pvscan_sz, "pvscan");
     247        mr_asprintf(vgchange_sz, "vgchange");
     248        mr_asprintf(vgremove_sz, "vgremove");
    260249    }
    261250    mr_free(tmp1);
    262251
    263252    mr_asprintf(tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz);
     253    mr_free(lvscan_sz);
     254    mr_free(lvremove_sz);
     255
    264256    run_program_and_log_output(tmp1, 5);
    265257    mr_free(tmp1);
    266258
    267259    sleep(1);
    268     sprintf(command,
    269             "for i in `%s | grep -i lvm | cut -d'\"' -f2` ; do %s -a n $i ; %s $i; echo \"Shutting down vg $i\" >> %s ; done", vgscan_sz, vgchange_sz, vgremove_sz, MONDO_LOGFILE);
     260    sprintf(command, "for i in `%s | grep -i lvm | cut -d'\"' -f2` ; do %s -a n $i ; %s $i; echo \"Shutting down vg $i\" >> %s ; done", vgscan_sz, vgchange_sz, vgremove_sz, MONDO_LOGFILE);
     261    mr_free(vgchange_sz);
     262    mr_free(vgremove_sz);
     263
    270264    run_program_and_log_output(command, 5);
    271265    if (just_erase_existing_volumes) {
     
    401395        sleep(1);
    402396    }
     397    mr_free(vgscan_sz);
     398    mr_free(pvscan_sz);
     399
    403400    paranoid_fclose(fin);
    404401    log_msg(1, "Closed i-want-my-lvm. Finished doing funky stuff.");
     
    407404    paranoid_free(incoming);
    408405    paranoid_free(command);
    409     paranoid_free(lvscan_sz);
    410     paranoid_free(lvremove_sz);
    411     paranoid_free(vgscan_sz);
    412     paranoid_free(pvscan_sz);
    413     paranoid_free(vgcreate_sz);
    414     paranoid_free(vgchange_sz);
    415     paranoid_free(vgremove_sz);
    416406    system("sync");
    417407    system("sync");
     
    829819
    830820    if (res && strstr(program, "kludge")) {
    831         mr_asprintf(&tmp, "Kludge failed; using regular mkfs.%s to format %s", format, device);
     821        mr_asprintf(tmp, "Kludge failed; using regular mkfs.%s to format %s", format, device);
    832822        mr_free(program);
    833823#ifdef __FreeBSD__
     
    895885
    896886    assert(mountlist != NULL);
    897     mr_asprintf(tmp, "format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false");
    898     log_it(tmp);
    899     mr_free(tmp);
     887    log_it("format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false");
    900888
    901889    mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions     ");
     
    14231411    /** buffers *********************************************************/
    14241412    char *device_str = NULL;
    1425     char *format;
     1413    char *format = NULL;
    14261414    char *tmp = NULL;
    14271415
     
    14301418    assert(mountlist != NULL);
    14311419    assert_string_is_neither_NULL_nor_zerolength(drivename);
    1432 
    1433     malloc_string(format);
    14341420
    14351421    log_it("Partitioning drive %s", drivename);
     
    14451431    if (!pout_to_fdisk) {
    14461432        log_to_screen("Cannot call parted2fdisk to configure %s", drivename);
    1447         paranoid_free(format);
    14481433        return (1);
    14491434    }
     
    14801465                    mr_free(command);
    14811466                    mr_free(device_str);
    1482                     paranoid_free(format);
    14831467                    return r;
    14841468                }
     
    14951479                int i, line;
    14961480
    1497                 strcpy(format, "ufs");
     1481                mr_asprintf(format, "ufs");
    14981482                partsize = 0;
    14991483                for (i = 'a'; i < 'z'; ++i) {
     
    15521536#ifdef __FreeBSD__
    15531537        if (!fbsd_part) {
    1554 #endif
    1555 
    1556             strcpy(format, mountlist->el[lino].format);
     1538            mr_free(format);
     1539#endif
     1540
     1541            mr_asprintf(format, "%s", mountlist->el[lino].format);
    15571542            partsize = mountlist->el[lino].size;
    15581543
     
    15661551                ("You must leave at least one partition spare as the Extended partition.");
    15671552            mr_free(device_str);
    1568             paranoid_free(format);
     1553            mr_free(format);
    15691554            return (1);
    15701555        }
    15711556#endif
    15721557
    1573         retval +=
    1574             partition_device(pout_to_fdisk, drivename, current_devno,
    1575                              previous_devno, format, partsize);
     1558        retval += partition_device(pout_to_fdisk, drivename, current_devno, previous_devno, format, partsize);
     1559        mr_free(format);
    15761560
    15771561#ifdef __FreeBSD__
     
    16261610        }
    16271611    }
    1628     paranoid_free(format);
    16291612    return (retval);
    16301613}
     
    19781961        mr_asprintf(partcode, "");
    19791962    } else if (strlen(format) >= 1 && strlen(format) <= 2) {
    1980         mr_asprintf(partcode, format);
     1963        mr_asprintf(partcode, "%s", format);
    19811964    } else {
    19821965        /* probably an image */
     
    19851968        mr_free(tmp);
    19861969#ifdef __FreeBSD__
    1987         mr_asprintf(partcode, format);  // was a5
     1970        mr_asprintf(partcode, "%s", format);    // was a5
    19881971#else
    1989         mr_asprintf(partcode, format);  // was 83
     1972        mr_asprintf(partcode, "%s", format);    // was 83
    19901973#endif
    19911974    }
     
    22602243
    22612244    /** buffers *********************************************************/
    2262     char *tmp = NULL;
    22632245    char *program = NULL;
    22642246
     
    23112293        mr_asprintf(program, "mkfs -t %s -c", format);  // -c checks for bad blocks
    23122294#endif
    2313         mr_asprintf(tmp, "Unknown format (%s) - assuming '%s' will do", format, program);
    2314         log_it(tmp);
    2315         mr_free(tmp);
     2295        log_it("Unknown format (%s) - assuming '%s' will do", format, program);
    23162296        res = 0;
    23172297    }
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c

    r2332 r2334  
    4343
    4444  /** needs malloc *******/
    45     char *checksum_ptr;
    46     char *original_cksum_ptr;
    47     char *bigfile_fname_ptr;
     45    char *checksum_ptr = NULL;
     46    char *original_cksum_ptr = NULL;
     47    char *bigfile_fname_ptr = NULL;
    4848    char *tmp_ptr = NULL;
    4949    char *command_ptr = NULL;
    5050
    51     char *checksum, *original_cksum, *bigfile_fname, *tmp, *command;
     51    char *checksum, *bigfile_fname, *tmp, *command;
    5252
    5353    char *p;
     
    5858
    5959    malloc_string(checksum);
    60     malloc_string(original_cksum);
    6160    malloc_string(bigfile_fname);
    6261    malloc_string(tmp);
    6362    malloc_string(command);
    64     malloc_string(checksum_ptr);
    65     malloc_string(original_cksum_ptr);
    66     malloc_string(bigfile_fname_ptr);
    6763
    6864  /*********************************************************************
     
    7066   *********************************************************************/
    7167    assert(bkpinfo != NULL);
    72     memset(checksum_ptr, '\0', sizeof(checksum));
    73     memset(original_cksum_ptr, '\0', sizeof(original_cksum));
    74     memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname));
    7568  /** end **/
    7669
     
    8477    }
    8578    if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) {
    86         log_to_screen("Cannot open bigfile %ld (%s)'s info file", bigfileno + 1, bigfile_fname_ptr);
     79        log_to_screen("Cannot open bigfile %ld (NULL)'s info file", bigfileno + 1);
    8780        return (1);
    8881    }
     
    9083    paranoid_fclose(fin);
    9184
    92     strcpy(checksum_ptr, biggiestruct.checksum);
    93     strcpy(bigfile_fname_ptr, biggiestruct.filename);
     85    mr_asprintf(checksum_ptr, "%s", biggiestruct.checksum);
     86    mr_asprintf(bigfile_fname_ptr, "%s", biggiestruct.filename);
    9487
    9588    log_msg(2, "biggiestruct.filename = %s", biggiestruct.filename);
     
    10699    }
    107100    if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) {
    108         strcpy(original_cksum_ptr, "IGNORE");
    109101        log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname_ptr);
     102        mr_free(bigfile_fname_ptr);
    110103        return (1);
    111104    }
     
    122115    if (i) {
    123116        log_OS_error("Warning - command failed");
    124         original_cksum[0] = '\0';
    125117        return (1);
    126118    } else {
     
    128120            log_msg(2,
    129121                    "Unable to open /tmp/md5sum.txt; can't get live checksum");
    130             original_cksum[0] = '\0';
     122            mr_free(bigfile_fname_ptr);
    131123            return (1);
    132124        } else {
    133             fgets(original_cksum_ptr, MAX_STR_LEN - 1, fin);
     125            mr_getline(original_cksum_ptr, fin);
    134126            paranoid_fclose(fin);
    135             for (i = strlen(original_cksum_ptr);
    136                  i > 0 && original_cksum[i - 1] < 32; i--);
    137             original_cksum[i] = '\0';
    138             p = (char *) strchr(original_cksum_ptr, ' ');
     127            p = strchr(original_cksum_ptr, ' ');
    139128            if (p) {
    140129                *p = '\0';
     
    143132    }
    144133    mr_asprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1, bigfile_fname_ptr);
    145     if (!strcmp(checksum_ptr, original_cksum_ptr) != 0) {
     134    if ((original_cksum_ptr != NULL) && (strcmp(checksum_ptr, original_cksum_ptr) == 0)) {
    146135        mr_strcat(tmp_ptr, " ... OK");
    147136    } else {
     
    149138        retval++;
    150139    }
     140    mr_free(checksum_ptr);
     141    mr_free(original_cksum_ptr);
     142
    151143    log_msg(1, tmp_ptr);
    152144    paranoid_free(tmp_ptr);
     
    159151        paranoid_fclose(fout);
    160152    }
    161 
    162     paranoid_free(original_cksum_ptr);
    163     paranoid_free(original_cksum);
    164     paranoid_free(bigfile_fname_ptr);
     153    mr_free(bigfile_fname_ptr);
     154
    165155    paranoid_free(bigfile_fname);
    166     paranoid_free(checksum_ptr);
    167156    paranoid_free(checksum);
    168157    paranoid_free(command);
     
    365354  /**  needs malloc **********/
    366355
    367     char *tarball_fname, *progress_str;
     356    char *tarball_fname = NULL;
     357    char *progress_str = NULL;
    368358    char *tmp = NULL;
    369359    char *mds = NULL;
     
    443433        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    444434    }
    445     paranoid_free(tarball_fname);
    446     paranoid_free(progress_str);
    447435    return (retval);
    448436}
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c

    r2332 r2334  
    7878    newtPushHelpLine
    7979        ("   Add one of the following unallocated RAID partitions to this RAID device.");
    80     mr_asprintf(&tmp, "%-26s %s", "Device", "Size");
     80    mr_asprintf(tmp, "%-26s %s", "Device", "Size");
    8181    headerMsg = newtLabel(1, 1, tmp);
    8282    partitionsListbox =
     
    104104
    105105            items = disklist->entries;
    106             strcpy(disklist->el[items].device,
    107                    unallocated_raid_partitions->el[currline].device);
     106            strcpy(disklist->el[items].device, unallocated_raid_partitions->el[currline].device);
    108107            disklist->el[items].index = index;
    109108            disklist->entries = ++items;
     
    154153
    155154    /** buffers **********************************************************/
    156     char drive_to_add[MAX_STR_LEN];
    157     char mountpoint_str[MAX_STR_LEN];
    158     char size_str[MAX_STR_LEN];
    159     char device_str[MAX_STR_LEN];
    160     char format_str[MAX_STR_LEN];
     155    char *drive_to_add = NULL;
     156    char *mountpoint_str = NULL;
     157    char *size_str = NULL;
     158    char *device_str = NULL;
     159    char *format_str = NULL;
    161160
    162161    /** pointers *********************************************************/
     
    171170    assert(keylist != NULL);
    172171
    173     strcpy(device_str, "/dev/");
    174     strcpy(mountpoint_str, "/");
     172    mr_asprintf(device_str, "/dev/");
     173    mr_asprintf(mountpoint_str, "/");
     174    mr_asprintf(size_str, "");
    175175#ifdef __FreeBSD__
    176     strcpy(format_str, "ufs");
     176    mr_asprintf(format_str, "ufs");
    177177#else
    178     strcpy(format_str, "ext3");
     178    mr_asprintf(format_str, "ext3");
    179179#endif
    180     size_str[0] = '\0';
    181180    newtOpenWindow(20, 5, 48, 10, "Add entry");
    182181    label0 = newtLabel(2, 1, "Device:    ");
     
    184183    label2 = newtLabel(2, 3, "Size (MB): ");
    185184    label3 = newtLabel(2, 4, "Format:    ");
    186     deviceComp =
    187         newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
    188     mountpointComp =
    189         newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
    190     formatComp =
    191         newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
     185    deviceComp = newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
     186    mountpointComp = newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
     187    formatComp = newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
    192188    sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0);
    193189    bOK = newtButton(5, 6, "  OK  ");
     
    201197    for (b_res = NULL; b_res != bOK && b_res != bCancel;) {
    202198        b_res = newtRunForm(myForm);
    203         strcpy(device_str, device_here);
    204         strcpy(mountpoint_str, mountpoint_here);
    205         strcpy(format_str, format_here);
    206         strcpy(size_str, size_here);
    207 //      log_it ("Originals = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str);
     199        mr_free(device_str);
     200        mr_asprintf(device_str, "%s", device_here);
     201
     202        mr_free(mountpoint_str);
     203        mr_asprintf(mountpoint_str, "%s", mountpoint_here);
     204        mr_strip_spaces(mountpoint_str);
     205
     206        mr_free(format_str);
     207        mr_asprintf(format_str, "%s", format_here);
     208        mr_strip_spaces(format_str);
     209
     210        mr_free(size_str);
     211        mr_asprintf(size_str, "%s", size_here);
     212        mr_strip_spaces(size_str);
     213
    208214        strip_spaces(device_str);
    209         strip_spaces(mountpoint_str);
    210         strip_spaces(format_str);
    211         strip_spaces(size_str);
    212 //      log_it ("Modified = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str);
    213215        if (b_res == bOK) {
    214216            if (device_str[strlen(device_str) - 1] == '/') {
     
    216218                b_res = NULL;
    217219            }
    218             if (size_of_specific_device_in_mountlist(mountlist, device_str)
    219                 >= 0) {
     220            if (size_of_specific_device_in_mountlist(mountlist, device_str) >= 0) {
    220221                popup_and_OK("Can't add this - you've got one already!");
    221222                b_res = NULL;
     
    229230        return;
    230231    }
    231     strcpy(drive_to_add, device_str);
     232    mr_asprintf(drive_to_add, "%s", device_str);
    232233    for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--);
    233234    num_to_add = atoi(drive_to_add + i);
    234     drive_to_add[i] = '\0';
     235    mr_free(drive_to_add);
     236
    235237    currline = mountlist->entries;
    236238    strcpy(mountlist->el[currline].device, device_str);
    237239    strcpy(mountlist->el[currline].mountpoint, mountpoint_str);
     240    mr_free(mountpoint_str);
     241
    238242    strcpy(mountlist->el[currline].format, format_str);
     243    mr_free(format_str);
     244
    239245    mountlist->el[currline].size = atol(size_str) * 1024L;
     246    mr_free(size_str);
     247
    240248    mountlist->entries++;
    241249    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) {
    242         initiate_new_raidlist_entry(raidlist, mountlist, currline,
    243                                     device_str);
    244     }
     250        initiate_new_raidlist_entry(raidlist, mountlist, currline, device_str);
     251    }
     252    mr_free(device_str);
     253
    245254    redraw_mountlist(mountlist, keylist, listbox);
    246255}
     
    316325    /** buffers ***********************************************************/
    317326    char tmp = NULL;
    318 
    319 
    320 
     327    char *devname = NULL;
    321328
    322329    for (i = 0;
     
    324331         && strcmp(raidlist->el[i].volname, basename(raid_device)); i++);
    325332    if (i == raidlist->entries) {
    326         mr_asprintf(&tmp, "Cannot calc size of raid device %s - cannot find it in raidlist", raid_device);
    327         log_it(tmp);
    328         mr_free(tmp);
     333        log_it("Cannot calc size of raid device %s - cannot find it in raidlist", raid_device);
    329334        return (0);             // Isn't this more sensible than 999999999? If the raid dev !exists,
    330335        // then it has no size, right?
     
    338343        int k = 0, l = 0;
    339344        for (k = 0; k < raidrec->plex[j].subdisks; ++k) {
    340             char devname[64];
    341             strcpy(devname, raidrec->plex[j].sd[k].which_device);
     345            mr_asprintf(devname, "%s", raidrec->plex[j].sd[k].which_device);
    342346            for (l = 0; l < raidlist->disks.entries; ++l) {
    343347                if (!strcmp(devname, raidlist->disks.el[l].name)) {
     
    367371                }
    368372            }
     373            mr_free(devname);
    369374        }
    370375
     
    387392    }
    388393
    389     mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device, (long) smallest_plex);
    390     log_it(tmp);
    391     mr_free(tmp);
     394    log_it("I have calculated %s's real size to be %ld", raid_device, (long) smallest_plex);
    392395    return (smallest_plex);
    393396#else
     
    406409    long sp = 0;
    407410
    408     /** buffers ***********************************************************/
    409     char tmp = NULL;
    410 
    411411    assert(mountlist != NULL);
    412412    assert(raidlist != NULL);
     
    417417         && strcmp(raidlist->el[i].raid_device, raid_device); i++);
    418418    if (i == raidlist->entries) {
    419         mr_asprintf(&tmp, "Cannot calc size of raid device %s - cannot find it in raidlist", raid_device);
    420         log_it(tmp);
    421         mr_free(tmp);
     419        log_it("Cannot calc size of raid device %s - cannot find it in raidlist", raid_device);
    422420        return (999999999);
    423421    }
     
    442440        total_size = smallest_partition * (noof_partitions - 1);
    443441    }
    444     mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device, (long) total_size);
    445     log_it(tmp);
    446     mr_free(tmp);
     442    log_it("I have calculated %s's real size to be %ld", raid_device, (long) total_size);
    447443    return (total_size);
    448444#endif
     
    499495            }
    500496            p[i] = '\0';
    501             mr_free(sz);
    502497        }
    503498        if (!strcmp(p, "concat")) {
     
    568563            }
    569564            p[i] = '\0';
    570             mr_free(sz);
    571565        }
    572566        if (!strcmp(p, "linear")) {
     
    613607
    614608    /** buffers ***********************************************************/
    615     char *tmp = NULL;
    616 
    617609    assert(mountlist != NULL);
    618610    assert(raidlist != NULL);
     
    625617             pos++);
    626618        if (pos < mountlist->entries) {
    627             mr_asprintf(&tmp, "Deleting partition %s cos it was part of a now-defunct RAID", mountlist->el[pos].device);
    628             log_it(tmp);
    629             mr_free(tmp);
     619            log_it("Deleting partition %s cos it was part of a now-defunct RAID", mountlist->el[pos].device);
    630620
    631621            memcpy((void *) &mountlist->el[pos],
     
    662652    assert_string_is_neither_NULL_nor_zerolength(raid_device);
    663653
    664     mr_asprintf(&tmp, "Delete %s from RAID device %s - are you sure?", disklist->el[currline].device, raid_device);
     654    mr_asprintf(tmp, "Delete %s from RAID device %s - are you sure?", disklist->el[currline].device, raid_device);
    665655    res = ask_me_yes_or_no(tmp);
    666656    mr_free(tmp);
     
    699689    /** buffers ***********************************************************/
    700690    char *tmp = NULL;
    701     char device[MAX_STR_LEN];
     691    char *device = NULL;
    702692
    703693
     
    707697    assert(keylist != NULL);
    708698
    709     /* BERLIOS: Why isn't device initialized here ? what is expected */
    710     pos =
    711         which_raid_device_is_using_this_partition(raidlist,
    712                                                   mountlist->el[currline].
    713                                                   device);
     699    pos = which_raid_device_is_using_this_partition(raidlist, mountlist->el[currline].device);
    714700    if (pos >= 0) {
    715         mr_asprintf(&tmp, "Cannot delete %s: it is in use by RAID device %s", mountlist->el[currline].device, raidlist->el[pos].OSSWAP(raid_device, volname));
     701        mr_asprintf(tmp, "Cannot delete %s: it is in use by RAID device %s", mountlist->el[currline].device, raidlist->el[pos].OSSWAP(raid_device, volname));
    716702        popup_and_OK(tmp);
    717703        mr_free(tmp);
    718704        return;
    719705    }
    720     mr_asprintf(&tmp, "Delete %s - are you sure?", mountlist->el[currline].device);
     706    mr_asprintf(tmp, "Delete %s - are you sure?", mountlist->el[currline].device);
    721707    res = ask_me_yes_or_no(tmp);
    722708    mr_free(tmp);
     
    726712    }
    727713    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) {
    728         strcpy(device, mountlist->el[currline].device);
     714        mr_asprintf(device, "%s", mountlist->el[currline].device);
    729715        delete_raidlist_entry(mountlist, raidlist, device);
    730716        for (currline = 0;
     
    732718             && strcmp(mountlist->el[currline].device, device);
    733719             currline++);
     720        mr_free(device);
     721
    734722        if (currline == mountlist->entries) {
    735723            log_it("Dev is gone. I can't delete it. Ho-hum");
     
    775763        return;
    776764    }
    777     mr_asprintf(&tmp, "Do you want me to delete %s's partitions, too?", device);
     765    mr_asprintf(tmp, "Do you want me to delete %s's partitions, too?", device);
    778766    delete_partitions_too = ask_me_yes_or_no(tmp);
    779767    if (delete_partitions_too) {
     
    788776                    if (!strcmp(raidlist->el[i].plex[x].sd[y].which_device,
    789777                                raidlist->disks.el[z].name)) {
    790                         strcpy(d.el[d.entries].name,
    791                                raidlist->disks.el[z].name);
    792                         strcpy(d.el[d.entries++].device,
    793                                raidlist->disks.el[z].device);
     778                        strcpy(d.el[d.entries].name, raidlist->disks.el[z].name);
     779                        strcpy(d.el[d.entries++].device, raidlist->disks.el[z].device);
    794780                    }
    795781                }
     
    844830
    845831    av = &raidrec->additional_vars;
    846     mr_asprintf(&tmp, "Delete %s - are you sure?", av->el[lino].label);
     832    mr_asprintf(tmp, "Delete %s - are you sure?", av->el[lino].label);
    847833    res = ask_me_yes_or_no(tmp);
    848834    mr_free(tmp);
     
    851837        if (!strcmp(av->el[lino].label, "persistent-superblock")
    852838            || !strcmp(av->el[lino].label, "chunk-size")) {
    853             mr_asprintf(&tmp, "%s must not be deleted. It would be bad.", av->el[lino].label);
     839            mr_asprintf(tmp, "%s must not be deleted. It would be bad.", av->el[lino].label);
    854840            popup_and_OK(tmp);
    855841            mr_free(tmp);
     
    920906                if (!warned_already) {
    921907                    warned_already = TRUE;
    922                     mr_asprintf(&tmp1, "Too many lines. Displaying first %d entries only. Close a directory to see more.", ARBITRARY_MAXIMUM);
     908                    mr_asprintf(tmp1, "Too many lines. Displaying first %d entries only. Close a directory to see more.", ARBITRARY_MAXIMUM);
    923909                    popup_and_OK(tmp1);
    924910                    mr_free(tmp1);
    925911                }
    926912            } else {
    927                 strcpy(g_strings_of_flist_window[lines_in_flist_window],
    928                        current_filename);
     913                strcpy(g_strings_of_flist_window[lines_in_flist_window], current_filename);
    929914                g_is_path_selected[lines_in_flist_window] = node->selected;
    930915                lines_in_flist_window++;
     
    941926                (g_strings_of_flist_window[i],
    942927                 g_strings_of_flist_window[i - 1]) < 0) {
    943                 mr_asprintf(&tmp1, g_strings_of_flist_window[i]);
    944                 strcpy(g_strings_of_flist_window[i],
    945                        g_strings_of_flist_window[i - 1]);
     928                mr_asprintf(tmp1, "%s", g_strings_of_flist_window[i]);
     929                strcpy(g_strings_of_flist_window[i], g_strings_of_flist_window[i - 1]);
    946930                strcpy(g_strings_of_flist_window[i - 1], tmp1);
    947931                mr_free(tmp1);
     
    10481032    void *curr_choice;
    10491033    void *keylist[ARBITRARY_MAXIMUM];
    1050 
    1051     /** buffers ***********************************************************/
    1052     char *tmp = NULL;
    10531034
    10541035    /** bool **************************************************************/
     
    10981079                indexno = 0;
    10991080            }
    1100             mr_asprintf(&tmp, "You selected '%s'", g_strings_of_flist_window[indexno]);
    1101             log_it(tmp);
    1102             mr_free(tmp);
     1081            log_it("You selected '%s'", g_strings_of_flist_window[indexno]);
    11031082
    11041083            if (b_res == bMore) {
     
    11931172
    11941173  /** buffers ***********************************************************/
    1195     char device_str[MAX_STR_LEN];
    1196     char mountpoint_str[MAX_STR_LEN];
    1197     char size_str[MAX_STR_LEN];
    1198     char format_str[MAX_STR_LEN];
     1174    char *device_str = NULL;
     1175    char *mountpoint_str = NULL;
     1176    char *size_str = NULL;
     1177    char *format_str = NULL;
    11991178    char *tmp = NULL;
    1200     char device_used_to_be[MAX_STR_LEN];
    1201     char mountpt_used_to_be[MAX_STR_LEN];
     1179    char *device_used_to_be = NULL;
     1180    char *mountpt_used_to_be = NULL;
    12021181
    12031182    /** pointers **********************************************************/
     
    12171196    memcpy((void *) &bkp_raidlist, (void *) raidlist,
    12181197           sizeof(struct raidlist_itself));
    1219     strcpy(device_str, mountlist->el[currline].device);
    1220     strcpy(device_used_to_be, mountlist->el[currline].device);
    1221     strcpy(mountpoint_str, mountlist->el[currline].mountpoint);
    1222     strcpy(mountpt_used_to_be, mountlist->el[currline].mountpoint);
    1223     strcpy(format_str, mountlist->el[currline].format);
    1224     sprintf(size_str, "%lld", mountlist->el[currline].size / 1024L);
     1198    mr_asprintf(device_str, "%s", mountlist->el[currline].device);
     1199    mr_asprintf(device_used_to_be, "%s", mountlist->el[currline].device);
     1200    mr_asprintf(mountpoint_str, "%s", mountlist->el[currline].mountpoint);
     1201    mr_asprintf(mountpt_used_to_be, "%s", mountlist->el[currline].mountpoint);
     1202    mr_asprintf(format_str, "%s", mountlist->el[currline].format);
     1203    mr_asprintf(size_str, "%lld", mountlist->el[currline].size / 1024L);
    12251204    newtOpenWindow(20, 5, 48, 10, "Edit entry");
    12261205    label0 = newtLabel(2, 1, "Device:");
     
    12281207    label2 = newtLabel(2, 3, "Size (MB): ");
    12291208    label3 = newtLabel(2, 4, "Format:    ");
    1230     deviceComp =
    1231         newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
    1232     mountpointComp =
    1233         newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
    1234     formatComp =
    1235         newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
     1209    deviceComp = newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
     1210    mountpointComp = newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
     1211    formatComp = newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
    12361212    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    12371213        || !strcmp(mountlist->el[currline].mountpoint, "image")) {
     
    12531229    for (b_res = NULL; b_res != bOK && b_res != bCancel;) {
    12541230        b_res = newtRunForm(myForm);
    1255         strcpy(device_str, device_here);
    1256         strip_spaces(device_str);
    1257         strcpy(mountpoint_str, mountpoint_here);
    1258         strip_spaces(mountpoint_str);
    1259         strcpy(format_str, format_here);
    1260         strip_spaces(format_str);
     1231        mr_free(device_str);
     1232        mr_asprintf(device_str, "%s", device_here);
     1233        mr_strip_spaces(device_str);
     1234
     1235        mr_free(mountpoint_str);
     1236        mr_asprintf(mountpoint_str, "%s", mountpoint_here);
     1237        mr_strip_spaces(mountpoint_str);
     1238
     1239        mr_free(format_str);
     1240        mr_asprintf(format_str, "%s", format_here);
     1241        mr_strip_spaces(format_str);
     1242
    12611243        if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB)
    12621244            && strstr(device_used_to_be, RAID_DEVICE_STUB)
     
    12731255        if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    12741256            && strcmp(mountlist->el[currline].mountpoint, "image")) {
    1275             strcpy(size_str, size_here);
    1276             strip_spaces(size_str);
     1257            mr_free(size_str);
     1258            mr_asprintf(size_str, "%s", size_here);
     1259            mr_strip_spaces(size_str);
    12771260        } else {
    1278             sprintf(size_str, "%ld",
    1279                     calculate_raid_device_size(mountlist, raidlist,
    1280                                                mountlist->el[currline].
    1281                                                device) / 1024);
     1261            mr_asprintf(size_str, "%ld", calculate_raid_device_size(mountlist, raidlist, mountlist->el[currline].device) / 1024);
    12821262            newtLabelSetText(sizeComp, size_str);
    12831263        }
     
    12961276                                                 device);
    12971277                if (j < 0) {
    1298                     mr_asprintf(&tmp, "/etc/raidtab does not have an entry for %s; please delete it and add it again", mountlist->el[currline].device);
     1278                    mr_asprintf(tmp, "/etc/raidtab does not have an entry for %s; please delete it and add it again", mountlist->el[currline].device);
    12991279                    popup_and_OK(tmp);
    13001280                    mr_free(tmp);
     
    13101290    newtPopHelpLine();
    13111291    newtPopWindow();
     1292    mr_free(mountpt_used_to_be);
     1293
    13121294    if (b_res == bCancel) {
    13131295        memcpy((void *) raidlist, (void *) &bkp_raidlist,
    13141296               sizeof(struct raidlist_itself));
     1297        mr_free(device_str);
     1298        mr_free(device_used_to_be);
     1299        mr_free(format_str);
     1300        mr_free(size_str);
    13151301        return;
    13161302    }
    13171303    strcpy(mountlist->el[currline].device, device_str);
    13181304    strcpy(mountlist->el[currline].mountpoint, mountpoint_str);
     1305    mr_free(mountpoint_str);
     1306
    13191307    strcpy(mountlist->el[currline].format, format_str);
     1308    mr_free(format_str);
     1309
    13201310    if (strcmp(mountlist->el[currline].mountpoint, "image")) {
    13211311        if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) {
     
    13271317        }
    13281318    }
     1319    mr_free(size_str);
    13291320    newtListboxSetEntry(listbox, (long) keylist[currline],
    13301321                        mountlist_entry_to_string(mountlist, currline));
     
    13321323    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    13331324        && !strstr(device_used_to_be, RAID_DEVICE_STUB)) {
    1334         initiate_new_raidlist_entry(raidlist, mountlist, currline,
    1335                                     device_str);
     1325        initiate_new_raidlist_entry(raidlist, mountlist, currline, device_str);
    13361326    }
    13371327    /* if moving from RAID to non-RAID then do funky stuff */
     
    13501340#ifndef __FreeBSD__             /* It works fine under FBSD. */
    13511341    else if (strcmp(device_used_to_be, device_str)) {
    1352         popup_and_OK
    1353             ("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it.");
     1342        popup_and_OK("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it.");
    13541343    }
    13551344#endif
     1345    mr_free(device_str);
     1346    mr_free(device_used_to_be);
     1347
    13561348    redraw_mountlist(mountlist, keylist, listbox);
    13571349}
     
    13761368    for (i = 0; i < raidlist->disks.entries; ++i) {
    13771369        if (!strcmp(raidlist->disks.el[i].device, temp)) {
    1378             strcpy(raidrec->sd[raidrec->subdisks].which_device,
    1379                    raidlist->disks.el[i].name);
     1370            strcpy(raidrec->sd[raidrec->subdisks].which_device, raidlist->disks.el[i].name);
    13801371            found = TRUE;
    13811372        }
     
    14941485                switch (raidrec->plex[i].raidlevel) {
    14951486                case -1:
    1496                     mr_asprintf(&raidlevel, "concat");
     1487                    mr_asprintf(raidlevel, "concat");
    14971488                    break;
    14981489                case 0:
    1499                     mr_asprintf(&raidlevel, "striped");
     1490                    mr_asprintf(raidlevel, "striped");
    15001491                    break;
    15011492                case 5:
    1502                     mr_asprintf(&raidlevel, "raid5");
     1493                    mr_asprintf(raidlevel, "raid5");
    15031494                    break;
    15041495                default:
    1505                     mr_asprintf(&raidlevel, "raid%i", raidrec->plex[i].raidlevel);
     1496                    mr_asprintf(raidlevel, "raid%i", raidrec->plex[i].raidlevel);
    15061497                    break;
    15071498                }
    15081499
    15091500                if (raidrec->plex[i].raidlevel == -1) {
    1510                     mr_asprintf(&chunksize, "N/A");
     1501                    mr_asprintf(chunksize, "N/A");
    15111502                } else {
    1512                     mr_asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize);
     1503                    mr_asprintf(chunksize, "%dk", raidrec->plex[i].stripesize);
    15131504                }
    15141505                snprintf(pname, 64, "%s.p%i", raidrec->volname, i);
     
    15401531
    15411532        if (b_res == bDelete) {
    1542             mr_asprintf(&msg, "Are you sure you want to delete %s.p%i?", raidrec->volname, currline2);
     1533            mr_asprintf(msg, "Are you sure you want to delete %s.p%i?", raidrec->volname, currline2);
    15431534            res = ask_me_yes_or_no(msg);
    15441535            mr_free(msg);
     
    15781569    /** buffers ***********************************************************/
    15791570    char *title_of_editraidForm_window;
    1580     char *sz_raid_level;
     1571    char *sz_raid_level = NULL;
    15811572    char *sz_data_disks = NULL;
    15821573    char *sz_spare_disks = NULL;
     
    16001591    assert(raidrec != NULL);
    16011592
    1602     malloc_string(title_of_editraidForm_window);
    1603     malloc_string(sz_raid_level);
    1604 
    16051593    bkp_raidrec = mr_malloc(sizeof(struct raid_device_record));
    16061594    log_it("Started edit_raidlist_entry");
    16071595
    16081596    memcpy((void *) bkp_raidrec, (void *) raidrec, sizeof(struct raid_device_record));
    1609     sprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);
     1597    mr_asprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);
    16101598    log_msg(2, "Opening newt window");
    16111599    newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window);
    16121600    for (;;) {
    16131601        log_msg(2, "Main loop");
    1614         sprintf(title_of_editraidForm_window, "Edit %s",
    1615                 raidrec->raid_device);
    1616         strcpy(sz_raid_level,
    1617                turn_raid_level_number_to_string(raidrec->raid_level));
     1602        mr_free(title_of_editraidForm_window);
     1603        mr_asprintf(title_of_editraidForm_window, "Edit %s", raidrec->raid_device);
     1604        mr_asprintf(sz_raid_level, "%s", turn_raid_level_number_to_string(raidrec->raid_level));
    16181605        /* Those 4 strings are allocated by the function  */
    16191606        sz_data_disks = number_of_disks_as_string(raidrec->data_disks.entries, "data");
     
    16661653    newtPopWindow();
    16671654    mountlist->el[currline].size = calculate_raid_device_size(mountlist, raidlist, raidrec->raid_device);
    1668     paranoid_free(title_of_editraidForm_window);
    1669     paranoid_free(sz_raid_level);
     1655    mr_free(title_of_editraidForm_window);
     1656    mr_free(sz_raid_level);
    16701657    paranoid_free(bkp_raidrec);
    16711658#endif
     
    17151702
    17161703    char *p = NULL;
     1704    char *tmp = NULL;
     1705    char *entry = NULL;
    17171706
    17181707    struct mountlist_itself *unallocparts;
     
    17301719    for (;;) {
    17311720        int i;
    1732         char headerstr[MAX_STR_LEN];
    1733         char tmp[64];
    1734         snprintf(headerstr, MAX_STR_LEN, "%-24s %s", "Subdisk", "Device");
    1735 
    17361721
    17371722        switch (raidrec->raidlevel) {
    17381723        case -1:
    1739             strcpy(tmp, "concat");
     1724            mr_asprintf(tmp, "concat");
    17401725            break;
    17411726        case 0:
    1742             strcpy(tmp, "striped");
     1727            mr_asprintf(tmp, "striped");
    17431728            break;
    17441729        case 5:
    1745             strcpy(tmp, "raid5");
     1730            mr_asprintf(tmp, "raid5");
    17461731            break;
    17471732        default:
    1748             sprintf(tmp, "unknown (%i)", raidrec->raidlevel);
     1733            mr_asprintf(tmp, "unknown (%i)", raidrec->raidlevel);
    17491734            break;
    17501735        }
    17511736        bLevel = newtCompactButton(2, 2, " RAID level ");
    17521737        sLevel = newtLabel(19, 2, tmp);
     1738        mr_free(tmp);
    17531739
    17541740        if (raidrec->raidlevel >= 0) {
    1755             sprintf(tmp, "%ik", raidrec->stripesize);
     1741            mr_asprintf(tmp, "%ik", raidrec->stripesize);
    17561742            bStripeSize = newtCompactButton(2, 4, " Stripe size ");
    17571743        } else {
    1758             strcpy(tmp, "N/A");
     1744            mr_asprintf(tmp, "N/A");
    17591745            bStripeSize = newtLabel(2, 4, "Stripe size:");
    17601746        }
    17611747        sStripeSize = newtLabel(19, 4, tmp);
     1748        mr_free(tmp);
    17621749
    17631750        bOK = newtCompactButton(2, 16, "  OK  ");
     
    17681755
    17691756
    1770         //  plexesListbox = newtListbox (2, 7, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
    1771         //  plexesHeader  = newtLabel (2, 6, headerstr);
    17721757        unallocListbox =
    17731758            newtListbox(2, 7, 7, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
     
    17851770                                                 raidlist);
    17861771        for (i = 0; i < ARBITRARY_MAXIMUM; ++i) {
    1787             char entry[MAX_STR_LEN];
    17881772            keylist[i] = (void *) i;
    17891773            if (i < raidrec->subdisks) {
    1790                 snprintf(entry, MAX_STR_LEN, "%-17s",
    1791                          find_dev_entry_for_raid_device_name(raidlist,
    1792                                                              raidrec->
    1793                                                              sd[i].
    1794                                                              which_device));
     1774                mr_asprintf(entry, "%-17s", find_dev_entry_for_raid_device_name(raidlist, raidrec->sd[i].which_device));
    17951775                newtListboxAppendEntry(allocListbox, entry, keylist[i]);
     1776                mr_free(entry);
    17961777            }
    17971778            if (i < unallocparts->entries) {
    1798                 snprintf(entry, MAX_STR_LEN, "%-17s",
    1799                          unallocparts->el[i].device);
     1779                mr_asprintf(entry, "%-17s", unallocparts->el[i].device);
    18001780                newtListboxAppendEntry(unallocListbox, entry, keylist[i]);
     1781                mr_free(entry);
    18011782            }
    18021783        }
     
    18481829            choose_raid_level(raidrec);
    18491830        } else if (b_res == bStripeSize) {
    1850             char *tmp = NULL;
    1851 
    18521831            mr_asprintf(tmp, "%i", raidrec->stripesize);
    18531832            p = popup_and_get_string("Stripe size", "Please enter the stripe size in kilobytes.", tmp);
     
    19731952    bCancel = newtCompactButton(i += 12, 17, "Cancel");
    19741953    bOK = newtCompactButton(i += 12, 17, "  OK  ");
    1975     mr_asprintf(&tmp, "%-24s %-24s %-8s  %s", "Device", "Mountpoint", "Format", "Size (MB)");
     1954    mr_asprintf(tmp, "%-24s %-24s %-8s  %s", "Device", "Mountpoint", "Format", "Size (MB)");
    19761955    headerMsg = newtLabel(2, 1, tmp);
    19771956    flawsLabelA = newtLabel(2, 13, flaws_str_A);
     
    22382217#ifdef __FreeBSD__
    22392218    for (i = 0; i < raidlist->entries; i++) {
    2240         mr_asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname);
     2219        mr_asprintf(vdev, "/dev/vinum/%s", raidlist->el[i].volname);
    22412220        res = strcmp(device, vdev);
    22422221        mr_free(vdev);
     
    23652344    raidrec = &raidlist->el[pos_in_raidlist];
    23662345    initialize_raidrec(raidrec);
    2367     strcpy(raidrec->OSSWAP(raid_device, volname),
    2368            OSSWAP(device, basename(device)));
     2346    strcpy(raidrec->OSSWAP(raid_device, volname), OSSWAP(device, basename(device)));
    23692347#ifndef __FreeBSD__
    23702348    choose_raid_level(raidrec);
     
    26182596                                                   char *new_dev)
    26192597{
    2620     /** buffers ********************************************************/
    2621     char *tmp = NULL;
    2622 
    26232598    /** int ************************************************************/
    26242599    int pos = 0;
     
    26312606    pos = which_raid_device_is_using_this_partition(raidlist, old_dev);
    26322607    if (pos < 0) {
    2633         mr_asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.", old_dev);
    2634         log_it(tmp);
    2635         mr_free(tmp);
     2608        log_it("No need to rejig %s in raidlist: it's not listed.", old_dev);
    26362609    } else {
    26372610        if ((j =
     
    26392612                                         OSSWAP(el[pos].data_disks, disks),
    26402613                                         old_dev)) >= 0) {
    2641             strcpy(raidlist->OSSWAP(el[pos].data_disks, disks).el[j].
    2642                    device, new_dev);
     2614            strcpy(raidlist->OSSWAP(el[pos].data_disks, disks).el[j].device, new_dev);
    26432615        } else
    26442616            if ((j =
     
    26472619                                                    spares),
    26482620                                             old_dev)) >= 0) {
    2649             strcpy(raidlist->OSSWAP(el[pos].spare_disks, spares).el[j].
    2650                    device, new_dev);
     2621            strcpy(raidlist->OSSWAP(el[pos].spare_disks, spares).el[j].device, new_dev);
    26512622        }
    26522623#ifndef __FreeBSD__
     
    26652636#endif
    26662637        else {
    2667             mr_asprintf(&tmp, "%s is supposed to be listed in this raid dev but it's not...", old_dev);
    2668             log_it(tmp);
    2669             mr_free(tmp);
     2638            log_it("%s is supposed to be listed in this raid dev but it's not...", old_dev);
    26702639        }
    26712640    }
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2332 r2334  
    206206{
    207207
    208 /** needs malloc **/
    209208char *command = NULL;
    210 char *file;
    211 char *tmp;
     209char *file = NULL;
     210char *tmp = NULL;
    212211int res;
    213212
    214 malloc_string(file);
    215 malloc_string(tmp);
    216213assert_string_is_neither_NULL_nor_zerolength(f);
    217214assert_string_is_neither_NULL_nor_zerolength(list_fname);
     
    219216
    220217if (strncmp(preamble, f, strlen(preamble)) == 0) {
    221     strcpy(file, f + strlen(preamble));
     218    mr_asprintf(file, "%s", f + strlen(preamble));
    222219} else {
    223     strcpy(file, f);
     220    mr_asprintf(file, "%s", f);
    224221}
    225222if (file[0] == '/' && file[1] == '/') {
    226     strcpy(tmp, file);
    227     strcpy(file, tmp + 1);
     223    mr_asprintf(tmp, "%s", file);
     224    mr_free(file);
     225
     226    mr_asprintf(file, "%s", tmp + 1);
     227    mr_free(tmp);
    228228}
    229229log_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles", f, file);
    230230mr_asprintf(command, "grep -E '^%s$' %s", file, list_fname);
     231mr_free(file);
     232
    231233res = run_program_and_log_output(command, FALSE);
    232234mr_free(command);
    233 paranoid_free(file);
    234 mr_free(tmp);
    235235if (res) {
    236236    return (FALSE);
     
    429429    }
    430430    if (res) {
    431         log_msg(1, "Unable to mount device %s (type %s) at %s", device,
    432                 format, mountdir);
     431        log_msg(1, "Unable to mount device %s (type %s) at %s", device, format, mountdir);
    433432        log_msg(1, "command was '%s'", command);
    434433        if (!strcmp(mountpoint, "swap")) {
     
    479478char *tmp = NULL;
    480479char *these_failed = NULL;
    481 char *format;
    482480struct mountlist_itself *mountlist = NULL;
    483 
    484 malloc_string(format);
    485481
    486482assert(p_external_copy_of_mountlist != NULL);
     
    511507            update_progress_form(tmp);
    512508            mr_free(tmp);
    513             strcpy(format, mountlist->el[lino].format);
    514             res = mount_device(mountlist->el[lino].device,
    515                        mountlist->el[lino].mountpoint,
    516                        format, writeable);
     509            res = mount_device(mountlist->el[lino].device, mountlist->el[lino].mountpoint, mountlist->el[lino].format, writeable);
     510
    517511            retval += res;
    518512            if (res) {
     
    556550    run_program_and_log_output("df -m", 3);
    557551    paranoid_free(mountlist);
    558     paranoid_free(format);
    559552    return (retval);
    560553}
     
    728721char *iso_path = NULL;
    729722char *old_isodir = NULL;
    730 char cfg_file[100];
     723char *cfg_file = NULL;
    731724t_bkptype media_specified_by_user;
    732725
     
    736729
    737730if (!cfgf) {
    738     strcpy(cfg_file, g_mondo_cfg_file);
     731    cfg_file = g_mondo_cfg_file;
    739732} else {
    740     strcpy(cfg_file, cfgf);
     733    cfg_file = cfgf;
    741734}
    742735
     
    14951488    char *conffile;
    14961489    char *tmp = NULL;
    1497     char *editor;
     1490    char *editor = NULL;
    14981491    char *p = NULL;
    14991492
     
    15011494    bool done;
    15021495
    1503     malloc_string(editor);
    15041496    malloc_string(rootdev);
    15051497    malloc_string(rootdrive);
    15061498    malloc_string(conffile);
    15071499    assert_string_is_neither_NULL_nor_zerolength(bd);
    1508     strcpy(editor, find_my_editor());
    15091500    mr_asprintf(boot_device, "%s", bd);
    15101501
     
    15441535                newtSuspend();
    15451536            }
     1537            mr_asprintf(editor, "%s", find_my_editor());
     1538
    15461539            mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
    15471540            paranoid_system(tmp);
     
    15591552            paranoid_system(tmp);
    15601553            mr_free(tmp);
     1554            mr_free(editor);
    15611555
    15621556            if (!g_text_mode) {
     
    16111605    paranoid_free(rootdrive);
    16121606    paranoid_free(conffile);
    1613     paranoid_free(editor);
    16141607
    16151608    return (res);
     
    16311624    char *command = NULL;
    16321625    char *tmp = NULL;
    1633     char *editor;
     1626    char *editor = NULL;
    16341627
    16351628    int res;
    16361629    int done;
    16371630
    1638     malloc_string(editor);
    1639     strcpy(editor, find_my_editor());
    16401631    if (offer_to_run_stabelilo
    16411632        && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?"))
     
    16571648                    newtSuspend();
    16581649                }
     1650                mr_asprintf(editor, "%s", find_my_editor());
     1651
    16591652                mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
    16601653                paranoid_system(tmp);
     
    16641657                paranoid_system(tmp);
    16651658                mr_free(tmp);
     1659
     1660                mr_free(editor);
    16661661
    16671662                if (!g_text_mode) {
     
    16821677        res = TRUE;
    16831678    }
    1684     paranoid_free(editor);
    16851679    return (res);
    16861680}
     
    17011695    char *command = NULL;
    17021696    char *tmp = NULL;
    1703     char *editor;
     1697    char *editor = NULL;
    17041698
    17051699    int res;
    17061700    int done;
    17071701    bool run_lilo_M = FALSE;
    1708     malloc_string(editor);
    17091702
    17101703    if (!run_program_and_log_output
     
    17131706    }
    17141707
    1715     strcpy(editor, find_my_editor());
    17161708    if (offer_to_run_stablilo
    17171709        && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?"))
     
    17331725                    newtSuspend();
    17341726                }
     1727                mr_asprintf(editor, "%s", find_my_editor());
     1728
    17351729                mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    17361730                paranoid_system(tmp);
     
    17401734                paranoid_system(tmp);
    17411735                mr_free(tmp);
     1736
     1737                mr_free(editor);
    17421738
    17431739                if (!g_text_mode) {
     
    17951791                                   " lilo -M /dev/sda", 3);
    17961792    }
    1797     paranoid_free(editor);
    17981793    return (res);
    17991794}
     
    18211816    int done;
    18221817
    1823     malloc_string(editor);
    18241818    assert_string_is_neither_NULL_nor_zerolength(bd);
    18251819
    1826     strcpy(editor, find_my_editor());
    18271820    mr_asprintf(boot_device, "%s", bd);
    18281821
     
    18381831                    newtSuspend();
    18391832                }
     1833                mr_asprintf(editor, "%s", find_my_editor());
    18401834                mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1835                mr_free(editor);
     1836
    18411837                paranoid_system(tmp);
    18421838                mr_free(tmp);
     
    18841880        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    18851881    }
    1886     paranoid_free(editor);
    18871882    return (res);
    18881883}
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2331 r2334  
    443443    char *p = NULL;
    444444    char *tmp1 = NULL;
    445     char *fstab_fname;
     445    char *fstab_fname = NULL;
    446446    char *old_restpath = NULL;
    447447
     
    453453
    454454    malloc_string(tmp);
    455     malloc_string(fstab_fname);
    456455    assert(bkpinfo != NULL);
    457456    assert(mountlist != NULL);
     
    640639                            "Using tune2fs to identify your ext2,3,4 partitions");
    641640        if (does_file_exist("/tmp/fstab.new")) {
    642             strcpy(fstab_fname, "/tmp/fstab.new");
     641            mr_asprintf(fstab_fname, "/tmp/fstab.new");
    643642        } else {
    644             strcpy(fstab_fname, "/tmp/fstab");
     643            mr_asprintf(fstab_fname, "/tmp/fstab");
    645644        }
    646645        mr_asprintf(tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", g_mountlist_fname, fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE);
     646        mr_free(fstab_fname);
     647
    647648        res = system(tmp1);
    648649        mr_free(tmp1);
     
    665666  end_of_func:
    666667    paranoid_free(tmp);
    667     paranoid_free(fstab_fname);
    668668    log_it("Leaving interactive_mode()");
    669669    return (retval);
     
    10181018
    10191019  /** malloc ***/
    1020     char *checksum;
     1020    char *checksum = NULL;
    10211021    char *outfile_fname = NULL;
    10221022    char *tmp = NULL;
    10231023    char *bzip2_command = NULL;
    1024     char *ntfsprog_command, *suffix;
     1024    char *ntfsprog_command;
     1025    char *suffix = NULL;
    10251026    char *sz_devfile = NULL;
    10261027    char *bigblk;
    1027     char *p;
    10281028    char *mds = NULL;
    10291029    int retval = 0;
     
    10311031    long sliceno;
    10321032    long siz;
    1033     char ntfsprog_fifo[MAX_STR_LEN];
     1033    char *ntfsprog_fifo = NULL;
    10341034    char *file_to_openout = NULL;
    10351035    struct s_filename_and_lstat_info biggiestruct;
     
    10451045    assert(bkpinfo != NULL);
    10461046
    1047     malloc_string(checksum);
    10481047    malloc_string(ntfsprog_command);
    1049     malloc_string(suffix);
    10501048
    10511049    pathname_of_last_file_restored[0] = '\0';
     
    10671065    paranoid_fclose(fin);
    10681066
    1069     strcpy(checksum, biggiestruct.checksum);
    1070 
     1067    mr_asprintf(checksum, "%s", biggiestruct.checksum);
    10711068    if (!checksum[0]) {
    10721069        log_msg(3, "Warning - bigfile %ld does not have a checksum", bigfileno + 1);
    1073         p = checksum;
    1074     }
     1070    }
     1071    mr_free(checksum);
    10751072
    10761073    if (!strncmp(biggiestruct.filename, "/dev/", 5))    // Whether NTFS or not :)
     
    10851082        node = find_string_at_node(filelist, biggiestruct.filename);
    10861083        if (!node) {
    1087             log_msg(0, "Skipping %s (name isn't in filelist)",
    1088                     biggiestruct.filename);
     1084            log_msg(0, "Skipping %s (name isn't in filelist)", biggiestruct.filename);
    10891085            pathname_of_last_file_restored[0] = '\0';
    10901086            return (0);
    10911087        } else if (!(node->selected)) {
    1092             log_msg(1, "Skipping %s (name isn't in biggielist subset)",
    1093                     biggiestruct.filename);
     1088            log_msg(1, "Skipping %s (name isn't in biggielist subset)", biggiestruct.filename);
    10941089            pathname_of_last_file_restored[0] = '\0';
    10951090            return (0);
    10961091        }
    10971092    }
     1093
    10981094    /* otherwise, continue */
    1099 
    11001095    log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename);
    11011096    if (biggiestruct.use_ntfsprog) {
    11021097        if (strncmp(biggiestruct.filename, "/dev/", 5)) {
    1103             log_msg(1,
    1104                     "I was in error when I set biggiestruct.use_ntfsprog to TRUE.");
     1098            log_msg(1, "I was in error when I set biggiestruct.use_ntfsprog to TRUE.");
    11051099            log_msg(1, "%s isn't even in /dev", biggiestruct.filename);
    11061100            biggiestruct.use_ntfsprog = FALSE;
     
    11091103
    11101104    if (biggiestruct.use_ntfsprog)  // if it's an NTFS device
    1111 //  if (!strncmp ( biggiestruct.filename, "/dev/", 5))
    11121105    {
    11131106        g_loglevel = 4;
     
    11161109        mr_asprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), (int) (random() % 32768));
    11171110        mkfifo(sz_devfile, 0x770);
    1118         strcpy(ntfsprog_fifo, sz_devfile);
     1111        mr_asprintf(ntfsprog_fifo, "%s", sz_devfile);
    11191112        mr_free(sz_devfile);
    11201113        file_to_openout = ntfsprog_fifo;
     
    11231116            fatal_error("Fork failure");
    11241117        case 0:
    1125             log_msg(3,
    1126                     "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)",
    1127                     biggiestruct.filename, ntfsprog_fifo);
    1128             res =
    1129                 feed_outfrom_ntfsprog(biggiestruct.filename,
    1130                                        ntfsprog_fifo);
    1131 //          log_msg(3, "CHILD - fip - exiting");
     1118            log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", biggiestruct.filename, ntfsprog_fifo);
     1119            res = feed_outfrom_ntfsprog(biggiestruct.filename, ntfsprog_fifo);
     1120            mr_free(ntfsprog_fifo);
    11321121            exit(res);
    11331122            break;
    11341123        default:
    1135             log_msg(3,
    1136                     "feed_into_ntfsprog() called in background --- pid=%ld",
    1137                     (long int) (pid));
    1138         }
     1124            log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid));
     1125        }
     1126        mr_free(ntfsprog_fifo);
    11391127    } else {
    11401128        use_ntfsprog_hack = FALSE;
    1141         ntfsprog_fifo[0] = '\0';
    11421129        file_to_openout = outfile_fname;
    11431130        if (!does_file_exist(outfile_fname))    // yes, it looks weird with the '!' but it's correct that way
     
    11551142     */
    11561143
    1157     strncpy(pathname_of_last_file_restored, biggiestruct.filename,
    1158             MAX_STR_LEN - 1);
     1144    strncpy(pathname_of_last_file_restored, biggiestruct.filename, MAX_STR_LEN - 1);
    11591145    pathname_of_last_file_restored[MAX_STR_LEN - 1] = '\0';
    11601146
     
    11671153
    11681154    for (sliceno = 1, finished = FALSE; !finished;) {
    1169         if (!does_file_exist
    1170             (slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""))
    1171             &&
    1172             !does_file_exist(slice_fname
    1173                              (bigfileno, sliceno, ARCHIVES_PATH, "lzo"))
    1174             &&
    1175             !does_file_exist(slice_fname
    1176                              (bigfileno, sliceno, ARCHIVES_PATH, "gz"))
    1177             &&
    1178             !does_file_exist(slice_fname
    1179                              (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) {
    1180             log_msg(3,
    1181                     "Cannot find a data slice or terminator slice on CD %d",
    1182                     g_current_media_number);
     1155        if (!does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")) &&
     1156            !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo")) &&
     1157            !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz")) &&
     1158            !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) {
     1159            log_msg(3, "Cannot find a data slice or terminator slice on CD %d", g_current_media_number);
    11831160            g_current_media_number++;
    11841161            mds = media_descriptor_string(bkpinfo->backup_media_type);
     
    11931170            mr_asprintf(tmp, "%s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""));
    11941171            if (does_file_exist(tmp) && length_of_file(tmp) == 0) {
    1195                 log_msg(2,
    1196                         "End of bigfile # %ld (slice %ld is the terminator)",
    1197                         bigfileno + 1, sliceno);
     1172                log_msg(2, "End of bigfile # %ld (slice %ld is the terminator)", bigfileno + 1, sliceno);
    11981173                finished = TRUE;
    11991174                mr_free(tmp);
    12001175                continue;
    12011176            } else {
    1202                 if (does_file_exist
    1203                     (slice_fname
    1204                      (bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) {
     1177                if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) {
    12051178                    mr_asprintf(bzip2_command, "lzop");
    1206                     strcpy(suffix, "lzo");
     1179                    mr_asprintf(suffix, "lzo");
    12071180                } else
    1208                     if (does_file_exist
    1209                         (slice_fname
    1210                          (bigfileno, sliceno, ARCHIVES_PATH, "gz"))) {
     1181                    if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz"))) {
    12111182                    mr_asprintf(bzip2_command, "gzip");
    1212                     strcpy(suffix, "gz");
     1183                    mr_asprintf(suffix, "gz");
    12131184                } else
    1214                     if (does_file_exist
    1215                         (slice_fname
    1216                          (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) {
     1185                    if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) {
    12171186                    mr_asprintf(bzip2_command, "bzip2");
    1218                     strcpy(suffix, "bz2");
     1187                    mr_asprintf(suffix, "bz2");
    12191188                } else
    1220                     if (does_file_exist
    1221                         (slice_fname
    1222                          (bigfileno, sliceno, ARCHIVES_PATH, ""))) {
     1189                    if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""))) {
    12231190                    mr_asprintf(bzip2_command, "");
    1224                     strcpy(suffix, "");
     1191                    mr_asprintf(suffix, "");
    12251192                } else {
    12261193                    log_to_screen("OK, that's pretty fsck0red...");
     
    12351202                mr_asprintf(bzip2_command, "cat %s 2>> %s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, suffix), MONDO_LOGFILE);
    12361203            }
     1204            mr_free(suffix);
     1205
    12371206            mds = media_descriptor_string(bkpinfo->backup_media_type);
    12381207            mr_asprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld    ", mds, g_current_media_number, bigfileno + 1, sliceno);
     
    12881257    mr_free(outfile_fname);
    12891258    paranoid_free(bigblk);
    1290     paranoid_free(checksum);
    12911259    paranoid_free(ntfsprog_command);
    1292     paranoid_free(suffix);
    12931260
    12941261    return (retval);
     
    13311298    char *ntfsprog_command;
    13321299    char *sz_devfile = NULL;
    1333     char *ntfsprog_fifo;
     1300    char *ntfsprog_fifo = NULL;
    13341301    char *file_to_openout = NULL;
    13351302
     
    13501317
    13511318    malloc_string(tmp);
    1352     malloc_string(ntfsprog_fifo);
    13531319    malloc_string(ntfsprog_command);
    13541320    old_loglevel = g_loglevel;
     
    14071373        mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768));
    14081374        mkfifo(sz_devfile, 0x770);
    1409         strcpy(ntfsprog_fifo, sz_devfile);
     1375        mr_asprintf(ntfsprog_fifo, "%s", sz_devfile);
    14101376        mr_free(sz_devfile);
    14111377
     
    14171383            log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", outfile_fname, ntfsprog_fifo);
    14181384            res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo);
     1385            mr_free(ntfsprog_fifo);
    14191386            exit(res);
    14201387            break;
     
    14221389            log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid));
    14231390        }
     1391        mr_free(ntfsprog_fifo);
    14241392    } else {
    14251393        if (!strncmp(orig_bf_fname, "/dev/", 5))    {
     
    14311399        }
    14321400        use_ntfsprog_hack = FALSE;
    1433         ntfsprog_fifo[0] = '\0';
    14341401        file_to_openout = outfile_fname;
    14351402        if (!does_file_exist(outfile_fname))    // yes, it looks weird with the '!' but it's correct that way
     
    15391506    paranoid_free(tmp);
    15401507    paranoid_free(ntfsprog_command);
    1541     paranoid_free(ntfsprog_fifo);
    15421508    g_loglevel = old_loglevel;
    15431509    return (retval);
     
    20992065    char *tarball_fname = NULL;
    21002066    char *progress_str = NULL;
    2101     char *comment;
    2102 
    2103     malloc_string(comment);
    21042067
    21052068    assert(bkpinfo != NULL);
     
    21822145                mr_strcat(tmp1, " (%d attempts) - review logs", attempts);
    21832146            }
    2184             strcpy(comment, tmp1);
     2147            if (attempts > 1) {
     2148                log_to_screen(tmp1);
     2149            }
    21852150            mr_free(tmp1);
    2186             if (attempts > 1) {
    2187                 log_to_screen(comment);
    2188             }
    21892151
    21902152            retval += res;
     
    22032165        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    22042166    }
    2205     paranoid_free(comment);
    22062167
    22072168    return (retval);
     
    26332594    struct raidlist_itself *raidlist;
    26342595    struct s_node *filelist;
    2635     char *a, *b;
     2596    char *tmp1 = NULL;
     2597    char *tmp2 = NULL;
    26362598    bool run_postnuke = FALSE;
    26372599
     
    26632625    run_program_and_log_output("mkdir -p " MNT_CDROM, FALSE);
    26642626
    2665     malloc_string(a);
    2666     malloc_string(b);
    26672627    setup_MR_global_filenames();    // malloc() and set globals, using bkpinfo->tmpdir etc.
    26682628    bkpinfo->backup_media_type = none;  // in case boot disk was made for one backup type but user wants to restore from another backup type
     
    27532713        toggle_path_selection(filelist, "/usr/share", TRUE);
    27542714        save_filelist(filelist, "/tmp/out.txt");
    2755         strcpy(a, argv[3]);
    2756         strcpy(b, argv[4]);
    2757 
    2758         res = save_filelist_entries_in_common(a, filelist, b, FALSE);
     2715        mr_asprintf(tmp1, "%s", argv[3]);
     2716        mr_asprintf(tmp2, "%s", argv[4]);
     2717
     2718        res = save_filelist_entries_in_common(tmp1, filelist, tmp2, FALSE);
     2719        mr_free(tmp1);
     2720        mr_free(tmp2);
     2721
    27592722        free_filelist(filelist);
    27602723        printf("res = %d", res);
     
    30292992    paranoid_MR_finish(retval); // frees global stuff plus bkpinfo
    30302993    free_libmondo_global_strings(); // it's fine to have this here :) really :)
    3031     paranoid_free(a);
    3032     paranoid_free(b);
    30332994
    30342995    unlink("/tmp/filelist.full");
  • branches/2.2.10/mondo/test/test-mem.c

    r2310 r2334  
    3030  is_null(str);
    3131
    32   mr_asprintf(&str, "%s is %d", "two", 2);
     32  mr_asprintf(str, "%s is %d", "two", 2);
    3333  printf("*** String is %s\n",str);
    3434
  • branches/2.2.10/mondo/test/test-string.c

    r2310 r2334  
    2222    char *string = NULL;
    2323
    24     mr_asprintf(&string, "%s", "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");
     24    mr_asprintf(string, "%s", "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");
    2525    fprintf(stdout, "string=|%s|\n", string);
    2626    token = mr_strtok(string, delims, &lastpos);
  • branches/2.2.10/tools/quality

    r2332 r2334  
    4646cat /tmp/mondo.quality
    4747echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` getline without &"
    48 pbg mr_asprintf | grep -vE '"|FNAME|ISOFS|syscall_sprintf|mr_mem|quality' > /tmp/mondo.quality
     48pbg -w mr_asprintf | grep -vE '"|FNAME|ISOFS|syscall_sprintf|mr_mem|quality' > /tmp/mondo.quality
    4949cat /tmp/mondo.quality
    5050echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` mr_asprintf without \""
    51 find . -name '*.c' -o -name '*.h' |  egrep -v '\.svn|/\*|monitas|/\*|mindi-busybox' | xargs grep -rw mr_getline | egrep -v '/\*' | egrep -v 'mr_getline\(&' > /tmp/mondo.quality
     51pbg 'mr_asprintf\(\&' > /tmp/mondo.quality
    5252cat /tmp/mondo.quality
    53 echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` mr_getline without &"
     53echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` mr_asprintf with \&"
     54pbg 'mr_getline\(\&' > /tmp/mondo.quality
     55cat /tmp/mondo.quality
     56echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` mr_getline with \&"
    5457
    5558echo " "
Note: See TracChangeset for help on using the changeset viewer.