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")
31 # test - produce a binfmt_script hashbang line for testing
33 # @size: bytes for bprm->buf line, including hashbang but not newline
36 # @leading: any leading whitespace before the executable path
52 remaining = size - len(hashbang) - len(leading) - len(root) - len(target) - len(arg)
55 middle += fill * (NAME_MAX - 1)
57 remaining -= NAME_MAX
71 script = "binfmt_script-%s" % (name)
76 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
77 stdout = proc.communicate()[0]
79 if proc.returncode == 0 and b'Executed interpreter' in stdout:
81 print("ok %d - binfmt_script %s (successful good exec)"
84 print("not ok %d - binfmt_script %s succeeded when it should have failed"
88 print("not ok %d - binfmt_script %s failed when it should have succeeded (rc:%d)"
91 print("ok %d - binfmt_script %s (correctly failed bad exec)"
110 # Entire path is well past the BINFMT_BUF_SIZE.
111 test(name="too-big", size=SIZE+80, good=False)
112 # Path is right at max size, making it impossible to tell if it was truncated.
115 test(name="exact-space", size=SIZE, good=False, leading=" ")
117 test(name="whitespace-too-big", size=SIZE+71, good=False, root="",
119 # A good path, but it gets truncated due to leading whitespace.
125 test(name="spaces", size=SIZE-1, good=False, root="", fill=" ",
128 test(name="newline-prefix", size=SIZE-1, good=False, leading="\n",
136 root="./nix/store/bwav8kz8b3y471wjsybgzw84mrh4js9-perl-5.28.1/bin",
137 …-I/nix/store/x6yyav38jgr924nkna62q3pkp0dgmzlx-perl5.28.1-File-Slurp-9999.25/lib/perl5/site_perl -I…
139 test(name="one-under", size=SIZE-1)
141 test(name="two-under", size=SIZE-2)
143 test(name="exact-trunc-whitespace", size=SIZE, arg=" ")
145 test(name="exact-trunc-arg", size=SIZE, arg=" f")
146 # One bute under, with confirmed non-truncated arg since newline now visible.
147 test(name="one-under-full-arg", size=SIZE-1, arg=" f")
149 test(name="one-under-no-nl", size=SIZE-1, newline="")
151 test(name="half-under-no-nl", size=int(SIZE/2), newline="")
153 test(name="one-under-trunc-arg", size=SIZE-1, arg=" ")
155 test(name="one-under-leading", size=SIZE-1, leading=" ")
157 test(name="one-under-leading-trunc-arg", size=SIZE-1, leading=" ", arg=" ")
159 test(name="two-under-no-nl", size=SIZE-2, newline="")
160 test(name="two-under-trunc-arg", size=SIZE-2, arg=" ")
161 test(name="two-under-leading", size=SIZE-2, leading=" ")
162 test(name="two-under-leading-trunc-arg", size=SIZE-2, leading=" ", arg=" ")
164 test(name="two-under-no-nl", size=int(SIZE/2), newline="")
165 test(name="two-under-trunc-arg", size=int(SIZE/2), arg=" ")
166 test(name="two-under-leading", size=int(SIZE/2), leading=" ")
167 test(name="two-under-lead-trunc-arg", size=int(SIZE/2), leading=" ", arg=" ")