Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errno.pm must not pass references to "prototype" #7558

Closed
p5pRT opened this issue Oct 25, 2004 · 5 comments
Closed

Errno.pm must not pass references to "prototype" #7558

p5pRT opened this issue Oct 25, 2004 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 25, 2004

Migrated from rt.perl.org#32130 (status was 'resolved')

Searchable as RT32130$

@p5pRT
Copy link
Author

p5pRT commented Oct 25, 2004

From qleah@earthlink.net

This is a bug report for perl from qleah@​earthlink.net,
generated with the help of perlbug 1.35 running under perl v5.8.5.


Errno.pm must not trust the user to pass only valid sub references via
EXISTS.

  perl -MErrno -e 'exists $!{[]}'

  Not a subroutine reference at
/usr/lib/perl5/5.8.5/i586-linux-multi-64int-ld/Errno.pm line 216.



Flags​:
  category=core
  severity=medium

@p5pRT
Copy link
Author

p5pRT commented Oct 25, 2004

From @rgs

Leah (via RT) wrote​:

Errno.pm must not trust the user to pass only valid sub references via
EXISTS.

perl \-MErrno \-e 'exists $\!\{\[\]\}'

Not a subroutine reference at

/usr/lib/perl5/5.8.5/i586-linux-multi-64int-ld/Errno.pm line 216.

Thanks for the report, this has been fixed by change #23423 to the
development version of perl :

Change 23424 by rgs@​valis on 2004/10/25 15​:31​:21

  Fix [perl #32130] Errno.pm must not pass references to "prototype"

Affected files ...

... //depot/perl/ext/Errno/Errno_pm.PL#39 edit
... //depot/perl/ext/Errno/t/Errno.t#3 edit

Differences ...

==== //depot/perl/ext/Errno/Errno_pm.PL#39 (text) ====

@​@​ -377,7 +377,8 @​@​

sub EXISTS {
  my ($self, $errname) = @​_;
- my $proto = prototype($errname);
+ my $r = ref $errname;
+ my $proto = !$r || $r eq 'CODE' ? prototype($errname) : undef;
  defined($proto) && $proto eq "";
}

==== //depot/perl/ext/Errno/t/Errno.t#3 (xtext) ====

@​@​ -13,7 +13,7 @​@​

use Errno;

-print "1..5\n";
+print "1..6\n";

print "not " unless @​Errno​::EXPORT_OK;
print "ok 1\n";
@​@​ -53,3 +53,6 @​@​
}

print "ok 5\n";
+
+eval { exists $!{[]} };
+print $@​ ? "not ok 6\n" : "ok 6\n";

@p5pRT
Copy link
Author

p5pRT commented Oct 25, 2004

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Oct 25, 2004

@rgs - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Oct 25, 2004
@p5pRT
Copy link
Author

p5pRT commented Oct 25, 2004

From @gbarr

On 25 Oct 2004, at 17​:57, Rafael Garcia-Suarez wrote​:

sub EXISTS {
my ($self, $errname) = @​_;
- my $proto = prototype($errname);
+ my $r = ref $errname;
+ my $proto = !$r || $r eq 'CODE' ? prototype($errname) : undef;

I don't think it should allow passing of code references. It was a
mistake that it ever did. EXISTS should only return true for errno
names that exist on the current system. So

my $proto = ref($errname) || prototype($errname);

should be sufficient because any reference would then cause the
following to fail

 defined\($proto\) && $proto eq "";

}

Graham.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant