5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-10 01:18:01 +03:00
qemu-server/PVE
Thomas Lamprecht e5caa02e05 avoid harmful '<>' pattern, explicitly read from STDIN
Fixes problems in CLIHandler using the code pattern:

while (my $line = <>) {
    ...
}

For why this causes only _now_ problems lets first look how <>
behaves:

"The null filehandle <> is special: [...] Input from <> comes either
from standard input, or from each file listed on the command line.
Here's how it works: the first time <> is evaluated, the @ARGV array
is checked, and if it is empty, $ARGV[0] is set to "-" , which when
opened gives you standard input.  The @ARGV array is then processed
as a list of filenames." - 'perldoc perlop'

Recent changes in the CLIHandler code changed how we modfiied @ARGV
Earlier we assumed that the first argument must be the command and
thus shifted it out of @ARGV, now we can have multiple levels of
(sub)commands. This change also changed how we handle @ARGV, we do
not unshift anything but go through the arguments until we got to
the final command and copy the rest of @ARGV as we know that this
must be the commandos arguments.

For '<>' this means that ARGV was still fully populated and perl
tried to open element as a file, which naturally failed.
Thus the change in pve-common only exposed this 'dangerous' code
pattern.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-22 14:56:27 +01:00
..
API2 avoid harmful '<>' pattern, explicitly read from STDIN 2018-01-22 14:56:27 +01:00
CLI avoid harmful '<>' pattern, explicitly read from STDIN 2018-01-22 14:56:27 +01:00
QemuServer Initial support for importing OVF virtual machines 2017-09-25 13:31:55 +02:00
VZDump fix #1570: fix template backup with pigz 2017-12-06 14:54:00 +01:00
Makefile add QemuServer::Memory 2016-05-23 10:02:07 +02:00
QemuConfig.pm rename foreach_writable_storage to foreach_storage_used_by_vm 2017-09-22 10:02:54 +02:00
QemuMigrate.pm migration : enable mtunnel for insecure migration V2 2017-09-12 14:15:33 +02:00
QemuServer.pm CPU flags: add spec-ctrl 2018-01-16 14:12:18 +01:00
QMPClient.pm qmpclient : block-job-(complete|cancel) : set timeout to 10min 2017-01-05 09:09:46 +01:00