Ignore:
Timestamp:
Jan 21, 2008, 7:16:46 PM (12 years ago)
Author:
bruno
Message:

Replace some sprintf by asprintf (searching for a core dumped bug at restore time when dealing with bootloader: asks for writing BL, and fails after)

File:
1 edited

Legend:

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

    r1852 r1873  
    14681468  /** malloc *******/
    14691469    char *device;
    1470     char *tmp;
     1470    char *tmp = NULL;
    14711471    char *name;
    14721472    char *cmd = NULL;
    14731473
    14741474    malloc_string(device);
    1475     malloc_string(tmp);
    14761475    malloc_string(name);
    14771476
     
    14821481    asprintf(&cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING);
    14831482    run_program_and_log_output(cmd, 3);
     1483    paranoid_free(cmd);
    14841484
    14851485    backup_crucial_file(MNT_RESTORING, "/etc/fstab");
     
    14911491    read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);
    14921492    read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
    1493     sprintf(tmp, "run_boot_loader: device='%s', name='%s'", device, name);
     1493    asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name);
    14941494    log_msg(2, tmp);
     1495    paranoid_free(tmp);
    14951496    system("sync");
    14961497    if (!strcmp(name, "LILO")) {
     
    15051506#ifdef __FreeBSD__
    15061507    else if (!strcmp(name, "BOOT0")) {
    1507         sprintf(tmp, "boot0cfg -B %s", device);
     1508        asprintf(&tmp, "boot0cfg -B %s", device);
    15081509        res = run_program_and_log_output(tmp, FALSE);
     1510        paranoid_free(tmp);
    15091511    } else {
    1510         sprintf(tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);
     1512        asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);
    15111513        if (!system(tmp)) {
    1512             sprintf(tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
     1514            paranoid_free(tmp);
     1515            asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
    15131516            res = run_program_and_log_output(tmp, 3);
    15141517        } else {
     
    15161519                    "I'm not running any boot loader. You have a DD boot drive. It's already loaded up.");
    15171520        }
     1521        paranoid_free(tmp);
    15181522    }
    15191523#else
     
    15311535    }
    15321536    paranoid_free(device);
    1533     paranoid_free(tmp);
    15341537    paranoid_free(name);
    15351538    return (retval);
Note: See TracChangeset for help on using the changeset viewer.