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...
This commit is contained in:
parent
70da6a66d2
commit
e111d69ca2
@ -26,6 +26,12 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
|
||||||
|
#undef TRUE
|
||||||
|
#undef FALSE
|
||||||
|
#define FALSE ((int) 1)
|
||||||
|
#define TRUE ((int) 0)
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
//--------md5.c
|
//--------md5.c
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -699,7 +705,7 @@ static int md5_check(const char *checkfile_name)
|
|||||||
fgets(line, BUFSIZ-1, checkfile_stream);
|
fgets(line, BUFSIZ-1, checkfile_stream);
|
||||||
line_length = strlen(line);
|
line_length = strlen(line);
|
||||||
|
|
||||||
if (line_length <= 0)
|
if (line_length <= 0 || line==NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Ignore comment lines, which begin with a '#' character. */
|
/* Ignore comment lines, which begin with a '#' character. */
|
||||||
@ -757,9 +763,6 @@ static int md5_check(const char *checkfile_name)
|
|||||||
|
|
||||||
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
|
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
|
||||||
|
|
||||||
if (line)
|
|
||||||
free(line);
|
|
||||||
|
|
||||||
if (ferror(checkfile_stream)) {
|
if (ferror(checkfile_stream)) {
|
||||||
error_msg("%s: read error\n", checkfile_name); /* */
|
error_msg("%s: read error\n", checkfile_name); /* */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -852,31 +855,26 @@ int md5sum_main(int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (file_type_specified && do_check) {
|
if (file_type_specified && do_check) {
|
||||||
error_msg("the -b and -t options are meaningless when verifying checksums\n");
|
error_msg_and_die("the -b and -t options are meaningless when verifying checksums\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n_strings > 0 && do_check) {
|
if (n_strings > 0 && do_check) {
|
||||||
error_msg("the -g and -c options are mutually exclusive\n");
|
error_msg_and_die("the -g and -c options are mutually exclusive\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status_only && !do_check) {
|
if (status_only && !do_check) {
|
||||||
error_msg("the -s option is meaningful only when verifying checksums\n");
|
error_msg_and_die("the -s option is meaningful only when verifying checksums\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warn && !do_check) {
|
if (warn && !do_check) {
|
||||||
error_msg("the -w option is meaningful only when verifying checksums\n");
|
error_msg_and_die("the -w option is meaningful only when verifying checksums\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n_strings > 0) {
|
if (n_strings > 0) {
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
error_msg("no files may be specified when using -g\n");
|
error_msg_and_die("no files may be specified when using -g\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < n_strings; ++i) {
|
for (i = 0; i < n_strings; ++i) {
|
||||||
size_t cnt;
|
size_t cnt;
|
||||||
@ -942,13 +940,11 @@ int md5sum_main(int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fclose (stdout) == EOF) {
|
if (fclose (stdout) == EOF) {
|
||||||
error_msg("write error\n");
|
error_msg_and_die("write error\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_read_stdin && fclose (stdin) == EOF) {
|
if (have_read_stdin && fclose (stdin) == EOF) {
|
||||||
error_msg("standard input\n");
|
error_msg_and_die("standard input\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
|
32
md5sum.c
32
md5sum.c
@ -26,6 +26,12 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
|
||||||
|
#undef TRUE
|
||||||
|
#undef FALSE
|
||||||
|
#define FALSE ((int) 1)
|
||||||
|
#define TRUE ((int) 0)
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
//--------md5.c
|
//--------md5.c
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -699,7 +705,7 @@ static int md5_check(const char *checkfile_name)
|
|||||||
fgets(line, BUFSIZ-1, checkfile_stream);
|
fgets(line, BUFSIZ-1, checkfile_stream);
|
||||||
line_length = strlen(line);
|
line_length = strlen(line);
|
||||||
|
|
||||||
if (line_length <= 0)
|
if (line_length <= 0 || line==NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Ignore comment lines, which begin with a '#' character. */
|
/* Ignore comment lines, which begin with a '#' character. */
|
||||||
@ -757,9 +763,6 @@ static int md5_check(const char *checkfile_name)
|
|||||||
|
|
||||||
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
|
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
|
||||||
|
|
||||||
if (line)
|
|
||||||
free(line);
|
|
||||||
|
|
||||||
if (ferror(checkfile_stream)) {
|
if (ferror(checkfile_stream)) {
|
||||||
error_msg("%s: read error\n", checkfile_name); /* */
|
error_msg("%s: read error\n", checkfile_name); /* */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -852,31 +855,26 @@ int md5sum_main(int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (file_type_specified && do_check) {
|
if (file_type_specified && do_check) {
|
||||||
error_msg("the -b and -t options are meaningless when verifying checksums\n");
|
error_msg_and_die("the -b and -t options are meaningless when verifying checksums\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n_strings > 0 && do_check) {
|
if (n_strings > 0 && do_check) {
|
||||||
error_msg("the -g and -c options are mutually exclusive\n");
|
error_msg_and_die("the -g and -c options are mutually exclusive\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status_only && !do_check) {
|
if (status_only && !do_check) {
|
||||||
error_msg("the -s option is meaningful only when verifying checksums\n");
|
error_msg_and_die("the -s option is meaningful only when verifying checksums\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warn && !do_check) {
|
if (warn && !do_check) {
|
||||||
error_msg("the -w option is meaningful only when verifying checksums\n");
|
error_msg_and_die("the -w option is meaningful only when verifying checksums\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n_strings > 0) {
|
if (n_strings > 0) {
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
error_msg("no files may be specified when using -g\n");
|
error_msg_and_die("no files may be specified when using -g\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < n_strings; ++i) {
|
for (i = 0; i < n_strings; ++i) {
|
||||||
size_t cnt;
|
size_t cnt;
|
||||||
@ -942,13 +940,11 @@ int md5sum_main(int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fclose (stdout) == EOF) {
|
if (fclose (stdout) == EOF) {
|
||||||
error_msg("write error\n");
|
error_msg_and_die("write error\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_read_stdin && fclose (stdin) == EOF) {
|
if (have_read_stdin && fclose (stdin) == EOF) {
|
||||||
error_msg("standard input\n");
|
error_msg_and_die("standard input\n");
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user