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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.