Changeset 2214 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-archive.c
- Timestamp:
- Jun 3, 2009, 7:10:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-archive.c
r2211 r2214 508 508 { 509 509 /*@ buffer ************************************************************ */ 510 char *tmp ;510 char *tmp = NULL; 511 511 char *tmp1 = NULL; 512 512 char *tmp2 = NULL; 513 char *scratchdir;514 513 char *command = NULL; 515 char *use_lzo_sz ;516 char *use_gzip_sz ;517 char *use_comp_sz ;518 char *use_star_sz ;519 char *bootldr_str ;520 char *tape_device ;521 char *last_filelist_number ;522 char *broken_bios_sz ;523 char *cd_recovery_sz ;524 char *tape_size_sz ;525 char *devs_to_exclude ;526 char *use_lilo_sz ;527 char *value ;528 char *bootdev ;514 char *use_lzo_sz = NULL; 515 char *use_gzip_sz = NULL; 516 char *use_comp_sz = NULL; 517 char *use_star_sz = NULL; 518 char *bootldr_str = NULL; 519 char *tape_device = NULL; 520 char *last_filelist_number = NULL; 521 char *broken_bios_sz = NULL; 522 char *cd_recovery_sz = NULL; 523 char *tape_size_sz = NULL; 524 char *devs_to_exclude = NULL; 525 char *use_lilo_sz = NULL; /* BCO: shared between LILO/ELILO */ 526 char *value = NULL; 527 char *bootdev = NULL; 529 528 char *ntapedev = NULL; 530 529 … … 542 541 543 542 assert(bkpinfo != NULL); 544 tmp = malloc(9*MAX_STR_LEN);545 malloc_string(scratchdir);546 malloc_string(use_lzo_sz);547 malloc_string(use_gzip_sz);548 malloc_string(use_star_sz);549 malloc_string(use_comp_sz);550 malloc_string(bootldr_str);551 malloc_string(tape_device);552 543 malloc_string(last_filelist_number); 553 malloc_string(broken_bios_sz); 554 malloc_string(cd_recovery_sz); 555 malloc_string(tape_size_sz); 556 malloc_string(devs_to_exclude); 557 malloc_string(use_lilo_sz); /* BCO: shared between LILO/ELILO */ 558 malloc_string(value); 559 malloc_string(bootdev); 560 561 strcpy(scratchdir, bkpinfo->scratchdir); 562 sprintf(tmp, 544 545 mr_asprintf(&tmp, 563 546 "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 564 547 bkpinfo->exclude_paths); 565 strcpy(devs_to_exclude, call_program_and_get_last_line_of_output(tmp)); 566 sprintf(tmp, "devs_to_exclude = '%s'", devs_to_exclude); 548 mr_asprintf(&devs_to_exclude, "%s", call_program_and_get_last_line_of_output(tmp)); 549 mr_free(tmp); 550 551 mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); 567 552 log_msg(2, tmp); 553 mr_free(tmp); 554 568 555 mvaddstr_and_log_it(g_currentY, 0, 569 556 "Calling MINDI to create boot+data disks"); 570 sprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);557 mr_asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir); 571 558 if (!does_file_exist(tmp)) { 572 sprintf(tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 559 mr_free(tmp); 560 mr_asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 573 561 if (!does_file_exist(tmp)) { 574 562 fatal_error … … 577 565 } 578 566 lines_in_filelist = count_lines_in_file(tmp); 579 sprintf(tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir); 580 strcpy(last_filelist_number, last_line_of_file(tmp)); 567 mr_free(tmp); 568 569 mr_asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir); 570 mr_asprintf(&last_filelist_number, "%s", last_line_of_file(tmp)); 571 mr_free(tmp); 572 581 573 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 582 sprintf(tape_size_sz, "%ld", bkpinfo->media_size[1]);574 mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]); 583 575 ntapedev = get_non_rewind_dev(bkpinfo->media_device); 584 576 if ((bkpinfo->use_obdr) && (ntapedev != NULL)) { … … 590 582 } 591 583 paranoid_free(ntapedev); 592 strcpy(tape_device, bkpinfo->media_device);584 mr_asprintf(&tape_device, "%s", bkpinfo->media_device); 593 585 } else { 594 tape_size_sz[0] = '\0';595 tape_device[0] = '\0';586 mr_asprintf(&tape_size_sz, "%ld", 0L);; 587 mr_asprintf(&tape_device, ""); 596 588 } 597 589 if (bkpinfo->use_lzo) { 598 strcpy(use_lzo_sz, "yes");590 mr_asprintf(&use_lzo_sz, "yes"); 599 591 } else { 600 strcpy(use_lzo_sz, "no");592 mr_asprintf(&use_lzo_sz, "no"); 601 593 } 602 594 if (bkpinfo->use_gzip) { 603 strcpy(use_gzip_sz, "yes");595 mr_asprintf(&use_gzip_sz, "yes"); 604 596 } else { 605 strcpy(use_gzip_sz, "no");597 mr_asprintf(&use_gzip_sz, "no"); 606 598 } 607 599 if (bkpinfo->use_star) { 608 strcpy(use_star_sz, "yes");600 mr_asprintf(&use_star_sz, "yes"); 609 601 } else { 610 strcpy(use_star_sz, "no");602 mr_asprintf(&use_star_sz, "no"); 611 603 } 612 604 613 605 if (bkpinfo->compression_level > 0) { 614 strcpy(use_comp_sz, "yes");606 mr_asprintf(&use_comp_sz, "yes"); 615 607 } else { 616 strcpy(use_comp_sz, "no");617 } 618 619 strcpy(broken_bios_sz, "yes"); /* assume so */608 mr_asprintf(&use_comp_sz, "no"); 609 } 610 611 mr_asprintf(&broken_bios_sz, "yes"); /* assume so */ 620 612 if (g_cd_recovery) { 621 strcpy(cd_recovery_sz, "yes");613 mr_asprintf(&cd_recovery_sz, "yes"); 622 614 } else { 623 strcpy(cd_recovery_sz, "no");615 mr_asprintf(&cd_recovery_sz, "no"); 624 616 } 625 617 if (bkpinfo->make_cd_use_lilo) { 626 strcpy(use_lilo_sz, "yes");618 mr_asprintf(&use_lilo_sz, "yes"); 627 619 } else { 628 strcpy(use_lilo_sz, "no");620 mr_asprintf(&use_lilo_sz, "no"); 629 621 } 630 622 … … 634 626 635 627 #ifdef __FreeBSD__ 636 strcpy(bootdev, call_program_and_get_last_line_of_output628 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 637 629 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 638 630 if (!bootdev[0]) { 639 strcpy(bootdev, call_program_and_get_last_line_of_output 631 mr_free(bootdev); 632 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 640 633 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 641 634 } … … 643 636 /* Linux */ 644 637 #ifdef __IA64__ 645 strcpy(bootdev, call_program_and_get_last_line_of_output638 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 646 639 ("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 647 640 #else 648 strcpy(bootdev, call_program_and_get_last_line_of_output641 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 649 642 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 650 643 #endif 651 644 if (strstr(bootdev, "/dev/cciss/")) { 645 mr_free(bootdev); 652 646 #ifdef __IA64__ 653 strcpy(bootdev, call_program_and_get_last_line_of_output647 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 654 648 ("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 655 649 #else 656 strcpy(bootdev, call_program_and_get_last_line_of_output650 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 657 651 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 658 652 #endif 659 653 } 660 654 if (!bootdev[0]) { 661 strcpy(bootdev, call_program_and_get_last_line_of_output 655 mr_free(bootdev); 656 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 662 657 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 663 658 if (strstr(bootdev, "/dev/cciss/")) { 664 strcpy(bootdev, call_program_and_get_last_line_of_output 659 mr_free(bootdev); 660 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 665 661 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 666 662 } … … 673 669 ch = 'U'; 674 670 if (bkpinfo->boot_loader != '\0') { 675 sprintf(tmp, "User specified boot loader. It is '%c'.",671 mr_asprintf(&tmp, "User specified boot loader. It is '%c'.", 676 672 bkpinfo->boot_loader); 677 673 log_msg(2, tmp); 674 mr_free(tmp); 678 675 } else { 679 676 bkpinfo->boot_loader = ch; 680 677 } 681 678 if (bkpinfo->boot_device[0] != '\0') { 682 sprintf(tmp, "User specified boot device. It is '%s'.",679 mr_asprintf(&tmp, "User specified boot device. It is '%s'.", 683 680 bkpinfo->boot_device); 684 681 log_msg(2, tmp); 682 mr_free(tmp); 685 683 } else { 686 684 strcpy(bkpinfo->boot_device, bootdev); 687 685 } 688 686 } 687 mr_free(bootdev); 689 688 690 689 if ( … … 702 701 } 703 702 if (bkpinfo->boot_loader == 'L') { 704 strcpy(bootldr_str, "LILO");703 mr_asprintf(&bootldr_str, "LILO"); 705 704 if (!does_file_exist("/etc/lilo.conf")) { 706 705 fatal_error … … 708 707 } 709 708 } else if (bkpinfo->boot_loader == 'G') { 710 strcpy(bootldr_str, "GRUB");709 mr_asprintf(&bootldr_str, "GRUB"); 711 710 if (!does_file_exist("/boot/grub/menu.lst") 712 711 && does_file_exist("/boot/grub/grub.conf")) { … … 719 718 } 720 719 } else if (bkpinfo->boot_loader == 'E') { 721 strcpy(bootldr_str, "ELILO");720 mr_asprintf(&bootldr_str, "ELILO"); 722 721 /* BCO: fix it for Debian, Mandrake, ... */ 723 722 if (!does_file_exist("/etc/elilo.conf") … … 750 749 } 751 750 } else if (bkpinfo->boot_loader == 'R') { 752 strcpy(bootldr_str, "RAW");751 mr_asprintf(&bootldr_str, "RAW"); 753 752 } 754 753 #ifdef __FreeBSD__ 755 754 else if (bkpinfo->boot_loader == 'D') { 756 strcpy(bootldr_str, "DD");755 mr_asprintf(&bootldr_str, "DD"); 757 756 } 758 757 759 758 else if (bkpinfo->boot_loader == 'B') { 760 strcpy(bootldr_str, "BOOT0");759 mr_asprintf(&bootldr_str, "BOOT0"); 761 760 } 762 761 #endif 763 762 else { 764 strcpy(bootldr_str, "unknown");765 } 766 sprintf(tmp, "Your boot loader is %s and it boots from %s",763 mr_asprintf(&bootldr_str, "unknown"); 764 } 765 mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s", 767 766 bootldr_str, bkpinfo->boot_device); 768 767 log_to_screen(tmp); 769 sprintf(tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir); 768 mr_free(tmp); 769 770 mr_asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir); 770 771 if (write_one_liner_data_file(tmp, bkpinfo->boot_device)) { 771 772 log_msg(1, "%ld: Unable to write one-liner boot device", __LINE__); 772 773 } 774 mr_free(tmp); 775 773 776 switch (bkpinfo->backup_media_type) { 774 777 case cdr: 775 strcpy(value, "cdr");778 mr_asprintf(&value, "cdr"); 776 779 break; 777 780 case cdrw: 778 strcpy(value, "cdrw");781 mr_asprintf(&value, "cdrw"); 779 782 break; 780 783 case cdstream: 781 strcpy(value, "cdstream");784 mr_asprintf(&value, "cdstream"); 782 785 break; 783 786 case tape: 784 strcpy(value, "tape");787 mr_asprintf(&value, "tape"); 785 788 break; 786 789 case udev: 787 strcpy(value, "udev");790 mr_asprintf(&value, "udev"); 788 791 break; 789 792 case iso: 790 strcpy(value, "iso");793 mr_asprintf(&value, "iso"); 791 794 break; 792 795 case nfs: 793 strcpy(value, "nfs");796 mr_asprintf(&value, "nfs"); 794 797 break; 795 798 case dvd: 796 strcpy(value, "dvd");799 mr_asprintf(&value, "dvd"); 797 800 break; 798 801 case usb: 799 strcpy(value, "usb");802 mr_asprintf(&value, "usb"); 800 803 break; 801 804 default: … … 808 811 } 809 812 810 sprintf(tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir);813 mr_asprintf(&tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir); 811 814 if (write_one_liner_data_file(tmp, value)) { 812 815 res++; … … 814 817 __LINE__); 815 818 } 816 sprintf(tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir); 819 mr_free(value); 820 mr_free(tmp); 821 822 mr_asprintf(&tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir); 817 823 if (write_one_liner_data_file(tmp, bootldr_str)) { 818 824 res++; … … 820 826 __LINE__); 821 827 } 822 sprintf(tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir); 828 mr_free(bootldr_str); 829 mr_free(tmp); 830 831 mr_asprintf(&tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir); 823 832 if (bkpinfo->differential) { 824 833 res += write_one_liner_data_file(tmp, "1"); … … 826 835 res += write_one_liner_data_file(tmp, "0"); 827 836 } 837 mr_free(tmp); 828 838 829 839 if (g_getfattr) { … … 861 871 } 862 872 paranoid_free(command); 863 sprintf(tmp, "BTW, I'm telling Mindi your kernel is '%s'",864 bkpinfo->kernel_path);865 866 873 log_msg(1, "lines_in_filelist = %ld", lines_in_filelist); 867 874 … … 892 899 use_gzip_sz); // parameter #20 (STRING) 893 900 901 mr_free(devs_to_exclude); 902 mr_free(last_filelist_number); 903 mr_free(tape_device); 904 mr_free(use_lzo_sz); 905 mr_free(use_gzip_sz); 906 mr_free(use_star_sz); 907 mr_free(use_comp_sz); 908 mr_free(broken_bios_sz); 909 mr_free(cd_recovery_sz); 910 mr_free(use_lilo_sz); 911 mr_free(tape_size_sz); 912 894 913 if (bkpinfo->nonbootable_backup) { 895 914 mr_strcat(command, " NONBOOTABLE"); … … 928 947 paranoid_free(command); 929 948 } else { 930 sprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir,949 mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, 931 950 bkpinfo->tmpdir); 932 951 if (system(tmp)) { 933 952 fatal_error("Cannot find all.tar.gz in tmpdir"); 934 953 } 954 mr_free(tmp); 935 955 } 936 956 if (res) { … … 942 962 log_to_screen("Mindi failed to create your boot+data disks."); 943 963 mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 944 strcpy(tmp, call_program_and_get_last_line_of_output(command));964 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 945 965 paranoid_free(command); 946 966 … … 948 968 popup_and_OK(tmp); 949 969 } 950 } 951 paranoid_free(tmp); 952 paranoid_free(use_lzo_sz); 953 paranoid_free(use_gzip_sz); 954 paranoid_free(scratchdir); 955 paranoid_free(use_comp_sz); 956 paranoid_free(bootldr_str); 957 paranoid_free(tape_device); 958 paranoid_free(last_filelist_number); 959 paranoid_free(broken_bios_sz); 960 paranoid_free(cd_recovery_sz); 961 paranoid_free(tape_size_sz); 962 paranoid_free(devs_to_exclude); 963 paranoid_free(use_lilo_sz); 964 paranoid_free(value); 965 paranoid_free(bootdev); 966 paranoid_free(use_star_sz); 970 mr_free(tmp); 971 } 967 972 return (res); 968 973 } … … 1352 1357 char *storing_afioball_fname; 1353 1358 char *tmp = NULL; 1354 char *media_usage_comment ;1359 char *media_usage_comment = NULL; 1355 1360 pthread_t archival_thread[ARCH_THREADS]; 1356 1361 char *p_list_of_fileset_flags; … … 1370 1375 malloc_string(curr_acl_list_fname); 1371 1376 malloc_string(storing_filelist_fname); 1372 malloc_string(media_usage_comment);1373 1377 malloc_string(storing_afioball_fname); 1374 1378 transfer_block = … … 1434 1438 misc_counter_that_is_not_important = 1435 1439 (misc_counter_that_is_not_important + 1) % 5; 1440 /* BCO the media_usage_comment is not really initialized there ! 1436 1441 if (!misc_counter_that_is_not_important) { 1437 1442 update_progress_form(media_usage_comment); 1443 */ 1438 1444 } 1439 1445 sleep(1); … … 1462 1468 sleep(5); 1463 1469 } 1464 strcpy(media_usage_comment, percent_media_full_comment());1470 mr_asprintf(&media_usage_comment, "%s", percent_media_full_comment()); 1465 1471 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ 1466 1472 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 1503 1509 g_current_progress++; 1504 1510 update_progress_form(media_usage_comment); 1511 mr_free(media_usage_comment); 1505 1512 if (res) { 1506 1513 mr_asprintf(&tmp, … … 1537 1544 paranoid_free(result_str); 1538 1545 paranoid_free(storing_filelist_fname); 1539 paranoid_free(media_usage_comment);1540 1546 paranoid_free(storing_afioball_fname); 1541 1547 paranoid_free(curr_xattr_list_fname); … … 1980 1986 bool is_dev_an_NTFS_dev(char *bigfile_fname) 1981 1987 { 1982 char *tmp ;1983 char *command ;1984 malloc_string(tmp);1985 malloc_string(command); 1986 sprintf(command,1988 char *tmp = NULL; 1989 char *command = NULL; 1990 bool ret = TRUE; 1991 1992 mr_asprintf(&command, 1987 1993 "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", 1988 1994 bigfile_fname); 1989 1995 log_msg(1, "command = '%s'", command); 1990 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 1996 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 1997 mr_free(command); 1998 1991 1999 log_msg(1, "--> tmp = '%s'", tmp); 1992 2000 if (strstr(tmp, "NTFS")) { 1993 2001 iamhere("TRUE"); 1994 ret urn (TRUE);2002 ret = TRUE; 1995 2003 } else { 1996 2004 iamhere("FALSE"); 1997 return (FALSE); 1998 } 2005 ret = FALSE; 2006 } 2007 mr_free(tmp); 2008 return(ret); 1999 2009 } 2000 2010 … … 2203 2213 char *curr_acl_list_fname; 2204 2214 char *tmp = NULL; 2205 char *media_usage_comment ;2215 char *media_usage_comment = NULL; 2206 2216 2207 2217 malloc_string(curr_afioball_fname); 2208 malloc_string(media_usage_comment);2209 2218 malloc_string(curr_filelist_fname); 2210 2219 malloc_string(curr_xattr_list_fname); … … 2256 2265 } 2257 2266 2258 strcpy(media_usage_comment, percent_media_full_comment());2267 mr_asprintf(&media_usage_comment, "%s", percent_media_full_comment()); 2259 2268 2260 2269 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ … … 2294 2303 g_current_progress++; 2295 2304 update_progress_form(media_usage_comment); 2305 mr_free(media_usage_comment); 2296 2306 2297 2307 if (res) { … … 2315 2325 paranoid_free(curr_filelist_fname); 2316 2326 paranoid_free(curr_afioball_fname); 2317 paranoid_free(media_usage_comment);2318 2327 paranoid_free(curr_xattr_list_fname); 2319 2328 paranoid_free(curr_acl_list_fname); … … 2500 2509 2501 2510 /*@ buffers ******************************************************** */ 2502 char *tmp, *curr_file, *cf; 2511 char *tmp = NULL; 2512 char *curr_file = NULL 2513 char *cf; 2503 2514 2504 2515 /*@ long ************************************************************ */ … … 2507 2518 2508 2519 assert(bkpinfo != NULL); 2509 malloc_string(curr_file);2510 tmp = malloc(1200);2511 2520 would_occupy = space_occupied_by_cd(bkpinfo->scratchdir); 2512 2521 va_start(ap, files_to_add); // initialize the variable arguments … … 2515 2524 continue; 2516 2525 } 2517 strcpy(curr_file, cf);2526 mr_asprintf(&curr_file, cf); 2518 2527 if (!does_file_exist(curr_file)) { 2519 2528 log_msg(1, … … 2524 2533 would_occupy += length_of_file(curr_file) / 1024; 2525 2534 } 2535 mr_free(curr_file); 2526 2536 } 2527 2537 va_end(ap); … … 2543 2553 continue; 2544 2554 } 2545 strcpy(curr_file, cf);2546 2547 sprintf(tmp, "mv -f %s %s/archives/", curr_file,2548 bkpinfo->scratchdir);2555 mr_asprintf(&curr_file, cf); 2556 2557 mr_asprintf(&tmp, "mv -f %s %s/archives/", curr_file, bkpinfo->scratchdir); 2558 mr_free(curr_file); 2549 2559 res = run_program_and_log_output(tmp, 5); 2550 2560 retval += res; … … 2554 2564 log_msg(8, "Moved %s to CD OK", tmp); 2555 2565 } 2556 // unlink (curr_file);2566 mr_free(tmp); 2557 2567 } 2558 2568 va_end(ap); … … 2562 2572 "Warning - errors occurred while I was adding files to CD dir"); 2563 2573 } 2564 paranoid_free(tmp);2565 paranoid_free(curr_file);2566 2574 return (retval); 2567 2575 } … … 2609 2617 char start_chr; 2610 2618 char stop_chr; 2611 char *curr_file, *cf; 2619 char *curr_file = NULL 2620 char *cf; 2612 2621 /*@ long long ****************************************************** */ 2613 2622 off_t length_of_incoming_file = (off_t)0; … … 2616 2625 2617 2626 assert(bkpinfo != NULL); 2618 malloc_string(curr_file);2619 2627 va_start(ap, files_to_add); 2620 2628 for (cf = files_to_add; cf != NULL; cf = va_arg(ap, char *)) { … … 2622 2630 continue; 2623 2631 } 2624 strcpy(curr_file, cf);2632 mr_asprintf(&curr_file, cf); 2625 2633 if (!does_file_exist(curr_file)) { 2626 2634 log_msg(1, … … 2628 2636 curr_file); 2629 2637 } 2630 /* create header chars */2638 /* create header chars */ 2631 2639 start_chr = BLK_START_AN_AFIO_OR_SLICE; 2632 2640 stop_chr = BLK_STOP_AN_AFIO_OR_SLICE; 2633 /* ask for new tape if necessary */2641 /* ask for new tape if necessary */ 2634 2642 length_of_incoming_file = length_of_file(curr_file); 2635 2643 write_header_block_to_stream(length_of_incoming_file, curr_file, … … 2645 2653 retval += res; 2646 2654 unlink(curr_file); 2647 /* write closing header */ 2655 mr_free(curr_file); 2656 /* write closing header */ 2648 2657 write_header_block_to_stream((off_t)0, "finished-writing-file", stop_chr); 2649 2658 } … … 2654 2663 "Warning - errors occurred while I was adding file to tape"); 2655 2664 } 2656 paranoid_free(curr_file);2657 2665 return (retval); 2658 2666 } … … 2678 2686 char *tmp; 2679 2687 int res = 0; 2680 char *bkp ;2688 char *bkp = NULL; 2681 2689 char *cdrecord; 2682 2690 2683 2691 malloc_string(tmp); 2684 malloc_string(bkp);2685 2692 malloc_string(cdrecord); 2686 strcpy(bkp, cdrw_dev);2693 mr_asprintf(&bkp, cdrw_dev); 2687 2694 if (find_cdrw_device(cdrw_dev)) { 2688 2695 strcpy(cdrw_dev, bkp); … … 2713 2720 } 2714 2721 } 2722 mr_free(bkp); 2723 2715 2724 // retract_CD_tray_and_defeat_autorun(); 2716 2725 paranoid_free(tmp); 2717 2726 paranoid_free(cdrecord); 2718 paranoid_free(bkp);2719 2727 return (res); 2720 2728 } … … 2742 2750 char *cdrom_dev; 2743 2751 char *cdrw_dev; 2744 char *our_serial_str ;2752 char *our_serial_str = NULL; 2745 2753 bool ok_go_ahead_burn_it; 2746 2754 int cd_number = -1; … … 2758 2766 malloc_string(szcdno); 2759 2767 malloc_string(szserfname); 2760 malloc_string(our_serial_str);2761 2768 malloc_string(szunmount); 2762 2769 … … 2785 2792 sprintf(szunmount, "umount %s", mtpt); 2786 2793 cd_number = -1; 2787 our_serial_str[0] = '\0';2788 2794 sprintf(tmp, "mount %s %s", cdrom_dev, mtpt); 2795 mr_asprintf(&our_serial_str, "%s", ""); 2789 2796 if ((attempt_to_mount_returned_this = 2790 2797 run_program_and_log_output(tmp, 1))) { … … 2812 2819 cd_number = atoi(last_line_of_file(szcdno)); 2813 2820 sprintf(tmp, "cat %s 2> /dev/null", szserfname); 2814 strcpy(our_serial_str, 2821 mr_free(our_serial_str); 2822 mr_asprintf(&our_serial_str, "%s", 2815 2823 call_program_and_get_last_line_of_output(tmp)); 2816 2824 // FIXME - should be able to use last_line_of_file(), surely? … … 2836 2844 log_to_screen("...but not part of _our_ backup set."); 2837 2845 } 2846 mr_free(our_serial_str); 2838 2847 } else { 2839 2848 log_msg(2, … … 2883 2892 paranoid_free(szcdno); 2884 2893 paranoid_free(szserfname); 2885 paranoid_free(our_serial_str);2886 2894 paranoid_free(szunmount); 2887 2895 if (pmountable) { … … 2966 2974 char *checksum_line, *command; 2967 2975 char *tempblock; 2968 char *curr_slice_fname_uncompressed ;2969 char *curr_slice_fname_compressed ;2970 char *file_to_archive ;2976 char *curr_slice_fname_uncompressed = NULL; 2977 char *curr_slice_fname_compressed = NULL; 2978 char *file_to_archive = NULL; 2971 2979 char *file_to_openin; 2972 2980 /*@ pointers ************************************************** */ … … 2983 2991 long optimal_set_size; 2984 2992 bool should_I_compress_slices; 2985 char *suffix ; // for compressed slices2993 char *suffix = NULL; // for compressed slices 2986 2994 2987 2995 /*@ long long ************************************************** */ … … 3001 3009 assert_string_is_neither_NULL_nor_zerolength(biggie_filename); 3002 3010 malloc_string(checksum_line); 3003 malloc_string(curr_slice_fname_uncompressed);3004 malloc_string(curr_slice_fname_compressed);3005 malloc_string(file_to_archive);3006 malloc_string(suffix);3007 3011 command = malloc(MAX_STR_LEN * 8); 3008 3012 … … 3015 3019 if (is_this_file_compressed(biggie_filename) 3016 3020 || bkpinfo->compression_level == 0) { 3017 suffix[0] = '\0';3021 mr_asprintf(&suffix, "%s", ""); 3018 3022 // log_it("%s is indeed compressed :-)", filename); 3019 3023 should_I_compress_slices = FALSE; 3020 3024 } else { 3021 strcpy(suffix, bkpinfo->zip_suffix);3025 mr_asprintf(&suffix, "%s", bkpinfo->zip_suffix); 3022 3026 should_I_compress_slices = TRUE; 3023 3027 } … … 3050 3054 if (!(fin = popen(command, "r"))) { 3051 3055 log_OS_error("Unable to popen-in command"); 3056 mr_free(suffix); 3052 3057 return (1); 3053 3058 } … … 3072 3077 log_msg(1, "Unable to open and write to %s\n", tmp); 3073 3078 paranoid_free(tmp); 3074 paranoid_free(suffix);3079 mr_free(suffix); 3075 3080 return (1); 3076 3081 } … … 3093 3098 paranoid_free(checksum_line); 3094 3099 paranoid_free(command); 3100 mr_free(suffix); 3095 3101 return (1); 3096 3102 } … … 3106 3112 i = bkpinfo->optimal_set_size / 256; 3107 3113 for (slice_num = 1; !finished; slice_num++) { 3108 strcpy(curr_slice_fname_uncompressed,3114 mr_asprintf(&curr_slice_fname_uncompressed, "%s", 3109 3115 slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, 3110 3116 "")); 3111 strcpy(curr_slice_fname_compressed,3117 mr_asprintf(&curr_slice_fname_compressed, "%s", 3112 3118 slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, 3113 3119 suffix)); … … 3119 3125 if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) { 3120 3126 log_OS_error(curr_slice_fname_uncompressed); 3127 mr_free(suffix); 3121 3128 return (1); 3122 3129 } … … 3188 3195 paranoid_free(tmp); 3189 3196 3190 strcpy(file_to_archive, curr_slice_fname_compressed);3197 mr_asprintf(&file_to_archive, curr_slice_fname_compressed); 3191 3198 g_current_progress++; 3192 3199 } else { /* if i==0 then ... */ 3193 3200 3194 3201 finished = TRUE; 3195 strcpy(file_to_archive, curr_slice_fname_uncompressed);3202 mr_asprintf(&file_to_archive, curr_slice_fname_uncompressed); 3196 3203 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3197 3204 break; 3198 3205 } 3199 3206 } 3207 mr_free(curr_slice_fname_uncompressed); 3208 mr_free(curr_slice_fname_compressed); 3200 3209 3201 3210 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 3208 3217 res = move_files_to_cd(file_to_archive, NULL); 3209 3218 } 3219 mr_free(file_to_archive); 3220 3210 3221 retval += res; 3211 3222 if (res) { … … 3219 3230 } 3220 3231 } 3232 mr_free(suffix); 3221 3233 paranoid_fclose(fin); 3222 3234 mr_asprintf(&tmp, "Sliced bigfile #%ld", biggie_file_number + 1); … … 3232 3244 paranoid_free(checksum_line); 3233 3245 paranoid_free(command); 3234 paranoid_free(curr_slice_fname_uncompressed);3235 paranoid_free(curr_slice_fname_compressed);3236 paranoid_free(file_to_archive);3237 paranoid_free(suffix);3238 3246 return (retval); 3239 3247 }
Note:
See TracChangeset
for help on using the changeset viewer.