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

Lvalue vec() unreliably propagates tainting #22192

Open
leonerd opened this issue May 3, 2024 · 1 comment
Open

Lvalue vec() unreliably propagates tainting #22192

leonerd opened this issue May 3, 2024 · 1 comment
Labels
taint Relates to taint-mode (`perl -T`)

Comments

@leonerd
Copy link
Contributor

leonerd commented May 3, 2024

If the value being assigned into an lvalue vec() is tainted, it sometimes does and sometimes doesn't propagate that tainting to the modified scalar.

In the (unlikely) cornercase that vec() itself has to create/upgrade the scalar from NULL, then the newly-created scalar does have tainting:

$ perl -T -MTaint::Util
use v5.36;
taint( my $y = 123 );
vec( my $x, 0, 8 ) = $y;
say "TAINTED" if tainted $x;
__END__
TAINTED

However, if the SV was already at least an SVt_PV and vec() is just modifying it in place (possibly by extending the PV buffer) then no tainting is propagated:

$ perl -T -MTaint::Util
use v5.36;
taint( my $y = 123 );
vec( my $x = "", 0, 8 ) = $y;
say "TAINTED" if tainted $x;
__END__

$ perl -T -MTaint::Util
use v5.36;
taint( my $y = 123 );
vec( my $x = "X", 0, 8 ) = $y;
say "TAINTED" if tainted $x;
__END__

@leonerd leonerd added Needs Triage Work In Progress This PR is in progress and is not meant to be merged yet. taint Relates to taint-mode (`perl -T`) and removed Needs Triage Work In Progress This PR is in progress and is not meant to be merged yet. labels May 3, 2024
@iabyn
Copy link
Contributor

iabyn commented May 6, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
taint Relates to taint-mode (`perl -T`)
Projects
None yet
Development

No branches or pull requests

2 participants