oeqa/selftest: Add test for shebang overflow

Make sure we do not stage any executable with a bigger shebang
than 128. Fixes [1]

[1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=11053

(From OE-Core rev: 280f68528c93b5ffab888c99190accf59e807a3f)

Signed-off-by: Paulo Neves <ptsneves@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paulo Neves 2022-06-14 17:11:02 +02:00 committed by Richard Purdie
parent 82589b5936
commit 53f0ee8d42
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,12 @@
SUMMARY = "Check that shebang does not exceed 128 characters"
LICENSE = "CLOSED"
INHIBIT_DEFAULT_DEPS = "1"
EXCLUDE_FROM_WORLD = "1"
do_install() {
install -d ${D}${bindir}
echo '#!BiM3cnVd1Amtv6PG+FynrQiVMbZnX5ELgF21q3EkuB+44JEGWtq8TvBJ7EGidfVs3eR3wVOUbLnjYDlKUWcm7YC/ute7f+KDHbwxziRUSUBZAUqgjiQdfQ0HnxajI0ozbM863E9JV9k13yZKYfh9/zR77Y6Dl4Dd3zOWS75LSpkAXV' > ${D}${bindir}/max-shebang
chmod 755 ${D}${bindir}/max-shebang
}
BBCLASSEXTEND = "native"

View File

@ -35,3 +35,13 @@ TESTSTRING:pn-sysroot-test-arch1 = "%s"
TESTSTRING:pn-sysroot-test-arch2 = "%s"
""" % (uuid1, uuid2))
bitbake("sysroot-test")
def test_sysroot_max_shebang(self):
"""
Summary: Check max shebang triggers. To confirm [YOCTO #11053] is closed.
Expected: Fail when a shebang bigger than the max shebang-size is reached.
Author: Paulo Neves <ptsneves@gmail.com>
"""
expected = "maximum shebang size exceeded, the maximum size is 128. [shebang-size]"
res = bitbake("sysroot-shebang-test-native -c populate_sysroot", ignore_status=True)
self.assertTrue(expected in res.output, msg=res.output)