Validate idle-pc values for auto idle-pc feature.

This commit is contained in:
grossmj 2017-11-23 10:40:51 +07:00
parent 958ab2294c
commit f48549a997
2 changed files with 7 additions and 4 deletions

View File

@ -29,16 +29,15 @@ import asyncio
import tempfile import tempfile
import logging import logging
import glob import glob
import re
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
from gns3server.utils.interfaces import interfaces, is_interface_up from gns3server.utils.interfaces import interfaces, is_interface_up
from gns3server.utils.images import md5sum
from gns3server.utils.asyncio import wait_run_in_executor from gns3server.utils.asyncio import wait_run_in_executor
from gns3server.utils import parse_version from gns3server.utils import parse_version
from uuid import UUID, uuid4 from uuid import uuid4
from ..base_manager import BaseManager from ..base_manager import BaseManager
from ..project_manager import ProjectManager
from ..port_manager import PortManager from ..port_manager import PortManager
from .dynamips_error import DynamipsError from .dynamips_error import DynamipsError
from .hypervisor import Hypervisor from .hypervisor import Hypervisor
@ -574,6 +573,9 @@ class Dynamips(BaseManager):
raise DynamipsError("No Idle-PC values found") raise DynamipsError("No Idle-PC values found")
for idlepc in idlepcs: for idlepc in idlepcs:
match = re.search(r"^0x[0-9a-f]{8}$", idlepc.split()[0])
if not match:
continue
yield from vm.set_idlepc(idlepc.split()[0]) yield from vm.set_idlepc(idlepc.split()[0])
log.debug("Auto Idle-PC: trying idle-PC value {}".format(vm.idlepc)) log.debug("Auto Idle-PC: trying idle-PC value {}".format(vm.idlepc))
start_time = time.time() start_time = time.time()

View File

@ -17,6 +17,7 @@
import os import os
import sys import sys
import aiohttp
from gns3server.web.route import Route from gns3server.web.route import Route
from gns3server.schemas.nio import NIO_SCHEMA from gns3server.schemas.nio import NIO_SCHEMA
@ -466,7 +467,7 @@ class DynamipsVMHandler:
# Raise error if user try to escape # Raise error if user try to escape
if filename[0] == ".": if filename[0] == ".":
raise aiohttp.web.HTTPForbidden raise aiohttp.web.HTTPForbidden()
yield from response.file(image_path) yield from response.file(image_path)