File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,11 +47,25 @@ bash ./update.sh >/dev/null 2>&1 || fail "second update failed"
4747cmp -s index.before index.html || fail " second update changed index.html"
4848[ " $( grep -Fxc " $entry " index.html) " -eq 1 ] || fail " prebuilt archive is listed more than once"
4949
50+ bad_name=$' bad\n name'
51+ printf ' archive=bad\narchive=name.tar.gz\n' > " binaries/$bad_name .meta"
52+ printf archive-data > " binaries/$bad_name .tar.gz"
53+ printf definition > " binaries/$bad_name "
54+ rm " $sha "
55+ if output=" $( bash ./update.sh 2>&1 ) " ; then
56+ fail " update accepted a control character in an archive name"
57+ fi
58+ case " $output " in
59+ * " Invalid archive name in binaries/" * ) ;;
60+ * ) fail " update did not reject the invalid archive name during validation" ;;
61+ esac
62+ [ ! -e " $sha " ] || fail " update created a checksum link before name validation completed"
63+ rm " binaries/$bad_name .meta" " binaries/$bad_name .tar.gz" " binaries/$bad_name "
64+
5065mkdir source
5166printf source-data > source/example.tar.gz
5267printf ' <li><a href="">example.tar.gz</a></li>\n' >> index.html
5368cp index.html index.before
54- rm " $sha "
5569cp binaries/3.14.0-ubuntu-24.04-x86_64.meta binaries/z-invalid.meta
5670sed -i ' s/^archive=.*/archive=invalid.tar.gz/' binaries/z-invalid.meta
5771if bash ./update.sh > /dev/null 2>&1 ; then
Original file line number Diff line number Diff line change @@ -61,6 +61,12 @@ for meta in binaries/*.meta; do
6161 [ -e " $meta " ] || continue
6262 name=" $( basename " $meta " .meta) "
6363 archive=" $( sed -n ' s/^archive=//p' " $meta " ) "
64+ case " $archive " in
65+ " " | * [!A-Za-z0-9._-]* )
66+ echo " Invalid archive name in $meta " >&2
67+ exit 1
68+ ;;
69+ esac
6470 if [ " $archive " != " $name .tar.gz" ]; then
6571 echo " Invalid archive in $meta " >&2
6672 exit 1
You can’t perform that action at this time.
0 commit comments