From 2cda26edae1938c78d5637eec2297a5d038bbefe Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sat, 2 Nov 2002 17:23:20 +0000 Subject: [PATCH] Fix buffer overflow reported by Aranym people --- BasiliskII/src/uae_cpu/readcpu.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BasiliskII/src/uae_cpu/readcpu.cpp b/BasiliskII/src/uae_cpu/readcpu.cpp index dc563924..a870fe66 100644 --- a/BasiliskII/src/uae_cpu/readcpu.cpp +++ b/BasiliskII/src/uae_cpu/readcpu.cpp @@ -255,7 +255,7 @@ static void build_insn (int insn) int pos = 0; int mnp = 0; int bitno = 0; - char mnemonic[10]; + char mnemonic[64]; wordsizes sz = sz_long; int srcgather = 0, dstgather = 0; @@ -332,6 +332,11 @@ static void build_insn (int insn) } } mnp++; + if ((unsigned)mnp >= sizeof(mnemonic) - 1) { + mnemonic[sizeof(mnemonic) - 1] = 0; + fprintf(stderr, "Instruction %s overflow\n", mnemonic); + abort(); + } } pos++; }