From 8259c035e0a1b0cc102dd823ad757bb4be6dd255 Mon Sep 17 00:00:00 2001 From: Neil Webber Date: Tue, 23 Apr 2024 08:00:33 -0500 Subject: [PATCH] safeguard literal from allowing bad values into physmem --- pdpasmhelper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pdpasmhelper.py b/pdpasmhelper.py index 8f53610..581e8cf 100644 --- a/pdpasmhelper.py +++ b/pdpasmhelper.py @@ -299,6 +299,9 @@ class PDP11InstructionAssembler: def literal(self, inst, oprnd=None, /): """For hand-assembled instructions. Also allows 1 operand.""" + # prevent bad values from leaking into physical memory this way + if inst < 0 or inst > 65535: + raise ValueError(f"Bad instruction literal: {inst}") return self._1op(inst, oprnd)