sys-kernel/vanilla-kernel: Verify version passed to has_version
authorMichał Górny <mgorny@gentoo.org>
Sat, 28 Dec 2019 20:29:45 +0000 (21:29 +0100)
committerMichał Górny <mgorny@gentoo.org>
Sat, 28 Dec 2019 20:34:33 +0000 (21:34 +0100)
Verify the version read from /usr/src/linux symlink and make sure
that it consists of plain [0-9.] before passing it to has_version.
If it doesn't conform, it isn't our symlink anyway.

Closes: https://bugs.gentoo.org/703822
Signed-off-by: Michał Górny <mgorny@gentoo.org>
sys-kernel/vanilla-kernel/vanilla-kernel-5.4.6-r1.ebuild

index 7e340bb44335e5270b43d4310f4fb2d4f50d3b6e..62465876eca3210d08c534ca97b87ba2c3797538 100644 (file)
@@ -174,8 +174,9 @@ pkg_postinst() {
        fi
 
        local symlink_target=$(readlink "${EROOT}"/usr/src/linux)
-       if [[ ${symlink_target} == linux-[0-9]* ]]; then
-               local symlink_ver=${symlink_target#linux-}
+       local symlink_ver=${symlink_target#linux-}
+       if [[ ${symlink_target} == linux-* && -z ${symlink_ver//[0-9.]/} ]]
+       then
                local symlink_pkg=${CATEGORY}/${PN}-${symlink_ver}
                # if the current target is either being replaced, or still
                # installed (probably depclean candidate), update the symlink