Ignore:
Timestamp:
Jul 17, 2006, 3:44:46 PM (14 years ago)
Author:
bcornec
Message:

Huge memory management patch.
Still not finished but a lot as been done.
What remains is around some functions returning strings, and some structure members.
(Could not finish due to laptop failure !)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/mondorestore/mondo-rstr-newt.c

    r539 r688  
    11/***************************************************************************
    22 * $Id$
    3 */
     3**/
    44
    55
     
    1111#ifdef __FreeBSD__
    1212#define OSSWAP(linux,fbsd) fbsd
    13 //#include <libgen.h>
    1413#else
    1514#define OSSWAP(linux,fbsd) linux
     
    1716
    1817#include "mondo-rstr-newt.h"
    19 
    20 //static char cvsid[] = "$Id$";
    21 
    22 extern char err_log_lines[NOOF_ERR_LINES][MAX_STR_LEN];
    23 
    2418
    2519/**
     
    5751{
    5852    /** buffers ***********************************************************/
    59     char *tmp;
     53    char *tmp = NULL;
    6054
    6155    /** newt **************************************************************/
     
    8276
    8377    newtPushHelpLine
    84         (_("   Add one of the following unallocated RAID partitions to this RAID device."));
     78        (_
     79         ("   Add one of the following unallocated RAID partitions to this RAID device."));
    8580    asprintf(&tmp, "%-26s %s", _("Device"), _("Size"));
    8681    headerMsg = newtLabel(1, 1, tmp);
     
    157152    newtComponent formatComp;
    158153
    159     /** buffers **********************************************************/
    160     char *drive_to_add;
    161     char *mountpoint_str;
     154    char *drive_to_add = NULL;
     155    char *mountpoint_str = NULL;
    162156    char *size_str = NULL;
    163     char *device_str;
    164     char *format_str;
    165 
    166     /** pointers *********************************************************/
    167     char *mountpoint_here;
    168     char *size_here;
    169     char *device_here;
    170     char *format_here;
     157    char *device_str = NULL;
     158    char *format_str = NULL;
     159    char *mountpoint_here = NULL;
     160    char *size_here = NULL;
     161    char *device_here = NULL;
     162    char *format_here = NULL;
    171163
    172164    assert(mountlist != NULL);
     
    198190    bCancel = newtButton(17, 6, _("Cancel"));
    199191    newtPushHelpLine
    200         (_("To add an entry to the mountlist, please fill in these fields and then hit 'OK'"));
     192        (_
     193         ("To add an entry to the mountlist, please fill in these fields and then hit 'OK'"));
    201194    myForm = newtForm(NULL, NULL, 0);
    202195    newtFormAddComponents(myForm, deviceComp, mountpointComp, sizeComp,
     
    229222            if (size_of_specific_device_in_mountlist(mountlist, device_str)
    230223                >= 0) {
    231                 popup_and_OK(_("Can't add this - you've got one already!"));
     224                popup_and_OK(_
     225                             ("Can't add this - you've got one already!"));
    232226                b_res = NULL;
    233227            }
     
    286280
    287281    if (popup_and_get_string
    288         ("Add variable", _("Enter the name of the variable to add"), sz_out,
    289          MAX_STR_LEN)) {
    290         strip_spaces(sz_out);
     282        ("Add variable", _("Enter the name of the variable to add"),
     283         sz_out)) {
    291284        items = raidrec->additional_vars.entries;
    292285        for (i = 0;
     
    295288        if (i < items) {
    296289            popup_and_OK
    297                 (_("No need to add that variable. It is already listed here."));
     290                (_
     291                 ("No need to add that variable. It is already listed here."));
    298292        } else {
    299293            strcpy(raidrec->additional_vars.el[items].label, sz_out);
     
    302296        }
    303297    }
     298    paranoid_free(sz_out);
    304299}
    305300#endif
     
    322317
    323318    /** structures ********************************************************/
    324     struct vinum_volume *raidrec;
    325 
    326     /** int ***************************************************************/
     319    struct vinum_volume *raidrec = NULL;
     320
    327321    int i = 0, j = 0;
    328322    int noof_partitions = 0;
    329323
    330     /** long **************************************************************/
    331324    long total_size = 0;
    332325    long plex_size = 0;
     
    335328    long sp = 0;
    336329
    337     /** buffers ***********************************************************/
    338     char *tmp;
    339     char *devname;
    340 
    341 
    342 
     330    char *tmp = NULL;
     331    char *devname = NULL;
    343332
    344333    for (i = 0;
     
    347336    if (i == raidlist->entries) {
    348337        asprintf(&tmp,
    349                 "Cannot calc size of raid device %s - cannot find it in raidlist",
    350                 raid_device);
     338                 "Cannot calc size of raid device %s - cannot find it in raidlist",
     339                 raid_device);
    351340        log_it(tmp);
    352341        paranoid_free(tmp);
     
    411400    }
    412401
    413     asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device,
    414             (long) smallest_plex);
     402    asprintf(&tmp, "I have calculated %s's real size to be %ld",
     403             raid_device, (long) smallest_plex);
    415404    log_it(tmp);
    416405    paranoid_free(tmp);
     
    420409
    421410    /** structures ********************************************************/
    422     struct raid_device_record *raidrec;
     411    struct raid_device_record *raidrec = NULL;
    423412
    424413    /** int ***************************************************************/
     
    432421
    433422    /** buffers ***********************************************************/
    434     char *tmp;
     423    char *tmp = NULL;
    435424
    436425    assert(mountlist != NULL);
     
    443432    if (i == raidlist->entries) {
    444433        asprintf(&tmp,
    445                 "Cannot calc size of raid device %s - cannot find it in raidlist",
    446                 raid_device);
     434                 "Cannot calc size of raid device %s - cannot find it in raidlist",
     435                 raid_device);
    447436        log_it(tmp);
    448437        paranoid_free(tmp);
     
    469458        total_size = smallest_partition * (noof_partitions - 1);
    470459    }
    471     asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device,
    472             (long) total_size);
     460    asprintf(&tmp, "I have calculated %s's real size to be %ld",
     461             raid_device, (long) total_size);
    473462    log_it(tmp);
    474463    paranoid_free(tmp);
     
    478467
    479468
    480 
    481469/**
    482470 * Choose the RAID level for the RAID device record in @p raidrec.
     
    495483
    496484    /** buffers ***********************************************************/
    497     char *tmp;
    498     char *prompt;
    499     char *sz;
     485    char *tmp = NULL;
     486    char *prompt = NULL;
     487    char *sz = NULL;
    500488
    501489    asprintf(&prompt,
    502             _("Please enter the RAID level you want. (concat, striped, raid5)"));
     490             _
     491             ("Please enter the RAID level you want. (concat, striped, raid5)"));
    503492    if (raidrec->raidlevel == -1) {
    504493        asprintf(&tmp, "concat");
     
    509498    }
    510499    for (out = 999; out == 999;) {
    511         res = popup_and_get_string("Specify RAID level", prompt, tmp, 10);
     500        res = popup_and_get_string("Specify RAID level", prompt, tmp);
    512501        if (!res) {
    513502            return;
    514503        }
    515         strip_spaces(tmp);
     504        /* BERLIOS: Useless ???
    516505        if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') {
    517506            asprintf(&sz, tmp);
     
    520509            paranoid_free(sz);
    521510        }
     511        */
    522512        if (!strcmp(tmp, "concat")) {
    523513            out = -1;
     
    544534#else
    545535    /** buffers ***********************************************************/
    546     char *tmp;
    547     char personalities[MAX_STR_LEN];
    548     char *prompt;
    549     char *sz;
     536    char *tmp = NULL;
     537    char *personalities = NULL;
     538    char *prompt = NULL;
     539    char *sz = NULL;
    550540    int out = 0, res = 0;
    551541
     
    554544    system
    555545        ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null");
    556     strcpy(personalities,
    557            last_line_of_file("/tmp/raid-personalities.txt"));
     546    personalities = last_line_of_file("/tmp/raid-personalities.txt"));
    558547    asprintf(&prompt, _("Please enter the RAID level you want. %s"),
    559             personalities);
     548             personalities);
     549    paranoid_free(personalities);
     550
    560551    if (raidrec->raid_level == -1) {
    561552        asprintf(&tmp, "linear");
     
    566557         out != -1 && out != 0 && out != 1 && out != 4 && out != 5
    567558         && out != 10;) {
    568         res = popup_and_get_string(_("Specify RAID level"), prompt, tmp, 10);
     559        res =
     560            popup_and_get_string(_("Specify RAID level"), prompt, tmp);
    569561        if (!res) {
    570562            return;
    571563        }
    572         strip_spaces(tmp);
     564        /* BERLIOS: Useless ???
    573565        if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') {
    574566            asprintf(&sz, tmp);
    575             strncpy(tmp, sz + 1, strlen(sz) - 2);
     567            paranoid_free(tmp);
     568
     569            asprintf(&tmp, sz + 1);
    576570            tmp[strlen(sz) - 2] = '\0';
    577571            paranoid_free(sz);
    578572        }
     573        */
    579574        if (!strcmp(tmp, "linear")) {
    580575            out = -1;
     
    585580        }
    586581        log_it(tmp);
    587         paranoid_free(tmp);
    588582        if (is_this_raid_personality_registered(out)) {
    589583            log_it
     
    591585        } else {
    592586            if (ask_me_yes_or_no
    593                 (_("You have chosen a RAID personality which is not registered with the kernel. Make another selection?")))
     587                (_
     588                 ("You have chosen a RAID personality which is not registered with the kernel. Make another selection?")))
    594589            {
    595590                out = 999;
     
    597592        }
    598593    }
     594    paranoid_free(tmp);
    599595    paranoid_free(prompt);
    600596    raidrec->raid_level = out;
     
    622618
    623619    /** buffers ***********************************************************/
    624     char *tmp;
     620    char *tmp = NULL;
    625621
    626622    assert(mountlist != NULL);
     
    634630             pos++);
    635631        if (pos < mountlist->entries) {
    636             asprintf(&tmp,
    637                     "Deleting partition %s cos it was part of a now-defunct RAID",
    638                     mountlist->el[pos].device);
    639             log_it(tmp);
    640             paranoid_free(tmp);
     632            log_it("Deleting partition %s cos it was part of a now-defunct RAID",
     633                     mountlist->el[pos].device);
    641634            memcpy((void *) &mountlist->el[pos],
    642635                   (void *) &mountlist->el[mountlist->entries - 1],
     
    665658
    666659    /** buffers ***********************************************************/
    667     char *tmp;
     660    char *tmp = NULL;
    668661
    669662    assert(disklist != NULL);
     
    671664
    672665    asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"),
    673             disklist->el[currline].device, raid_device);
     666             disklist->el[currline].device, raid_device);
    674667    if (!ask_me_yes_or_no(tmp)) {
    675668        paranoid_free(tmp);
     
    705698
    706699    /** buffers ***********************************************************/
    707     char *tmp;
    708     char *device;
     700    char *tmp = NULL;
     701    char *device = NULL;
    709702
    710703    assert(mountlist != NULL);
     
    718711                                                  device);
    719712    if (pos >= 0) {
    720         asprintf(&tmp, _("Cannot delete %s: it is in use by RAID device %s"),
    721                 mountlist->el[currline].device,
    722                 raidlist->el[pos].OSSWAP(raid_device, volname));
     713        asprintf(&tmp,
     714                 _("Cannot delete %s: it is in use by RAID device %s"),
     715                 mountlist->el[currline].device,
     716                 raidlist->el[pos].OSSWAP(raid_device, volname));
    723717        popup_and_OK(tmp);
    724718        paranoid_free(tmp);
     
    726720    }
    727721    asprintf(&tmp, _("Delete %s - are you sure?"),
    728             mountlist->el[currline].device);
     722             mountlist->el[currline].device);
    729723    if (!ask_me_yes_or_no(tmp)) {
    730724        paranoid_free(tmp);
     
    740734             && strcmp(mountlist->el[currline].device, device);
    741735             currline++);
    742         if (currline == mountlist->entries) {
    743             log_it("Dev is gone. I can't delete it. Ho-hum");
    744             paranoid_free(device);
    745             return;
    746         }
     736            if (currline == mountlist->entries) {
     737                log_it("Dev is gone. I can't delete it. Ho-hum");
     738                paranoid_free(device);
     739                return;
     740            }
    747741        paranoid_free(device);
    748742    }
     
    775769
    776770    /** buffers ***********************************************************/
    777     char *tmp;
     771    char *tmp = NULL;
    778772
    779773    assert(mountlist != NULL);
     
    785779        return;
    786780    }
    787     asprintf(&tmp, _("Do you want me to delete %s's partitions, too?", device));
     781    asprintf(&tmp,
     782             _("Do you want me to delete %s's partitions, too?"), device);
    788783    delete_partitions_too = ask_me_yes_or_no(tmp);
    789784    if (delete_partitions_too) {
     
    846841
    847842    /** buffers ************************************************************/
    848     char *tmp;
     843    char *tmp = NULL;
    849844
    850845    /** structures *********************************************************/
    851     struct additional_raid_variables *av;
     846    struct additional_raid_variables *av = NULL;
    852847
    853848    assert(raidrec != NULL);
    854849
    855850    av = &raidrec->additional_vars;
    856     asprintf(&tmp, _("Delete %s - are you sure?", av->el[lino].label));
     851    asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label);
    857852    if (ask_me_yes_or_no(tmp)) {
    858853        if (!strcmp(av->el[lino].label, "persistent-superblock")
     
    860855            paranoid_free(tmp);
    861856            asprintf(&tmp, _("%s must not be deleted. It would be bad."),
    862                     av->el[lino].label);
     857                     av->el[lino].label);
    863858            popup_and_OK(tmp);
    864859        } else {
     
    891886
    892887    /** structures *******************************************************/
    893     struct s_node *node;
     888    struct s_node *node = NULL;
    894889
    895890    /** buffers **********************************************************/
    896     static char *current_filename;
    897     char *tmp;
     891    static char *current_filename = NULL;
     892    char *tmp = NULL;
    898893
    899894    /** bool *************************************************************/
     
    905900    assert(keylist != NULL);
    906901    assert(listbox != NULL);
    907 
    908902
    909903    if (depth == 0) {
     
    927921                    warned_already = TRUE;
    928922                    asprintf(&tmp,
    929                             _("Too many lines. Displaying first %d entries only. Close a directory to see more."),
    930                             ARBITRARY_MAXIMUM);
     923                             _
     924                             ("Too many lines. Displaying first %d entries only. Close a directory to see more."),
     925                             ARBITRARY_MAXIMUM);
    931926                    popup_and_OK(tmp);
    932927                    paranoid_free(tmp);
     
    964959        newtListboxClear(listbox);
    965960        for (i = 0; i < lines_in_flist_window; i++) {
    966             asprintf(&tmp, "%c%c %-80s", (g_is_path_selected[i] ? '*' : ' '),
    967                     (g_is_path_expanded[i] ? '+' : '-'),
    968                     strip_path(g_strings_of_flist_window[i]));
    969             // BERLIOS: this is dangerous now
     961            asprintf(&tmp, "%c%c %-80s",
     962                     (g_is_path_selected[i] ? '*' : ' '),
     963                     (g_is_path_expanded[i] ? '+' : '-'),
     964                     strip_path(g_strings_of_flist_window[i]));
     965            // BERLIOS: this is dangerous now  => Memory leak
    970966            if (strlen(tmp) > 71) {
    971967                tmp[70] = '\0';
     
    10111007        slashcount--;           /* Keep one slash 'cos Hugh does... */
    10121008
     1009    /* BERLIOS: tmpnopath and prev not defined !! How can this compile ?? */
    10131010    for (i = 0; i < slashcount; i++) {  /* Replace each dir with a space char */
    10141011        tmpnopath[i] = ' ';
     
    10621059    void *keylist[ARBITRARY_MAXIMUM];
    10631060
    1064     /** buffers ***********************************************************/
    1065     char tmp[MAX_STR_LEN];
    1066 
    10671061    /** bool **************************************************************/
    10681062    bool dummybool;
     
    10741068    log_to_screen(_("Editing filelist"));
    10751069    newtPushHelpLine
    1076         (_("   Please edit the filelist to your satisfaction, then click OK or Cancel."));
     1070        (_
     1071         ("   Please edit the filelist to your satisfaction, then click OK or Cancel."));
    10771072    j = 4;
    10781073    bLess = newtCompactButton(j, 17, _(" Less "));
     
    11111106                indexno = 0;
    11121107            }
    1113             sprintf(tmp, "You selected '%s'",
     1108            log_it("You selected '%s'",
    11141109                    g_strings_of_flist_window[indexno]);
    1115             log_it(tmp);
    11161110            if (b_res == bMore) {
    11171111                g_is_path_expanded[indexno] = TRUE;
     
    12041198    newtComponent b_raid = NULL;
    12051199
    1206   /** buffers ***********************************************************/
    1207     char device_str[MAX_STR_LEN];
    1208     char mountpoint_str[MAX_STR_LEN];
    1209     char size_str[MAX_STR_LEN];
    1210     char format_str[MAX_STR_LEN];
    1211     char tmp[MAX_STR_LEN];
    1212     char device_used_to_be[MAX_STR_LEN];
    1213     char mountpt_used_to_be[MAX_STR_LEN];
    1214 
    1215     /** pointers **********************************************************/
    1216     char *device_here;
    1217     char *mountpoint_here;
    1218     char *size_here;
    1219     char *format_here;
    1220 
    1221     /** int ***************************************************************/
     1200    char *device_str = NULL;
     1201    char *mountpoint_str = NULL;
     1202    char *size_str = NULL;
     1203    char *format_str = NULL;
     1204    char *tmp = NULL;
     1205    char *device_used_to_be = NULL;
     1206    char *mountpt_used_to_be = NULL;
     1207    char *device_here = NULL;
     1208    char *mountpoint_here = NULL;
     1209    char *size_here = NULL;
     1210    char *format_here = NULL;
     1211
    12221212    int j = 0;
    12231213
     
    12291219    memcpy((void *) &bkp_raidlist, (void *) raidlist,
    12301220           sizeof(struct raidlist_itself));
    1231     strcpy(device_str, mountlist->el[currline].device);
    1232     strcpy(device_used_to_be, mountlist->el[currline].device);
    1233     strcpy(mountpoint_str, mountlist->el[currline].mountpoint);
    1234     strcpy(mountpt_used_to_be, mountlist->el[currline].mountpoint);
    1235     strcpy(format_str, mountlist->el[currline].format);
    1236     sprintf(size_str, "%lld", mountlist->el[currline].size / 1024);
     1221    asprintf(&device_str, mountlist->el[currline].device);
     1222    asprintf(&device_used_to_be, mountlist->el[currline].device);
     1223    asprintf(&mountpoint_str, mountlist->el[currline].mountpoint);
     1224    asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint);
     1225    asprintf(&format_str, mountlist->el[currline].format);
     1226    asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024);
     1227
    12371228    newtOpenWindow(20, 5, 48, 10, "Edit entry");
    12381229    label0 = newtLabel(2, 1, _("Device:"));
     
    12421233    deviceComp =
    12431234        newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
     1235    paranoid_free(device_str);
     1236
    12441237    mountpointComp =
    12451238        newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
     1239    paranoid_free(mountpoint_str);
     1240
    12461241    formatComp =
    12471242        newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
     1243    paranoid_free(format_str);
     1244
    12481245    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    12491246        || !strcmp(mountlist->el[currline].mountpoint, "image")) {
     
    12521249        sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0);
    12531250    }
     1251    paranoid_free(size_str);
     1252
    12541253    bOK = newtButton(2, 6, _("  OK  "));
    12551254    bCancel = newtButton(14, 6, _("Cancel"));
     
    12581257    }
    12591258    newtPushHelpLine
    1260         (_("       Edit this partition's mountpoint, size and format; then click 'OK'."));
     1259        (_
     1260         ("       Edit this partition's mountpoint, size and format; then click 'OK'."));
    12611261    myForm = newtForm(NULL, NULL, 0);
    12621262    newtFormAddComponents(myForm, deviceComp, mountpointComp, sizeComp,
     
    12651265    for (b_res = NULL; b_res != bOK && b_res != bCancel;) {
    12661266        b_res = newtRunForm(myForm);
    1267         strcpy(device_str, device_here);
     1267
     1268        paranoid_free(device_str);
     1269        asprintf(&device_str, device_here);
    12681270        strip_spaces(device_str);
    1269         strcpy(mountpoint_str, mountpoint_here);
     1271
     1272        paranoid_free(mountpoint_str);
     1273        asprintf(&mountpoint_str, mountpoint_here);
    12701274        strip_spaces(mountpoint_str);
    1271         strcpy(format_str, format_here);
     1275
     1276        paranoid_free(format_str);
     1277        asprintf(&format_str, format_here);
     1278        paranoid_free(format_here);
    12721279        strip_spaces(format_str);
    12731280        if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB)
     
    12791286        } else if (b_res == bOK && !strcmp(mountpoint_str, "image")
    12801287                   && strcmp(mountpt_used_to_be, "image")) {
    1281             popup_and_OK(_("You can't change a regular device to an image."));
     1288            popup_and_OK(_
     1289                         ("You can't change a regular device to an image."));
    12821290            b_res = NULL;
    12831291            continue;
    12841292        }
     1293        paranoid_free(mountpt_used_to_be);
     1294
    12851295        if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    12861296            && strcmp(mountlist->el[currline].mountpoint, "image")) {
    1287             strcpy(size_str, size_here);
     1297            asprintf(&size_str, size_here);
    12881298            strip_spaces(size_str);
    12891299        } else {
    1290             sprintf(size_str, "%ld",
     1300            asprintf(&size_str, "%ld",
    12911301                    calculate_raid_device_size(mountlist, raidlist,
    12921302                                               mountlist->el[currline].
     
    12941304            newtLabelSetText(sizeComp, size_str);
    12951305        }
     1306        paranoid_free(size_here);
     1307
    12961308        /* do not let user click RAID button if user has changed device_str */
    12971309        if (b_res == b_raid) {
     
    13021314                 */
    13031315                popup_and_OK
    1304                     (_("You cannot edit the RAID settings until you have OK'd your change to the device node."));
     1316                    (_
     1317                     ("You cannot edit the RAID settings until you have OK'd your change to the device node."));
    13051318            } else {
    13061319                j = find_raid_device_in_raidlist(raidlist,
     
    13091322                if (j < 0) {
    13101323                    sprintf(tmp,
    1311                             _("/etc/raidtab does not have an entry for %s; please delete it and add it again"),
     1324                            _
     1325                            ("/etc/raidtab does not have an entry for %s; please delete it and add it again"),
    13121326                            mountlist->el[currline].device);
    13131327                    popup_and_OK(tmp);
     
    13201334        }
    13211335    }
     1336    paranoid_free(device_here);
     1337    paranoid_free(mountpoint_here);
     1338
    13221339    newtFormDestroy(myForm);
    13231340    newtPopHelpLine();
     
    13301347    strcpy(mountlist->el[currline].device, device_str);
    13311348    strcpy(mountlist->el[currline].mountpoint, mountpoint_str);
     1349    paranoid_free(mountpoint_str);
     1350
    13321351    strcpy(mountlist->el[currline].format, format_str);
     1352    paranoid_free(format_str);
     1353
    13331354    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    13341355        || !strcmp(mountlist->el[currline].mountpoint, "image")) {
     
    13391360        mountlist->el[currline].size = atol(size_str) * 1024;
    13401361    }
     1362    paranoid_free(size_str);
     1363
    13411364    newtListboxSetEntry(listbox, (int) keylist[currline],
    13421365                        mountlist_entry_to_string(mountlist, currline));
     
    13631386    else if (strcmp(device_used_to_be, device_str)) {
    13641387        popup_and_OK
    1365             (_("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it."));
     1388            (_
     1389             ("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it."));
    13661390    }
    13671391#endif
    13681392    redraw_mountlist(mountlist, keylist, listbox);
     1393    paranoid_free(device_str);
     1394    paranoid_free(device_used_to_be);
    13691395}
    13701396
     
    14251451}
    14261452
     1453
    14271454void
    14281455edit_raidlist_plex(struct mountlist_itself *mountlist,
     
    14551482
    14561483    /** buffers ***********************************************************/
    1457     char title_of_editraidForm_window[MAX_STR_LEN];
     1484    char *title_of_editraidForm_window;
    14581485
    14591486    /** newt **************************************************************/
     
    14721499
    14731500    int currline2 = 0;
     1501    char *pname = NULL;
     1502    char *raidlevel = NULL;
     1503    char *chunksize = NULL;
     1504    char *entry = NULL;
     1505    char *msg = NULL;
     1506    int i = 0;
     1507    char *headerstr = NULL;
    14741508
    14751509    log_it(_("Started edit_raidlist_entry"));
    14761510    memcpy((void *) &bkp_raidrec, (void *) raidrec,
    14771511           sizeof(struct vinum_volume));
    1478     sprintf(title_of_editraidForm_window, _("Plexes on %s"),
     1512    asprintf(&title_of_editraidForm_window, _("Plexes on %s"),
    14791513            raidrec->volname);
    14801514    newtPushHelpLine(_("   Please select a plex to edit"));
    14811515    newtOpenWindow(13, 5, 54, 15, title_of_editraidForm_window);
     1516    paranoid_free(title_of_editraidForm_window);
     1517
    14821518    for (;;) {
    1483         int i;
    1484         char headerstr[MAX_STR_LEN];
    1485         snprintf(headerstr, MAX_STR_LEN, "%-14s %-8s  %11s  %8s",
    1486                  _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks"));
     1519        asprintf(&headerstr, "%-14s %-8s  %11s  %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks"));
    14871520
    14881521        bOK = newtCompactButton(2, 13, _("  OK  "));
     
    14951528            newtListbox(2, 3, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
    14961529        plexesHeader = newtLabel(2, 2, headerstr);
     1530        paranoid_free(headerstr);
     1531
    14971532        editraidForm = newtForm(NULL, NULL, 0);
    14981533
     
    15011536            keylist[i] = (void *) i;
    15021537            if (i < raidrec->plexes) {
    1503                 char pname[64], entry[MAX_STR_LEN], raidlevel[64],
    1504                     chunksize[64];
    15051538                switch (raidrec->plex[i].raidlevel) {
    15061539                case -1:
    1507                     strcpy(raidlevel, "concat");
     1540                    asprintf(&raidlevel, "concat");
    15081541                    break;
    15091542                case 0:
    1510                     strcpy(raidlevel, "striped");
     1543                    asprintf(&raidlevel, "striped");
    15111544                    break;
    15121545                case 5:
    1513                     strcpy(raidlevel, "raid5");
     1546                    asprintf(&raidlevel, "raid5");
    15141547                    break;
    15151548                default:
    1516                     sprintf(raidlevel, "raid%i",
     1549                    asprintf(&raidlevel, "raid%i",
    15171550                            raidrec->plex[i].raidlevel);
    15181551                    break;
     
    15201553
    15211554                if (raidrec->plex[i].raidlevel == -1) {
    1522                     strcpy(chunksize, "N/A");
     1555                    asprintf(&chunksize, "N/A");
    15231556                } else {
    1524                     sprintf(chunksize, "%dk", raidrec->plex[i].stripesize);
     1557                    asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize);
    15251558                }
    1526                 snprintf(pname, 64, "%s.p%i", raidrec->volname, i);
    1527                 snprintf(entry, MAX_STR_LEN, "%-14s %-8s  %11s  %8d",
     1559                asprintf(&pname, "%s.p%i", raidrec->volname, i);
     1560                asprintf(&entry, "%-14s %-8s  %11s  %8d",
    15281561                         pname, raidlevel, chunksize,
    15291562                         raidrec->plex[i].subdisks);
     1563                paranoid_free(pname);
     1564                paranoid_free(chunksize);
     1565                paranoid_free(raidlevel);
    15301566                newtListboxAppendEntry(plexesListbox, entry, keylist[i]);
     1567                paranoid_free(entry);
    15311568            }
    15321569        }
     
    15491586
    15501587        if (b_res == bDelete) {
    1551             char msg[MAX_STR_LEN];
    1552             sprintf(msg, _("Are you sure you want to delete %s.p%i?"),
     1588            asprintf(&msg, _("Are you sure you want to delete %s.p%i?"),
    15531589                    raidrec->volname, currline2);
    15541590            if (ask_me_yes_or_no(msg)) {
     
    15591595                raidrec->plexes--;
    15601596            }
     1597            paranoid_free(msg);
    15611598            continue;
    15621599        }
     
    15811618#else
    15821619    /** structures ********************************************************/
    1583     struct raid_device_record *bkp_raidrec;
     1620    struct raid_device_record *bkp_raidrec = NULL;
    15841621
    15851622
    15861623    /** buffers ***********************************************************/
    1587     char *title_of_editraidForm_window;
    1588     char *sz_raid_level;
    1589     char *sz_data_disks;
    1590     char *sz_spare_disks;
    1591     char *sz_parity_disks;
    1592     char *sz_failed_disks;
     1624    char *title_of_editraidForm_window = NULL;
     1625    char *sz_raid_level = NULL;
     1626    char *sz_data_disks = NULL;
     1627    char *sz_spare_disks = NULL;
     1628    char *sz_parity_disks = NULL;
     1629    char *sz_failed_disks = NULL;
    15931630
    15941631    /** newt **************************************************************/
     
    16081645    assert(raidrec != NULL);
    16091646
    1610     malloc_string(title_of_editraidForm_window);
    1611     malloc_string(sz_raid_level);
    1612     malloc_string(sz_data_disks);
    1613     malloc_string(sz_spare_disks);
    1614     malloc_string(sz_parity_disks);
    1615     malloc_string(sz_failed_disks);
    16161647    if (!(bkp_raidrec = malloc(sizeof(struct raid_device_record)))) {
    16171648        fatal_error("Cannot malloc space for raidrec");
     
    16221653    memcpy((void *) bkp_raidrec, (void *) raidrec,
    16231654           sizeof(struct raid_device_record));
    1624     sprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);
     1655    asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device);
    16251656    log_msg(2, "Opening newt window");
    16261657    newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window);
     1658    paranoid_free(title_of_editraidForm_window);
     1659
    16271660    for (;;) {
    16281661        log_msg(2, "Main loop");
    1629         sprintf(title_of_editraidForm_window, _("Edit %s"),
    1630                 raidrec->raid_device);
    1631         strcpy(sz_raid_level,
     1662        asprintf(&sz_raid_level,
    16321663               turn_raid_level_number_to_string(raidrec->raid_level));
    1633         strcpy(sz_data_disks,
     1664        asprintf(&sz_data_disks,
    16341665               number_of_disks_as_string(raidrec->data_disks.entries,
    16351666                                         _("data")));
    1636         strcpy(sz_spare_disks,
     1667        asprintf(&sz_spare_disks,
    16371668               number_of_disks_as_string(raidrec->spare_disks.entries,
    16381669                                         _("spare")));
    1639         strcpy(sz_parity_disks,
     1670        asprintf(&sz_parity_disks,
    16401671               number_of_disks_as_string(raidrec->parity_disks.entries,
    16411672                                         _("parity")));
    1642         strcpy(sz_failed_disks,
     1673        asprintf(&sz_failed_disks,
    16431674               number_of_disks_as_string(raidrec->failed_disks.entries,
    16441675                                         _("failed")));
     
    16481679        bSelectFailed = newtButton(20, 5, sz_failed_disks);
    16491680        bChangeRaid = newtButton(1, 9, sz_raid_level);
     1681        paranoid_free(sz_raid_level);
     1682        paranoid_free(sz_data_disks);
     1683        paranoid_free(sz_spare_disks);
     1684        paranoid_free(sz_parity_disks);
     1685        paranoid_free(sz_failed_disks);
     1686
    16501687        bOK = newtButton(16 + (raidrec->raid_level == -1), 9, _("  OK  "));
    16511688        bCancel = newtButton(28, 9, _("Cancel"));
     
    16541691                              _("Additional settings and information"));
    16551692        newtPushHelpLine
    1656             (_("  Edit the RAID device's settings to your heart's content, then hit OK/Cancel."));
     1693            (_
     1694             ("  Edit the RAID device's settings to your heart's content, then hit OK/Cancel."));
    16571695        editraidForm = newtForm(NULL, NULL, 0);
    16581696        newtFormAddComponents(editraidForm, bSelectData, bSelectParity,
     
    16911729        calculate_raid_device_size(mountlist, raidlist,
    16921730                                   raidrec->raid_device);
    1693     paranoid_free(title_of_editraidForm_window);
    1694     paranoid_free(sz_raid_level);
    1695     paranoid_free(sz_data_disks);
    1696     paranoid_free(sz_spare_disks);
    1697     paranoid_free(sz_parity_disks);
    1698     paranoid_free(sz_failed_disks);
    16991731    paranoid_free(bkp_raidrec);
    17001732#endif
    17011733}
    1702 
    17031734#ifdef __FreeBSD__
     1735
    17041736
    17051737/**
     
    17241756
    17251757    /** buffers ***********************************************************/
    1726     char title_of_editraidForm_window[MAX_STR_LEN];
     1758    char *title_of_editraidForm_window = NULL;
     1759    char *tmp = NULL;
     1760    char *entry = NULL;
    17271761
    17281762    /** newt **************************************************************/
     
    17421776    void *curr_choice_a, *curr_choice_u;
    17431777    int currline_a, currline_u;
    1744 
    1745     struct mountlist_itself *unallocparts;
    1746 
     1778    int i;
     1779
     1780    struct mountlist_itself *unallocparts = NULL;
     1781
     1782    /* BERLIOS: Check return value */
    17471783    unallocparts = malloc(sizeof(struct mountlist_itself));
    17481784
     
    17501786    memcpy((void *) &bkp_raidrec, (void *) raidrec,
    17511787           sizeof(struct vinum_plex));
    1752     sprintf(title_of_editraidForm_window, "%s.p%i",
     1788    asprintf(&title_of_editraidForm_window, "%s.p%i",
    17531789            raidlist->el[currline].volname, currline2);
    17541790    newtPushHelpLine
    1755         (_("   Please select a subdisk to edit, or edit this plex's parameters"));
     1791        (_
     1792         ("   Please select a subdisk to edit, or edit this plex's parameters"));
    17561793    newtOpenWindow(13, 3, 54, 18, title_of_editraidForm_window);
     1794    paranoid_free(title_of_editraidForm_window);
     1795
    17571796    for (;;) {
    1758         int i;
    1759         char headerstr[MAX_STR_LEN];
    1760         char tmp[64];
    1761         snprintf(headerstr, MAX_STR_LEN, "%-24s %s", _("Subdisk"), _("Device"));
    1762 
    1763 
    17641797        switch (raidrec->raidlevel) {
    17651798        case -1:
    1766             strcpy(tmp, "concat");
     1799            asprintf(&tmp, "concat");
    17671800            break;
    17681801        case 0:
    1769             strcpy(tmp, "striped");
     1802            asprintf(&tmp, "striped");
    17701803            break;
    17711804        case 5:
    1772             strcpy(tmp, "raid5");
     1805            asprintf(&tmp, "raid5");
    17731806            break;
    17741807        default:
    1775             sprintf(tmp, _("unknown (%i)"), raidrec->raidlevel);
     1808            asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel);
    17761809            break;
    17771810        }
    17781811        bLevel = newtCompactButton(2, 2, _(" RAID level "));
    17791812        sLevel = newtLabel(19, 2, tmp);
     1813        paranoid_free(tmp);
    17801814
    17811815        if (raidrec->raidlevel >= 0) {
    1782             sprintf(tmp, "%ik", raidrec->stripesize);
     1816            asprintf(&tmp, "%ik", raidrec->stripesize);
    17831817            bStripeSize = newtCompactButton(2, 4, _(" Stripe size "));
    17841818        } else {
    1785             strcpy(tmp, "N/A");
     1819            asprintf(&tmp, "N/A");
    17861820            bStripeSize = newtLabel(2, 4, _("Stripe size:"));
    17871821        }
    17881822        sStripeSize = newtLabel(19, 4, tmp);
     1823        paranoid_free(tmp);
    17891824
    17901825        bOK = newtCompactButton(2, 16, _("  OK  "));
     
    17961831
    17971832        //  plexesListbox = newtListbox (2, 7, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
    1798         //  plexesHeader  = newtLabel (2, 6, headerstr);
    17991833        unallocListbox =
    18001834            newtListbox(2, 7, 7, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
     
    18121846                                                 raidlist);
    18131847        for (i = 0; i < ARBITRARY_MAXIMUM; ++i) {
    1814             char entry[MAX_STR_LEN];
    18151848            keylist[i] = (void *) i;
    18161849            if (i < raidrec->subdisks) {
    1817                 snprintf(entry, MAX_STR_LEN, "%-17s",
     1850                asprintf(&entry, "%-17s",
    18181851                         find_dev_entry_for_raid_device_name(raidlist,
    18191852                                                             raidrec->
     
    18211854                                                             which_device));
    18221855                newtListboxAppendEntry(allocListbox, entry, keylist[i]);
     1856                paranoid_free(entry);
    18231857            }
    18241858            if (i < unallocparts->entries) {
    1825                 snprintf(entry, MAX_STR_LEN, "%-17s",
    1826                          unallocparts->el[i].device);
     1859                asprintf(&entry, "%-17s", unallocparts->el[i].device);
    18271860                newtListboxAppendEntry(unallocListbox, entry, keylist[i]);
     1861                paranoid_free(entry);
    18281862            }
    18291863        }
     
    18751909            choose_raid_level(raidrec);
    18761910        } else if (b_res == bStripeSize) {
    1877             char tmp[64];
    1878             sprintf(tmp, "%i", raidrec->stripesize);
     1911            asprintf(&tmp, "%i", raidrec->stripesize);
    18791912            if (popup_and_get_string
    18801913                (_("Stripe size"),
    1881                  _("Please enter the stripe size in kilobytes."), tmp, 20)) {
     1914                 _("Please enter the stripe size in kilobytes."), tmp)) {
    18821915                raidrec->stripesize = atoi(tmp);
    18831916            }
     1917            paranoid_free(tmp);
    18841918        } else if ((b_res == bAlloc) || (b_res == unallocListbox)) {
    18851919            if (currline_u <= unallocparts->entries)
     
    19221956
    19231957    /** buffers ***********************************************************/
    1924     char header[MAX_STR_LEN];
    1925     char comment[MAX_STR_LEN];
    1926     char sz_out[MAX_STR_LEN];
     1958    char *header = NULL;
     1959    char *comment = NULL;
     1960    char *sz_out = NULL;
    19271961
    19281962    assert(raidrec != 0);
    19291963    assert(lino >= 0);
    19301964
    1931     strcpy(sz_out, raidrec->additional_vars.el[lino].value);
    1932     sprintf(header, _("Edit %s"), raidrec->additional_vars.el[lino].label);
    1933     sprintf(comment, _("Please set %s's value (currently '%s')"),
     1965    asprintf(&sz_out, raidrec->additional_vars.el[lino].value);
     1966    asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label);
     1967    asprintf(&comment, _("Please set %s's value (currently '%s')"),
    19341968            raidrec->additional_vars.el[lino].label, sz_out);
    1935     if (popup_and_get_string(header, comment, sz_out, MAX_STR_LEN)) {
    1936         strip_spaces(sz_out);
     1969    if (popup_and_get_string(header, comment, sz_out)) {
    19371970        strcpy(raidrec->additional_vars.el[lino].value, sz_out);
    19381971    }
    1939 }
    1940 
    1941 
    1942 /* I'm not racist against white people. I just don't like people who think Liberia is near Spain.       - Hugo, 09/01/2001 */
    1943 
     1972    paranoid_free(header);
     1973    paranoid_free(comment);
     1974    paranoid_free(sz_out);
     1975}
    19441976#endif
     1977
    19451978
    19461979/**
     
    19722005
    19732006    /** ???? *************************************************************/
    1974     void *curr_choice;
     2007    void *curr_choice = NULL;
    19752008    void *keylist[ARBITRARY_MAXIMUM];
    19762009
     
    19812014
    19822015    /** buffers **********************************************************/
    1983     char tmp[MAX_STR_LEN];
    1984     char flaws_str_A[MAX_STR_LEN];
    1985     char flaws_str_B[MAX_STR_LEN];
    1986     char flaws_str_C[MAX_STR_LEN];
     2016    char *tmp = NULL;
     2017    char *flaws_str_A = NULL;
     2018    char *flaws_str_B = NULL;
     2019    char *flaws_str_C = NULL;
    19872020
    19882021    assert(mountlist != NULL);
    19892022    assert(raidlist != NULL);
    19902023
    1991     strcpy(flaws_str_A, "xxxxxxxxx");
    1992     strcpy(flaws_str_B, "xxxxxxxxx");
    1993     strcpy(flaws_str_C, "xxxxxxxxx");
     2024    asprintf(&flaws_str_A, "xxxxxxxxx");
     2025    asprintf(&flaws_str_B, "xxxxxxxxx");
     2026    asprintf(&flaws_str_C, "xxxxxxxxx");
    19942027    if (mountlist->entries > ARBITRARY_MAXIMUM) {
    19952028        log_to_screen(_("Arbitrary limits suck, man!"));
     
    19972030    }
    19982031    newtPushHelpLine
    1999         (_("   Please edit the mountlist to your satisfaction, then click OK or Cancel."));
     2032        (_
     2033         ("   Please edit the mountlist to your satisfaction, then click OK or Cancel."));
    20002034    i = 4;
    20012035    bAdd = newtCompactButton(i, 17, _(" Add "));
     
    20052039    bCancel = newtCompactButton(i += 12, 17, _("Cancel"));
    20062040    bOK = newtCompactButton(i += 12, 17, _("  OK  "));
    2007     sprintf(tmp, "%-24s %-24s %-8s  %s", _("Device"), _("Mountpoint"), _("Format"),
    2008             _("Size (MB)"));
     2041    asprintf(&tmp, "%-24s %-24s %-8s  %s", _("Device"), _("Mountpoint"),
     2042            _("Format"), _("Size (MB)"));
    20092043    headerMsg = newtLabel(2, 1, tmp);
    20102044    flawsLabelA = newtLabel(2, 13, flaws_str_A);
     
    20262060        newtLabelSetText(flawsLabelC, flaws_str_C);
    20272061        b_res = newtRunForm(myForm);
     2062        /* BERLIOS: This needs to be re-written */
    20282063        if (b_res == bOK) {
    20292064            if (!evaluate_mountlist
     
    20352070                finished =
    20362071                    ask_me_yes_or_no
    2037                     (_("Are you sure you want to save your mountlist and continue? (No changes will be made to your partition table at this time.)"));
     2072                    (_
     2073                     ("Are you sure you want to save your mountlist and continue? (No changes will be made to your partition table at this time.)"));
    20382074            }
    20392075        } else if (b_res == bCancel) {
     
    20412077        } else if (b_res == bReload) {
    20422078            if (ask_me_yes_or_no(_("Reload original mountlist?"))) {
    2043 /*
    2044 This would be really dumb. RAIDTAB_FNAME is #define'd.   --- Hugo, 2003/04/24
    2045           if (!RAIDTAB_FNAME[0])
    2046         {
    2047                   strcpy(RAIDTAB_FNAME, "/etc/raidtab");
    2048           log_it("Warning - raidtab_fname is blank. Assuming %s", g_raidtab_fname);
    2049         }
    2050 */
    20512079                load_mountlist(mountlist, mountlist_fname);
    20522080                load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
     
    20762104                    } else {
    20772105                        popup_and_OK
    2078                             (_("Please add an entry. Then press ENTER to edit it."));
     2106                            (_
     2107                             ("Please add an entry. Then press ENTER to edit it."));
    20792108                    }
    20802109                }
    20812110            }
    20822111        }
     2112        paranoid_free(flaws_str_A);
     2113        paranoid_free(flaws_str_B);
     2114        paranoid_free(flaws_str_C);
    20832115    }
    20842116    newtFormDestroy(myForm);
     
    20952127
    20962128
    2097 
    20982129/**
    20992130 * Edit the mountlist.
     
    21072138{
    21082139    int res = 0;
    2109 //  char tmp[MAX_STR_LEN];
    21102140
    21112141    iamhere("entering eml");
     
    21212151    return (res);
    21222152}
    2123 
    2124 
    21252153
    21262154
     
    21492177
    21502178    /** ?? ***************************************************************/
    2151     void *keylist[ARBITRARY_MAXIMUM], *curr_choice;
     2179    void *keylist[ARBITRARY_MAXIMUM], *curr_choice = NULL;
    21522180
    21532181    /** buffers **********************************************************/
    2154     char title_of_window[MAX_STR_LEN];
     2182    char *title_of_window = NULL;
    21552183
    21562184    /** int **************************************************************/
     
    21632191    memcpy((void *) &bkp_raidrec, (void *) raidrec,
    21642192           sizeof(struct raid_device_record));
    2165     sprintf(title_of_window, "Additional variables");
     2193    asprintf(&title_of_window, "Additional variables");
    21662194    newtPushHelpLine
    2167         (_("  Edit the additional fields to your heart's content, then click OK or Cancel."));
    2168     headerMsg = newtLabel(1, 1, _("Label                            Value"));
     2195        (_
     2196         ("  Edit the additional fields to your heart's content, then click OK or Cancel."));
     2197    headerMsg =
     2198        newtLabel(1, 1, _("Label                            Value"));
    21692199    varsListbox =
    21702200        newtListbox(1, 2, 6, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
     
    21762206    bCancel = newtCompactButton(i += 9, 9, _("Cancel"));
    21772207    newtOpenWindow(17, 7, 46, 10, title_of_window);
     2208    paranoid_free(title_of_window);
     2209
    21782210    myForm = newtForm(NULL, NULL, 0);
    21792211    newtFormAddComponents(myForm, headerMsg, varsListbox, bAdd, bEdit,
     
    22472279
    22482280
    2249 
    22502281/**
    22512282 * Locate @p device in @p raidlist.
     
    22592290                             char *device)
    22602291{
    2261 
    22622292    /** int ***************************************************************/
    22632293    int i = 0;
    22642294#ifdef __FreeBSD__
    2265     char vdev[64];
    2266 #else
    2267 // Linux
     2295    char *vdev = NULL;
    22682296#endif
    22692297
     
    22732301#ifdef __FreeBSD__
    22742302    for (i = 0; i < raidlist->entries; i++) {
    2275         sprintf(vdev, "/dev/vinum/%s", raidlist->el[i].volname);
    2276         if (!strcmp(device, vdev))
     2303        asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname);
     2304        if (!strcmp(device, vdev)) {
     2305            paranoid_free(vdev);
    22772306            break;
     2307        }
     2308        paranoid_free(vdev);
    22782309    }
    22792310#else
     
    23052336    /** initialize ********************************************************/
    23062337
    2307     assert(isodir_device != NULL);
    2308     assert(isodir_format != NULL);
    2309     assert(isodir_path != NULL);
    2310 
    2311     log_it("%d - AAA - isodir_path = %s", isodir_path);
    2312     isodir_format[0] = '\0';
    2313     if (isodir_device[0] == '\0') {
    2314         strcpy(isodir_device, "/dev/");
    2315     }
    2316     if (isodir_path[0] == '\0') {
    2317         strcpy(isodir_path, "/");
     2338    // %d no var ???
     2339    // log_it("%d - AAA - isodir_path = %s", isodir_path);
     2340    if (isodir_device == NULL) {
     2341        asprintf(&isodir_device, "/dev/");
     2342    }
     2343    if (isodir_path == NULL) {
     2344        asprintf(&isodir_path, "/");
    23182345    }
    23192346    if (does_file_exist("/tmp/NFS-SERVER-PATH")) {
    2320         strcpy(isodir_device, last_line_of_file("/tmp/NFS-SERVER-MOUNT"));
    2321         strcpy(isodir_format, "nfs");
    2322         strcpy(isodir_path, last_line_of_file("/tmp/NFS-SERVER-PATH"));
     2347        paranoid_free(isodir_device);
     2348        isodir_device = last_line_of_file("/tmp/NFS-SERVER-MOUNT");
     2349        asprintf(&isodir_format, "nfs");
     2350        paranoid_free(isodir_path);
     2351        isodir_path = last_line_of_file("/tmp/NFS-SERVER-PATH");
    23232352    }
    23242353    if (nuke_me_please) {
     
    23272356
    23282357    if (popup_and_get_string
    2329         (_("ISO Mode - device"), _("On what device do the ISO files live?"),
    2330          isodir_device, MAX_STR_LEN / 4)) {
     2358        (_("ISO Mode - device"),
     2359         _("On what device do the ISO files live?"), isodir_device)) {
    23312360        if (popup_and_get_string
    23322361            (_("ISO Mode - format"),
    2333              _("What is the disk format of the device? (Hit ENTER if you don't know.)"),
    2334              isodir_format, 16)) {
     2362             _
     2363             ("What is the disk format of the device? (Hit ENTER if you don't know.)"),
     2364             isodir_format)) {
    23352365            if (popup_and_get_string
    23362366                (_("ISO Mode - path"),
    2337                  _("At what path on this device can the ISO files be found?"),
    2338                  isodir_path, MAX_STR_LEN / 4)) {
    2339                 strip_spaces(isodir_device);
    2340                 strip_spaces(isodir_format);
    2341                 strip_spaces(isodir_path);
    2342                 log_it("%d - BBB - isodir_path = %s", isodir_path);
     2367                 _
     2368                 ("At what path on this device can the ISO files be found?"),
     2369                 isodir_path)) {
     2370                // Same pb:
     2371                // log_it("%d - BBB - isodir_path = %s", isodir_path);
    23432372                return (TRUE);
    23442373            }
     
    23622391                            int currline, char *device)
    23632392{
    2364 
    23652393    /** structure *********************************************************/
    23662394    struct OSSWAP (raid_device_record, vinum_volume) * raidrec;
     
    24152443    raidrec->additional_vars.entries = items;
    24162444}
    2417 
    24182445#endif
     2446
    24192447
    24202448/**
     
    24332461
    24342462    newtPushHelpLine
    2435         (_("This is where I nuke your hard drives. Mhahahahaha. No-one can stop Mojo Jojo!"));
     2463        (_
     2464         ("This is where I nuke your hard drives. Mhahahahaha. No-one can stop Mojo Jojo!"));
    24362465    newtOpenWindow(24, 3, 32, 13, _("Nuking"));
    24372466    b1 = newtButton(7, 1, _("Slowly"));
     
    24472476
    24482477
    2449 
    24502478/**
    24512479 * Redraw the disklist.
     
    25122540
    25132541
    2514 
    2515 
    25162542/**
    25172543 * Redraw the list of unallocated RAID partitions.
     
    25312557
    25322558    /** buffers **********************************************************/
    2533     char tmp[MAX_STR_LEN];
     2559    char *tmp = NULL;
    25342560
    25352561    assert(unallocated_raid_partitions != NULL);
     
    25422568    }
    25432569    for (i = 0; i < unallocated_raid_partitions->entries; i++) {
    2544         sprintf(tmp, "%-22s %8lld",
     2570        asprintf(&tmp, "%-22s %8lld",
    25452571                unallocated_raid_partitions->el[i].device,
    25462572                unallocated_raid_partitions->el[i].size / 1024);
    25472573        newtListboxAppendEntry(listbox, tmp, keylist[i]);
    2548     }
    2549 }
     2574        paranoid_free(tmp);
     2575    }
     2576}
     2577
    25502578
    25512579#ifndef __FreeBSD__
     
    25652593
    25662594    /** buffers *********************************************************/
    2567     char tmp[MAX_STR_LEN];
     2595    char *tmp;
    25682596
    25692597    assert(additional_vars != NULL);
     
    25772605    }
    25782606    for (i = 0; i < additional_vars->entries; i++) {
    2579         sprintf(tmp, "%-32s %-8s", additional_vars->el[i].label,
     2607        asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label,
    25802608                additional_vars->el[i].value);
    25812609        newtListboxAppendEntry(listbox, tmp, keylist[i]);
     2610        paranoid_free(tmp);
    25822611    }
    25832612}
     
    26222651#endif
    26232652
     2653
    26242654/**
    26252655 * Change all RAID devices to use @p new_dev instead of @p old_dev.
     
    26352665{
    26362666    /** buffers ********************************************************/
    2637     char tmp[MAX_STR_LEN];
     2667    char *tmp;
    26382668
    26392669    /** int ************************************************************/
     
    26472677    pos = which_raid_device_is_using_this_partition(raidlist, old_dev);
    26482678    if (pos < 0) {
    2649         sprintf(tmp, "No need to rejig %s in raidlist: it's not listed.",
     2679        asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.",
    26502680                old_dev);
    26512681        log_it(tmp);
     2682        paranoid_free(tmp);
    26522683    } else {
    26532684        if ((j =
     
    26812712#endif
    26822713        else {
    2683             sprintf(tmp,
     2714            asprintf(&tmp,
    26842715                    "%s is supposed to be listed in this raid dev but it's not...",
    26852716                    old_dev);
    26862717            log_it(tmp);
     2718            paranoid_free(tmp);
    26872719        }
    26882720    }
     
    27172749    res = read_variableINT_and_remove_from_raidvars(raidrec, "block-size");
    27182750}
     2751
    27192752
    27202753/**
     
    27342767                  struct list_of_disks *disklist)
    27352768{
    2736     void *curr_choice;
    2737 
    2738     /** ??? ***************************************************************/
     2769    void *curr_choice = NULL;
    27392770
    27402771    /** structures ********************************************************/
    2741     struct raidlist_itself *bkp_raidlist;
    2742     struct raid_device_record *bkp_raidrec;
    2743     struct list_of_disks *bkp_disklist;
    2744     struct mountlist_itself *unallocated_raid_partitions;
     2772    struct raidlist_itself *bkp_raidlist = NULL;
     2773    struct raid_device_record *bkp_raidrec = NULL;
     2774    struct list_of_disks *bkp_disklist = NULL;
     2775    struct mountlist_itself *unallocated_raid_partitions = NULL;
    27452776
    27462777    /** newt **************************************************************/
     
    27562787    /** buffers **********************************************************/
    27572788    void *keylist[ARBITRARY_MAXIMUM];
    2758     char *tmp;
    2759     char *help_text;
    2760     char *title_of_window;
    2761     char *sz_res;
    2762     char *header_text;
     2789    char *tmp = NULL;
     2790    char *help_text = NULL;
     2791    char *title_of_window = NULL;
     2792    char *sz_res = NULL;
     2793    char *header_text = NULL;
    27632794
    27642795  /** int **************************************************************/
     
    27732804
    27742805    iamhere("malloc'ing");
    2775     malloc_string(tmp);
    2776     malloc_string(help_text);
    2777     malloc_string(title_of_window);
    2778     malloc_string(sz_res);
    2779     malloc_string(header_text);
    27802806    if (!(bkp_raidrec = malloc(sizeof(struct raid_device_record)))) {
    27812807        fatal_error("Cannot malloc space for raidrec");
     
    28012827
    28022828    iamhere("Post-malloc");
    2803     strcpy(help_text,
    2804            _("   Edit this RAID device's list of partitions. Choose OK or Cancel when done."));
    2805     sprintf(header_text, "%-24s    %s", _("Device"), _("Index"));
    2806     sprintf(title_of_window, _("%s contains..."), raidrec->raid_device);
     2829    asprintf(&help_text,
     2830           _
     2831           ("   Edit this RAID device's list of partitions. Choose OK or Cancel when done."));
     2832    asprintf(&header_text, "%-24s    %s", _("Device"), _("Index"));
     2833    asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device);
    28072834    newtPushHelpLine(help_text);
     2835    paranoid_free(help_text);
    28082836    for (b_res = (newtComponent) 12345; b_res != bOK && b_res != bCancel;) {
    28092837        headerMsg = newtLabel(1, 1, header_text);
     
    28442872                    if (unallocated_raid_partitions->entries <= 0) {
    28452873                        popup_and_OK
    2846                             (_("There are no unallocated partitions marked for RAID."));
     2874                            (_
     2875                             ("There are no unallocated partitions marked for RAID."));
    28472876                    } else {
    28482877                        log_it
    2849                             (_("Done. The user may add one or more of the above to RAID device"));
     2878                            (_
     2879                             ("Done. The user may add one or more of the above to RAID device"));
    28502880                        add_disklist_entry(disklist, raidrec->raid_device,
    28512881                                           unallocated_raid_partitions);
    2852                         log_it(_("I have finished adding a disklist entry."));
     2882                        log_it(_
     2883                               ("I have finished adding a disklist entry."));
    28532884                        redraw_disklist(disklist, keylist,
    28542885                                        partitionsListbox);
     
    28592890                    redraw_disklist(disklist, keylist, partitionsListbox);
    28602891                } else {
    2861                     sprintf(tmp, _("%s's index is %d. What should it be?"),
     2892                    asprintf(&tmp, _("%s's index is %d. What should it be?"),
    28622893                            raidrec->raid_device,
    28632894                            disklist->el[currline].index);
    2864                     sprintf(sz_res, "%d", disklist->el[currline].index);
    2865                     if (popup_and_get_string(_("Set index"), tmp, sz_res, 10)) {
     2895                    asprintf(&sz_res, "%d", disklist->el[currline].index);
     2896                    if (popup_and_get_string
     2897                        (_("Set index"), tmp, sz_res)) {
    28662898                        disklist->el[currline].index = atoi(sz_res);
    28672899                    }
     2900                    paranoid_free(tmp);
     2901                    paranoid_free(sz_res);
    28682902                    redraw_disklist(disklist, keylist, partitionsListbox);
    28692903                }
     
    28732907        newtPopWindow();
    28742908    }
     2909    paranoid_free(title_of_window);
     2910    paranoid_free(header_text);
     2911
    28752912    newtPopHelpLine();
    28762913    if (b_res == bCancel) {
     
    28822919               sizeof(struct list_of_disks));
    28832920    }
    2884     paranoid_free(tmp);
    2885     paranoid_free(help_text);
    2886     paranoid_free(title_of_window);
    2887     paranoid_free(sz_res);
    2888     paranoid_free(header_text);
    28892921    paranoid_free(bkp_raidrec);
    28902922    paranoid_free(bkp_disklist);
     
    28952927
    28962928
    2897 
    28982929/**
    28992930 * Ask the user which restore mode (nuke, interactive, or compare) we should use.
     
    29062937  /** char *************************************************************/
    29072938    char output = '\0';
    2908     char tmp[MAX_STR_LEN];
     2939    char *tmp = NULL;
     2940    size_t n = 0;
    29092941
    29102942  /** newt *************************************************************/
     
    29202952        for (output = 'z'; !strchr("AICE", output); output = tmp[0]) {
    29212953            printf
    2922                 (_("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> "));
    2923             fgets(tmp, MAX_STR_LEN - 1, stdin);
    2924         }
     2954                (_
     2955                 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> "));
     2956            getline(&tmp, &n, stdin);
     2957        }
     2958        paranoid_free(tmp);
    29252959        return (output);
    29262960    }
    29272961
    29282962    newtPushHelpLine
    2929         (_("   Do you want to 'nuke' your system, restore interactively, or just compare?"));
     2963        (_
     2964         ("   Do you want to 'nuke' your system, restore interactively, or just compare?"));
    29302965    newtOpenWindow(24, 3, 32, 17, _("How should I restore?"));
    29312966    b1 = newtButton(7, 1, _("Automatically"));
Note: See TracChangeset for help on using the changeset viewer.