From c2c1f04e8a50937373d232dee673219187b7e431 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Wed, 29 Mar 2017 14:16:57 -0700 Subject: [PATCH] ALTAIR: Avoid potential buffer overrun while parsing opcodes and arguments --- ALTAIR/altair_sys.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ALTAIR/altair_sys.c b/ALTAIR/altair_sys.c index f3b2d471..5f898dfb 100644 --- a/ALTAIR/altair_sys.c +++ b/ALTAIR/altair_sys.c @@ -252,9 +252,9 @@ if ((sw & SWMASK ('C')) || ((*cptr == '"') && cptr++)) { /* ASCII string? */ or numeric (including spaces). */ -while (i < sizeof (gbuf)) { +while (i < sizeof (gbuf) - 3) { if (*cptr == ',' || *cptr == '\0' || - isdigit(*cptr)) + sim_isdigit(*cptr)) break; gbuf[i] = toupper(*cptr); cptr++; @@ -294,7 +294,7 @@ for (j = 0; j < 256; j++) { break; } if (j > 255) /* not found */ - return SCPE_ARG; + return sim_messagef (SCPE_ARG, "No such opcode: %s\n", gbuf); val[0] = j; /* store opcode */ if (oplen[j] < 2) /* if 1-byter we are done */