diff options
author | Jim Meyering <meyering@redhat.com> | 2008-04-15 08:19:11 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-04-15 08:46:48 +0200 |
commit | 7cb24684cc4ef96bb25dfc1c819acfc3b98d9442 (patch) | |
tree | b0d71c4140509c1906993d06e5c1497fa04a13d8 /tests/misc/md5sum | |
parent | 739cf4e8325775dd6400984b3b52e67b3102e556 (diff) | |
download | coreutils-7cb24684cc4ef96bb25dfc1c819acfc3b98d9442.tar.xz |
md5sum, sha1sum, etc: handle invalid input (i.e., don't segfault)
* src/md5sum.c (bsd_split_3): Return right away if s_len == 0.
* tests/misc/md5sum (bsd-segv): New test for the above.
* tests/misc/sha1sum (bsd-segv): Likewise.
* NEWS: Mention the bug fix.
Reported by Cristian Cadar, Daniel Dunbar and Dawson Engler.
Diffstat (limited to 'tests/misc/md5sum')
-rwxr-xr-x | tests/misc/md5sum | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/misc/md5sum b/tests/misc/md5sum index ca23d9432..25069fd15 100755 --- a/tests/misc/md5sum +++ b/tests/misc/md5sum @@ -1,7 +1,7 @@ #!/bin/sh # Basic tests for "md5sum". -# Copyright (C) 1998, 1999, 2003, 2005, 2007 Free Software Foundation, Inc. +# Copyright (C) 1998-1999, 2003, 2005, 2007-2008 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF require 5.003; use strict; -(my $program_name = $0) =~ s|.*/||; +my $prog = 'md5sum'; # Turn off localisation of executable's ouput. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @@ -64,6 +64,8 @@ my @Tests = ['check-bsd3', '--check', '--status', {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, {AUX=> {f=> 'bar'}}, {EXIT=> 1}], + ['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1}, + {ERR=> "$prog: z: no properly formatted MD5 checksum lines found\n"}], ); # Insert the `--text' argument for each test. @@ -76,7 +78,6 @@ foreach $t (@Tests) my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -my $prog = 'md5sum'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); exit $fail; EOF |