]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
rng: fix port number range validation
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 23 Apr 2015 10:49:23 +0000 (11:49 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 23 Apr 2015 11:59:52 +0000 (12:59 +0100)
The PortNumber data type is declared to derive from 'short'.
Unfortunately this is an signed type, so validates the range
[-32,768, 32,767] which excludes valid port numbers between
32767 and 65535.

We can't use 'unsignedShort', since we need -1 to be a valid
port number too.

This change is to use 'int' and set an explicit max boundary
instead of relying on the data types' built-in max.

One of the existing tests is changed to use a high port number
to validate the schema.

https://bugzilla.redhat.com/show_bug.cgi?id=1214664

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
docs/schemas/basictypes.rng
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-policy.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-policy.xml

index f086ad2f3edb524ead02e4a6aaffd9d2935b95ac..a83063afcc7f529693d4f1124ec2d41f147c32dc 100644 (file)
   </define>
 
   <define name="PortNumber">
-    <data type="short">
+    <data type="int">
       <param name="minInclusive">-1</param>
+      <param name="maxInclusive">65535</param>
     </data>
   </define>
 
index 1b61fcfa1ceb632f93232925ba7eb87b125e619e..34dc767e600d4f1a4ed1d9ae738d6c8abbb74117 100644 (file)
@@ -1,4 +1,4 @@
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 /usr/bin/qemu -S -M pc -m 214 -smp 1 -monitor unix:/tmp/test-monitor,server,nowait \
 -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
--net none -serial none -parallel none -vnc 127.0.0.1:0,share=allow-exclusive
+-net none -serial none -parallel none -vnc 127.0.0.1:59630,share=allow-exclusive
index f78ff48554569938929397f36442f03165051d57..4b88e492b4b612f860db1cadf93c16cde5bdf579 100644 (file)
@@ -25,7 +25,7 @@
     <controller type='pci' index='0' model='pci-root'/>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
-    <graphics type='vnc' port='5900' autoport='no' listen='127.0.0.1' sharePolicy='allow-exclusive'>
+    <graphics type='vnc' port='65530' autoport='no' listen='127.0.0.1' sharePolicy='allow-exclusive'>
       <listen type='address' address='127.0.0.1'/>
     </graphics>
     <video>