From f48549a99760105db211d647437a397999ba17c5 Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 23 Nov 2017 10:40:51 +0700 Subject: [PATCH] Validate idle-pc values for auto idle-pc feature. --- gns3server/compute/dynamips/__init__.py | 8 +++++--- gns3server/handlers/api/compute/dynamips_vm_handler.py | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gns3server/compute/dynamips/__init__.py b/gns3server/compute/dynamips/__init__.py index 000a2e53..c6fd1c05 100644 --- a/gns3server/compute/dynamips/__init__.py +++ b/gns3server/compute/dynamips/__init__.py @@ -29,16 +29,15 @@ import asyncio import tempfile import logging import glob +import re log = logging.getLogger(__name__) 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 import parse_version -from uuid import UUID, uuid4 +from uuid import uuid4 from ..base_manager import BaseManager -from ..project_manager import ProjectManager from ..port_manager import PortManager from .dynamips_error import DynamipsError from .hypervisor import Hypervisor @@ -574,6 +573,9 @@ class Dynamips(BaseManager): raise DynamipsError("No Idle-PC values found") 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]) log.debug("Auto Idle-PC: trying idle-PC value {}".format(vm.idlepc)) start_time = time.time() diff --git a/gns3server/handlers/api/compute/dynamips_vm_handler.py b/gns3server/handlers/api/compute/dynamips_vm_handler.py index 3abe40f9..1f425365 100644 --- a/gns3server/handlers/api/compute/dynamips_vm_handler.py +++ b/gns3server/handlers/api/compute/dynamips_vm_handler.py @@ -17,6 +17,7 @@ import os import sys +import aiohttp from gns3server.web.route import Route from gns3server.schemas.nio import NIO_SCHEMA @@ -466,7 +467,7 @@ class DynamipsVMHandler: # Raise error if user try to escape if filename[0] == ".": - raise aiohttp.web.HTTPForbidden + raise aiohttp.web.HTTPForbidden() yield from response.file(image_path)