Ignore:
Timestamp:
Nov 19, 2020, 2:17:57 AM (4 years ago)
Author:
Bruno Cornec
Message:

Fix some remaining memory allocation errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-devices.c

    r3755 r3777  
    492492
    493493    if (!dev[0] || (res = mount_CDROM_here(dev, mountpoint))) {
    494         if (!popup_and_get_string("CD-ROM device", "Please enter your CD-ROM's /dev device", dev, MAX_STR_LEN / 4)) {
     494        if (!popup_and_get_string("CD-ROM device", "Please enter your CD-ROM's /dev device", dev,(MAX_STR_LEN / 4)-1)) {
    495495            res = 1;
    496496        } else {
     
    23082308                log_msg(1, "bkpinfo->media_device = %s", bkpinfo->media_device);
    23092309                mr_asprintf(comment, "Please specify your %s drive's /dev entry", mds);
    2310                 if (!popup_and_get_string("Device?", comment, bkpinfo->media_device, MAX_STR_LEN / 4)) {
     2310                if (!popup_and_get_string("Device?", comment, bkpinfo->media_device,(MAX_STR_LEN / 4)-1)) {
    23112311                    log_to_screen("User has chosen not to backup the machine");
    23122312                    finish(1);
     
    23312331            if (!bkpinfo->media_device[0]) {
    23322332                if (bkpinfo->backup_media_type == usb) {
    2333                     i = popup_and_get_string("/dev entry?", "What is the /dev entry of your USB Disk/Key, please?", bkpinfo->media_device, MAX_STR_LEN / 4);
     2333                    i = popup_and_get_string("/dev entry?", "What is the /dev entry of your USB Disk/Key, please?", bkpinfo->media_device, (MAX_STR_LEN / 4)-1);
    23342334                } else {
    23352335                    if (g_kernel_version < 2.6) {
    2336                         i = popup_and_get_string("Device node?", "What is the SCSI node of your CD (re)writer, please?", bkpinfo->media_device, MAX_STR_LEN / 4);
     2336                        i = popup_and_get_string("Device node?", "What is the SCSI node of your CD (re)writer, please?", bkpinfo->media_device,(MAX_STR_LEN / 4)-1);
    23372337                    } else {
    2338                         i = popup_and_get_string("/dev entry?", "What is the /dev entry of your CD (re)writer, please?", bkpinfo->media_device, MAX_STR_LEN / 4);
     2338                        i = popup_and_get_string("/dev entry?", "What is the /dev entry of your CD (re)writer, please?", bkpinfo->media_device,(MAX_STR_LEN / 4)-1);
    23392339                    }
    23402340                }
     
    23852385        }
    23862386        if (!bkpinfo->media_device[0]) {
    2387             if (!popup_and_get_string("Device name?", "What is the /dev entry of your tape streamer?", bkpinfo->media_device, MAX_STR_LEN / 4)) {
     2387            if (!popup_and_get_string("Device name?", "What is the /dev entry of your tape streamer?", bkpinfo->media_device,(MAX_STR_LEN / 4)-1)) {
    23882388                log_to_screen("User has chosen not to backup the machine");
    23892389                finish(1);
     
    24572457#endif
    24582458        {
    2459             if (!popup_and_get_string("Network shared dir.", "Please enter path and directory where archives are stored remotely. (Mondo has taken a guess at the correct value. If it is incorrect, delete it and type the correct one.)", p, MAX_STR_LEN / 4)) {
     2459            if (!popup_and_get_string("Network shared dir.", "Please enter path and directory where archives are stored remotely. (Mondo has taken a guess at the correct value. If it is incorrect, delete it and type the correct one.)", p,(MAX_STR_LEN / 4)-1)) {
    24602460                log_to_screen("User has chosen not to backup the machine");
    24612461                finish(1);
     
    25232523        }
    25242524        strcpy(tmp1, bkpinfo->netfs_proto);
    2525         if (!popup_and_get_string("Network protocol", "Which protocol should I use (nfs/sshfs/smbfs) ?",tmp1, MAX_STR_LEN)) {
     2525        if (!popup_and_get_string("Network protocol", "Which protocol should I use (nfs/sshfs/smbfs) ?",tmp1, MAX_STR_LEN-1)) {
    25262526            log_to_screen("User has chosen not to backup the machine");
    25272527            finish(1);
     
    25312531
    25322532        strcpy(tmp1, bkpinfo->netfs_mount);
    2533         if (!popup_and_get_string("Network share", "Which remote share should I mount?", tmp1, MAX_STR_LEN)) {
     2533        if (!popup_and_get_string("Network share", "Which remote share should I mount?", tmp1, MAX_STR_LEN-1)) {
    25342534            log_to_screen("User has chosen not to backup the machine");
    25352535            finish(1);
     
    25432543            strcpy(tmp1, "");
    25442544        }
    2545         if (!popup_and_get_string("Network user", "Which user should I use if any ?",tmp1, MAX_STR_LEN)) {
     2545        if (!popup_and_get_string("Network user", "Which user should I use if any ?",tmp1, MAX_STR_LEN-1)) {
    25462546            log_to_screen("User has chosen not to backup the machine");
    25472547            finish(1);
     
    25602560        } else {
    25612561            // Why netfsdir ?
    2562             sprintf(bkpinfo->isodir, "%s/netfsdir", bkpinfo->tmpdir);
     2562            snprintf(bkpinfo->isodir, (MAX_STR_LEN / 4) -1, "%s/netfsdir", bkpinfo->tmpdir);
    25632563            mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir);
    25642564            run_program_and_log_output(command, 5);
     
    26062606        }
    26072607        strcpy(tmp1, bkpinfo->netfs_remote_dir);
    2608         if (!popup_and_get_string ("Directory", "Which directory within that mountpoint?", tmp1, MAX_STR_LEN)) {
     2608        if (!popup_and_get_string ("Directory", "Which directory within that mountpoint?", tmp1, MAX_STR_LEN-1)) {
    26092609            log_to_screen("User has chosen not to backup the machine");
    26102610            finish(1);
     
    26142614        bkpinfo->netfs_remote_dir = mr_strip_spaces(tmp1);
    26152615
    2616         if (!popup_and_get_string("Prefix.", "Please enter the prefix that will be prepended to your ISO filename.  Example: machine1 to obtain machine1-[1-9]*.iso files", bkpinfo->prefix, MAX_STR_LEN / 4)) {
     2616        if (!popup_and_get_string("Prefix.", "Please enter the prefix that will be prepended to your ISO filename.  Example: machine1 to obtain machine1-[1-9]*.iso files", bkpinfo->prefix,(MAX_STR_LEN / 4)-1)) {
    26172617            log_to_screen("User has chosen not to backup the machine");
    26182618            finish(1);
     
    26252625    case iso:
    26262626        if (!bkpinfo->disaster_recovery) {
    2627             if (!popup_and_get_string("Storage dir.", "Please enter the full path name to the directory for your ISO images.  Example: /mnt/raid0_0", bkpinfo->isodir, MAX_STR_LEN / 4)) {
     2627            if (!popup_and_get_string("Storage dir.", "Please enter the full path name to the directory for your ISO images.  Example: /mnt/raid0_0", bkpinfo->isodir,(MAX_STR_LEN / 4)-1)) {
    26282628                log_to_screen("User has chosen not to backup the machine");
    26292629                finish(1);
     
    26482648            }
    26492649        }
    2650         if (!popup_and_get_string("Prefix.", "Please enter the prefix that will be prepended to your ISO filename.  Example: machine1 to obtain machine1-[1-9]*.iso files", bkpinfo->prefix, MAX_STR_LEN / 4)) {
     2650        if (!popup_and_get_string("Prefix.", "Please enter the prefix that will be prepended to your ISO filename.  Example: machine1 to obtain machine1-[1-9]*.iso files", bkpinfo->prefix,(MAX_STR_LEN / 4)-1)) {
    26512651            log_to_screen("User has chosen not to backup the machine");
    26522652            finish(1);
     
    26722672
    26732673#ifdef __FreeBSD__
    2674             if (!popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/ad0)", bkpinfo->boot_device, MAX_STR_LEN / 4)) {
     2674            if (!popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/ad0)", bkpinfo->boot_device,(MAX_STR_LEN / 4)-1)) {
    26752675                log_to_screen("User has chosen not to backup the machine");
    26762676                finish(1);
     
    26792679#else
    26802680            strcpy(tmp1, bkpinfo->boot_device);
    2681             if (!popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/hda)", tmp1, MAX_STR_LEN / 4)) {
     2681            if (!popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/hda)", tmp1,(MAX_STR_LEN / 4)-1)) {
    26822682                log_to_screen("User has chosen not to backup the machine");
    26832683                finish(1);
     
    27162716            strcpy(tmp1, "/");
    27172717        }
    2718         if (!popup_and_get_string("Backup paths", "Please enter paths (separated by '|') which you want me to backup. The default is '/' (i.e. everything).", tmp1, MAX_STR_LEN)) {
     2718        if (!popup_and_get_string("Backup paths", "Please enter paths (separated by '|') which you want me to backup. The default is '/' (i.e. everything).", tmp1, MAX_STR_LEN-1)) {
    27192719            log_to_screen("User has chosen not to backup the machine");
    27202720            finish(1);
     
    27292729// NTFS
    27302730        tmp = call_program_and_get_last_line_of_output("mr-parted2fdisk -l 2>/dev/null | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'");
    2731         strncpy(tmp1, tmp, MAX_STR_LEN / 4);
     2731        strncpy(tmp1, tmp,(MAX_STR_LEN / 4)-1);
    27322732        mr_free(tmp);
    27332733        if (strlen(tmp1) > 2) {
    2734             if (!popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp1, MAX_STR_LEN / 4)) {
     2734            if (!popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp1,(MAX_STR_LEN / 4)-1)) {
    27352735                log_to_screen("User has chosen not to backup the machine");
    27362736                finish(1);
    27372737            }
    2738             strncpy(bkpinfo->image_devs, tmp1, MAX_STR_LEN / 4);
     2738            strncpy(bkpinfo->image_devs, tmp1, (MAX_STR_LEN / 4)-1);
    27392739        }
    27402740
     
    27552755        mr_asprintf(oldtmp, "%s", bkpinfo->tmpdir);
    27562756        if (bkpinfo->tmpdir != NULL ) {
    2757             strncpy(p,bkpinfo->tmpdir,(16*MAX_STR_LEN)-1);
     2757            strncpy(p,bkpinfo->tmpdir,(MAX_STR_LEN / 4)-1);
    27582758        } else {
    27592759            p[0] = '\0';
     
    27712771        mr_asprintf(oldtmp, "%s", bkpinfo->scratchdir);
    27722772        if (bkpinfo->scratchdir != NULL ) {
    2773             strncpy(p,bkpinfo->scratchdir,(16*MAX_STR_LEN)-1);
     2773            strncpy(p,bkpinfo->scratchdir,(MAX_STR_LEN / 4)-1);
    27742774        } else {
    27752775            p[0] = '\0';
Note: See TracChangeset for help on using the changeset viewer.