Commit e8f1f9db8787be08e0ae3ed5a94da68966dbfff1

Authored by aliguori
1 parent 0b1bcb00

net: Check device passed to host_net_remove (Jan Kiszka)

Make sure that we do not delete guest NICs via host_net_remove.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7195 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 8 additions and 2 deletions
... ... @@ -1858,14 +1858,20 @@ void net_host_device_remove(Monitor *mon, int vlan_id, const char *device)
1858 1858  
1859 1859 vlan = qemu_find_vlan(vlan_id);
1860 1860  
1861   - for(vc = vlan->first_client; vc != NULL; vc = vc->next)
1862   - if (!strcmp(vc->name, device))
  1861 + for (vc = vlan->first_client; vc != NULL; vc = vc->next) {
  1862 + if (!strcmp(vc->name, device)) {
1863 1863 break;
  1864 + }
  1865 + }
1864 1866  
1865 1867 if (!vc) {
1866 1868 monitor_printf(mon, "can't find device %s\n", device);
1867 1869 return;
1868 1870 }
  1871 + if (!net_host_check_device(vc->model)) {
  1872 + monitor_printf(mon, "invalid host network device %s\n", device);
  1873 + return;
  1874 + }
1869 1875 qemu_del_vlan_client(vc);
1870 1876 }
1871 1877  
... ...