aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-12-20 23:19:42 +0000
committerEric Andersen <andersen@codepoet.org>2000-12-20 23:19:42 +0000
commite111d69ca27a39d0a1eaf02617912092bc929c30 (patch)
tree9c65bcffd99ee9462f19e19fdb6a7ccff1370446
parent70da6a66d2d4be1b93b80616a496985ec347447d (diff)
downloadbusybox-w32-e111d69ca27a39d0a1eaf02617912092bc929c30.tar.gz
busybox-w32-e111d69ca27a39d0a1eaf02617912092bc929c30.tar.bz2
busybox-w32-e111d69ca27a39d0a1eaf02617912092bc929c30.zip
Turns out, md5sum was broken anyways. It uses backwards TRUE/FALSE
and wasnever updated when TRUE and FALSE were fixed. So kludge it by doing an #undef TRUE, then define it backwards...
-rw-r--r--coreutils/md5sum.c32
-rw-r--r--md5sum.c32
2 files changed, 28 insertions, 36 deletions
diff --git a/coreutils/md5sum.c b/coreutils/md5sum.c
index 2c08b29c5..3458f2e05 100644
--- a/coreutils/md5sum.c
+++ b/coreutils/md5sum.c
@@ -26,6 +26,12 @@
26#include <ctype.h> 26#include <ctype.h>
27#include <getopt.h> 27#include <getopt.h>
28 28
29/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
30#undef TRUE
31#undef FALSE
32#define FALSE ((int) 1)
33#define TRUE ((int) 0)
34
29//---------------------------------------------------------------------------- 35//----------------------------------------------------------------------------
30//--------md5.c 36//--------md5.c
31//---------------------------------------------------------------------------- 37//----------------------------------------------------------------------------
@@ -699,7 +705,7 @@ static int md5_check(const char *checkfile_name)
699 fgets(line, BUFSIZ-1, checkfile_stream); 705 fgets(line, BUFSIZ-1, checkfile_stream);
700 line_length = strlen(line); 706 line_length = strlen(line);
701 707
702 if (line_length <= 0) 708 if (line_length <= 0 || line==NULL)
703 break; 709 break;
704 710
705 /* Ignore comment lines, which begin with a '#' character. */ 711 /* Ignore comment lines, which begin with a '#' character. */
@@ -757,9 +763,6 @@ static int md5_check(const char *checkfile_name)
757 763
758 while (!feof(checkfile_stream) && !ferror(checkfile_stream)); 764 while (!feof(checkfile_stream) && !ferror(checkfile_stream));
759 765
760 if (line)
761 free(line);
762
763 if (ferror(checkfile_stream)) { 766 if (ferror(checkfile_stream)) {
764 error_msg("%s: read error\n", checkfile_name); /* */ 767 error_msg("%s: read error\n", checkfile_name); /* */
765 return FALSE; 768 return FALSE;
@@ -852,31 +855,26 @@ int md5sum_main(int argc,
852 } 855 }
853 856
854 if (file_type_specified && do_check) { 857 if (file_type_specified && do_check) {
855 error_msg("the -b and -t options are meaningless when verifying checksums\n"); 858 error_msg_and_die("the -b and -t options are meaningless when verifying checksums\n");
856 return EXIT_FAILURE;
857 } 859 }
858 860
859 if (n_strings > 0 && do_check) { 861 if (n_strings > 0 && do_check) {
860 error_msg("the -g and -c options are mutually exclusive\n"); 862 error_msg_and_die("the -g and -c options are mutually exclusive\n");
861 return EXIT_FAILURE;
862 } 863 }
863 864
864 if (status_only && !do_check) { 865 if (status_only && !do_check) {
865 error_msg("the -s option is meaningful only when verifying checksums\n"); 866 error_msg_and_die("the -s option is meaningful only when verifying checksums\n");
866 return EXIT_FAILURE;
867 } 867 }
868 868
869 if (warn && !do_check) { 869 if (warn && !do_check) {
870 error_msg("the -w option is meaningful only when verifying checksums\n"); 870 error_msg_and_die("the -w option is meaningful only when verifying checksums\n");
871 return EXIT_FAILURE;
872 } 871 }
873 872
874 if (n_strings > 0) { 873 if (n_strings > 0) {
875 size_t i; 874 size_t i;
876 875
877 if (optind < argc) { 876 if (optind < argc) {
878 error_msg("no files may be specified when using -g\n"); 877 error_msg_and_die("no files may be specified when using -g\n");
879 return EXIT_FAILURE;
880 } 878 }
881 for (i = 0; i < n_strings; ++i) { 879 for (i = 0; i < n_strings; ++i) {
882 size_t cnt; 880 size_t cnt;
@@ -942,13 +940,11 @@ int md5sum_main(int argc,
942 } 940 }
943 941
944 if (fclose (stdout) == EOF) { 942 if (fclose (stdout) == EOF) {
945 error_msg("write error\n"); 943 error_msg_and_die("write error\n");
946 return EXIT_FAILURE;
947 } 944 }
948 945
949 if (have_read_stdin && fclose (stdin) == EOF) { 946 if (have_read_stdin && fclose (stdin) == EOF) {
950 error_msg("standard input\n"); 947 error_msg_and_die("standard input\n");
951 return EXIT_FAILURE;
952 } 948 }
953 949
954 if (err == 0) 950 if (err == 0)
diff --git a/md5sum.c b/md5sum.c
index 2c08b29c5..3458f2e05 100644
--- a/md5sum.c
+++ b/md5sum.c
@@ -26,6 +26,12 @@
26#include <ctype.h> 26#include <ctype.h>
27#include <getopt.h> 27#include <getopt.h>
28 28
29/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
30#undef TRUE
31#undef FALSE
32#define FALSE ((int) 1)
33#define TRUE ((int) 0)
34
29//---------------------------------------------------------------------------- 35//----------------------------------------------------------------------------
30//--------md5.c 36//--------md5.c
31//---------------------------------------------------------------------------- 37//----------------------------------------------------------------------------
@@ -699,7 +705,7 @@ static int md5_check(const char *checkfile_name)
699 fgets(line, BUFSIZ-1, checkfile_stream); 705 fgets(line, BUFSIZ-1, checkfile_stream);
700 line_length = strlen(line); 706 line_length = strlen(line);
701 707
702 if (line_length <= 0) 708 if (line_length <= 0 || line==NULL)
703 break; 709 break;
704 710
705 /* Ignore comment lines, which begin with a '#' character. */ 711 /* Ignore comment lines, which begin with a '#' character. */
@@ -757,9 +763,6 @@ static int md5_check(const char *checkfile_name)
757 763
758 while (!feof(checkfile_stream) && !ferror(checkfile_stream)); 764 while (!feof(checkfile_stream) && !ferror(checkfile_stream));
759 765
760 if (line)
761 free(line);
762
763 if (ferror(checkfile_stream)) { 766 if (ferror(checkfile_stream)) {
764 error_msg("%s: read error\n", checkfile_name); /* */ 767 error_msg("%s: read error\n", checkfile_name); /* */
765 return FALSE; 768 return FALSE;
@@ -852,31 +855,26 @@ int md5sum_main(int argc,
852 } 855 }
853 856
854 if (file_type_specified && do_check) { 857 if (file_type_specified && do_check) {
855 error_msg("the -b and -t options are meaningless when verifying checksums\n"); 858 error_msg_and_die("the -b and -t options are meaningless when verifying checksums\n");
856 return EXIT_FAILURE;
857 } 859 }
858 860
859 if (n_strings > 0 && do_check) { 861 if (n_strings > 0 && do_check) {
860 error_msg("the -g and -c options are mutually exclusive\n"); 862 error_msg_and_die("the -g and -c options are mutually exclusive\n");
861 return EXIT_FAILURE;
862 } 863 }
863 864
864 if (status_only && !do_check) { 865 if (status_only && !do_check) {
865 error_msg("the -s option is meaningful only when verifying checksums\n"); 866 error_msg_and_die("the -s option is meaningful only when verifying checksums\n");
866 return EXIT_FAILURE;
867 } 867 }
868 868
869 if (warn && !do_check) { 869 if (warn && !do_check) {
870 error_msg("the -w option is meaningful only when verifying checksums\n"); 870 error_msg_and_die("the -w option is meaningful only when verifying checksums\n");
871 return EXIT_FAILURE;
872 } 871 }
873 872
874 if (n_strings > 0) { 873 if (n_strings > 0) {
875 size_t i; 874 size_t i;
876 875
877 if (optind < argc) { 876 if (optind < argc) {
878 error_msg("no files may be specified when using -g\n"); 877 error_msg_and_die("no files may be specified when using -g\n");
879 return EXIT_FAILURE;
880 } 878 }
881 for (i = 0; i < n_strings; ++i) { 879 for (i = 0; i < n_strings; ++i) {
882 size_t cnt; 880 size_t cnt;
@@ -942,13 +940,11 @@ int md5sum_main(int argc,
942 } 940 }
943 941
944 if (fclose (stdout) == EOF) { 942 if (fclose (stdout) == EOF) {
945 error_msg("write error\n"); 943 error_msg_and_die("write error\n");
946 return EXIT_FAILURE;
947 } 944 }
948 945
949 if (have_read_stdin && fclose (stdin) == EOF) { 946 if (have_read_stdin && fclose (stdin) == EOF) {
950 error_msg("standard input\n"); 947 error_msg_and_die("standard input\n");
951 return EXIT_FAILURE;
952 } 948 }
953 949
954 if (err == 0) 950 if (err == 0)