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

make tests pass when build directory name contains @ $ \ " #22449

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

mauke
Copy link
Contributor

@mauke mauke commented Jul 30, 2024

If you build and test perl from a directory whose name contains an @ sign (such as /tmp/hello@world/perl5), one of the tests in t/io/pipe.t fails.

This is because it takes the path to the perl binary (which is /tmp/hello@world/perl5/perl in our example) and interpolates it in double-quotes into a string that is then eval'd and run (via fresh_perl()). Thus the code that the interpreter in the child process sees is:

$Perl = "/tmp/hello@world/perl5/perl";

which of course tries to interpolate the (non-existent) @world array. (Similar problems would be caused by paths containing $ or " characters).

Switching to single quotes, as in

$Perl = '/tmp/hello@world/perl5/perl';

would fix this case, but would still be vulnerable to a path containing ' symbols.

Sidestep the problem by using q (to prevent variable interpolation) with a NUL byte delimiter (which cannot occur in path names).

Found while investigating #22446.

@jkeenan
Copy link
Contributor

jkeenan commented Jul 30, 2024

Problem confirmed.

$ pwd
/home/jkeenan/tmp/gh-22449/hello@world
[hello@world] 2009 $ cd t;./perl harness io/pipe.t; cd -
io/pipe.t .. 14/27 # Failed test 27 - but we did get the exception from die at io/pipe.t line 272
#      got "sh: 1: /home/jkeenan/tmp/gh-22449/hello/perl: not found"
# expected =~ "(?^:Died at)"
io/pipe.t .. Failed 1/27 subtests 

Test Summary Report
-------------------
io/pipe.t (Wstat: 0 Tests: 27 Failed: 1)
  Failed test:  27
Files=1, Tests=27,  8 wallclock secs ( 0.01 usr  0.00 sys +  0.03 cusr  0.01 csys =  0.05 CPU)
Result: FAIL
Finished test run at Tue Jul 30 15:57:01 2024.
/home/jkeenan/tmp/gh-22449/hello@world

Separately confirmed that p.r. works.

If you build and test perl from a directory whose name contains an `@`
sign (such as `/tmp/hello@world/perl5`), one of the tests in
`t/io/pipe.t` fails.

This is because it takes the path to the perl binary (which is
`/tmp/hello@world/perl5/perl` in our example) and interpolates it in
double-quotes into a string that is then eval'd and run (via
`fresh_perl()`). Thus the code that the interpreter in the child process
sees is:

    $Perl = "/tmp/hello@world/perl5/perl";

which of course tries to interpolate the (non-existent) `@world` array.
(Similar problems would be caused by paths containing `$` or `"`
characters).

Switching to single quotes, as in

    $Perl = '/tmp/hello@world/perl5/perl';

would fix this case, but would still be vulnerable to a path containing
`'` symbols.

Sidestep the problem by using `q` (to prevent variable interpolation)
with a NUL byte delimiter (which cannot occur in path names).

Found while investigating Perl#22446.
@mauke mauke force-pushed the build-in-at-path branch from 9f41790 to 4a92e88 Compare July 31, 2024 15:55
@mauke mauke merged commit 9a99c2b into Perl:blead Jul 31, 2024
33 checks passed
@mauke mauke deleted the build-in-at-path branch July 31, 2024 17:24
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

Successfully merging this pull request may close these issues.

2 participants