Ignore:
Timestamp:
Mar 7, 2024, 1:33:54 AM (4 months ago)
Author:
Bruno Cornec
Message:

Fix build_partition_name to allocate dynamically and change proto accordingly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-mountlist.c

    r3611 r3859  
    5454
    5555    /*@ buffers ******************************************************** */
    56     char tmp = NULL;
    57     char tmp1 = NULL;
    58     char device[MAX_STR_LEN];
     56    char *tmp = NULL;
     57    char *tmp1 = NULL;
     58    char *device = NULL;
    5959
    6060    char *flaws_str = NULL;
     
    8686    /* check DD */
    8787    for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    88         sprintf(device, "%s%c", drive, cur_sp_no);
     88        mr_asprintf(device, "%s%c", drive, cur_sp_no);
    8989        if (find_device_in_mountlist(mountlist, device) >= 0)
    9090            foundsome = TRUE;
     
    9292    if (foundsome) {
    9393        for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    94             sprintf(device, "%s%c", drive, cur_sp_no);
     94            mr_asprintf(device, "%s%c", drive, cur_sp_no);
    9595            pos = find_device_in_mountlist(mountlist, device);
    9696            if (pos < 0) {
     
    160160    npos = pos = 0;
    161161    for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
    162         build_partition_name(device, drive, curr_part_no);
     162        device = build_partition_name(drive, curr_part_no);
    163163        pos = find_device_in_mountlist(mountlist, device);
    164164        npos = 0;
    165165        for (cur_sp_no = 'a'; cur_sp_no <= 'h'; cur_sp_no++) {
    166             sprintf(device, "%ss%i%c", device, curr_part_no, cur_sp_no);
     166            mr_asprintf(device, "%ss%i%c", device, curr_part_no, cur_sp_no);
    167167            if (find_device_in_mountlist(mountlist, device) >= 0)
    168168                npos++;
     
    170170        if (((pos >= 0) || npos) && foundsome) {
    171171            mr_strcat(flaws_str, " %s has both DD and PC-style partitions.", drive);
     172            mr_free(device);
    172173            return(flaws_str);      // fatal error
    173174        }
    174175
    175         build_partition_name(device, drive, curr_part_no);
    176176        if (pos > 0 && !npos) {
    177177            /* gap in the partition list? */
     
    255255            /* Check subpartitions */
    256256            for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    257                 sprintf(device, "%ss%d%c", drive, curr_part_no, cur_sp_no);
     257                mr_asprintf(device, "%ss%d%c", drive, curr_part_no, cur_sp_no);
    258258                pos = find_device_in_mountlist(mountlist, device);
    259259                if (pos < 0) {
     
    344344        }
    345345        prev_part_no = curr_part_no;
     346        mr_free(device);
    346347    }
    347348
     
    397398    mr_asprintf(flaws_str, "%s", "");
    398399
    399     malloc_string(device);
    400400    prev_part_no = 0;
    401401
     
    421421
    422422    for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
    423         build_partition_name(device, drive, curr_part_no);
     423        device = build_partition_name(drive, curr_part_no);
    424424        pos = find_device_in_mountlist(mountlist, device);
    425425        if (pos < 0) {
     
    520520
    521521  endoffunc:
    522     paranoid_free(device);
     522    mr_free(device);
    523523
    524524    if (res == 0) {
Note: See TracChangeset for help on using the changeset viewer.