Skip to content

Commit

Permalink
admin.vm.volume.Import: Limit bytes read into bash variable
Browse files Browse the repository at this point in the history
stdin is not trusted.  Only read 22 bytes of it into the requested_size
variable, and error out if the value is too long.
  • Loading branch information
DemiMarie committed Dec 20, 2022
1 parent d17f8bc commit c10ce5b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion qubes-rpc/admin.vm.volume.Import
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ trap 'rm -f $tmpfile' EXIT

requested_size=""
if [[ "${0##*/}" == admin.vm.volume.ImportWithSize ]]; then
read -r requested_size
read -r -n 22 requested_size
if [[ "${#requested_size}" -gt 20 ]]; then
echo "Size provided is too long: expected no more than 20 bytes, but got ${#requested_size}" >&2
exit 1
fi
fi

echo -n "$requested_size" | qubesd-query -c /var/run/qubesd.internal.sock \
Expand Down

0 comments on commit c10ce5b

Please sign in to comment.