Lines Matching +full:stdout +full:- +full:path

2 # SPDX-License-Identifier: GPL-2.0
4 # Test that truncation of bprm->buf doesn't cause unexpected execs paths, along
10 # b5372fe5dc84 ("exec: load_script: Do not exec truncated interpreter path")
33 # test - produce a binfmt_script hashbang line for testing
35 # @size: bytes for bprm->buf line, including hashbang but not newline
38 # @leading: any leading whitespace before the executable path
54 remaining = size - len(hashbang) - len(leading) - len(root) - len(target) - len(arg)
57 middle += fill * (NAME_MAX - 1)
59 remaining -= NAME_MAX
73 script = "binfmt_script-%s" % (name)
78 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
79 stdout = proc.communicate()[0]
81 if proc.returncode == 0 and b'Executed interpreter' in stdout:
83 print("ok %d - binfmt_script %s (successful good exec)"
87 print("not ok %d - binfmt_script %s succeeded when it should have failed"
92 print("not ok %d - binfmt_script %s failed when it should have succeeded (rc:%d)"
96 print("ok %d - binfmt_script %s (correctly failed bad exec)"
116 # Entire path is well past the BINFMT_BUF_SIZE.
117 test(name="too-big", size=SIZE+80, good=False)
118 # Path is right at max size, making it impossible to tell if it was truncated.
121 test(name="exact-space", size=SIZE, good=False, leading=" ")
123 test(name="whitespace-too-big", size=SIZE+71, good=False, root="",
125 # A good path, but it gets truncated due to leading whitespace.
131 test(name="spaces", size=SIZE-1, good=False, root="", fill=" ",
134 test(name="newline-prefix", size=SIZE-1, good=False, leading="\n",
142 root="./nix/store/bwav8kz8b3y471wjsybgzw84mrh4js9-perl-5.28.1/bin",
143-I/nix/store/x6yyav38jgr924nkna62q3pkp0dgmzlx-perl5.28.1-File-Slurp-9999.25/lib/perl5/site_perl -I…
145 test(name="one-under", size=SIZE-1)
147 test(name="two-under", size=SIZE-2)
149 test(name="exact-trunc-whitespace", size=SIZE, arg=" ")
151 test(name="exact-trunc-arg", size=SIZE, arg=" f")
152 # One bute under, with confirmed non-truncated arg since newline now visible.
153 test(name="one-under-full-arg", size=SIZE-1, arg=" f")
155 test(name="one-under-no-nl", size=SIZE-1, newline="")
157 test(name="half-under-no-nl", size=int(SIZE/2), newline="")
159 test(name="one-under-trunc-arg", size=SIZE-1, arg=" ")
161 test(name="one-under-leading", size=SIZE-1, leading=" ")
163 test(name="one-under-leading-trunc-arg", size=SIZE-1, leading=" ", arg=" ")
165 test(name="two-under-no-nl", size=SIZE-2, newline="")
166 test(name="two-under-trunc-arg", size=SIZE-2, arg=" ")
167 test(name="two-under-leading", size=SIZE-2, leading=" ")
168 test(name="two-under-leading-trunc-arg", size=SIZE-2, leading=" ", arg=" ")
170 test(name="two-under-no-nl", size=int(SIZE/2), newline="")
171 test(name="two-under-trunc-arg", size=int(SIZE/2), arg=" ")
172 test(name="two-under-leading", size=int(SIZE/2), leading=" ")
173 test(name="two-under-lead-trunc-arg", size=int(SIZE/2), leading=" ", arg=" ")