Skip to content

Commit 4881fac

Browse files
authored
mail: invalid message number accepted
* I exported a mailbox with 24 items in mbox format * The maximum valid message id is 24, but a very long number is interpreted as 24 * Another long message id is rejected, so this made me scratch my head * perl debugger shows that the invalid message number errors for 0, 25 and 1111111111 are from L842 in main::msg_print() * mailbox::messagex() takes the very long message id and returns a valid message instead of undef * mailbox::messagex() has a guard for negative array index, but does not guard against index past end of array * Adding an index guard fixes the problem on my system
1 parent 4555c26 commit 4881fac

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bin/mail

+3-1
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ sub messagex {
473473
my $self=shift;
474474
my $num=shift;
475475
return if $num <= 0;
476+
my $size = @{ $self->{'messages'} };
477+
return if $num >= $size;
476478
return(${$self->{messages}}[$num]);
477479
}
478480
sub replace {
@@ -640,7 +642,7 @@ use Getopt::Std;
640642

641643
use vars qw($opt_f $opt_s $opt_c $opt_b $opt_v);
642644

643-
our $VERSION = '0.05';
645+
our $VERSION = '0.06';
644646
our $ROWS = 23; # Screen Dimensions. Yeah, this sucks.
645647
our $COLS = 80;
646648
our $BUFFERL = 2; # Lines needed for "fluff"

0 commit comments

Comments
 (0)