[RFA] Correct problem in s390-opc.tab generation
Pierre Muller
pierre.muller@ics-cnrs.unistra.fr
Wed Sep 29 15:39:00 GMT 2010
Using
s390-opc.tab generation leads to errors
due to longer description fields:
The longest description is 72 char long,
while s390-mkopc.c has a description array of size 60,
without any length limitation.
This leads to format array overwriting and uncompilable
code...
This is how I compute the longest description line:
$ cat s390-opc.txt | gawk -F '"' '{print $2}' |wc -L
72
Proposed patch:
1) Increase sdescription size to 80
2) Add a limitation that will generate a failure
in the sscanf routine rather than creating trash.
About point 2) I am not sure that adding a length
to that sscanf construct is supported by all scanners...
Is this OK?
Pierre Muller
Pascal language support maintainer for GDB
opcodes ChangeLog entry:
2010-09-28 Pierre Muller <muller@ics.u-strasbg.fr>
* s390-mkopc.c (main): Change description array size to 80.
Add maximum length of 79 to description parsing.
Index: s390-mkopc.c
===================================================================
RCS file: /cvs/src/src/opcodes/s390-mkopc.c,v
retrieving revision 1.16
diff -u -p -r1.16 s390-mkopc.c
--- s390-mkopc.c 27 Sep 2010 13:36:48 -0000 1.16
+++ s390-mkopc.c 29 Sep 2010 15:30:14 -0000
@@ -335,7 +335,7 @@ main (void)
char opcode[16];
char mnemonic[16];
char format[16];
- char description[64];
+ char description[80];
char cpu_string[16];
char modes_string[16];
int min_cpu;
@@ -345,7 +345,7 @@ main (void)
if (currentLine[0] == '#')
continue;
memset (opcode, 0, 8);
- if (sscanf (currentLine, "%15s %15s %15s \"%[^\"]\" %15s %15s",
+ if (sscanf (currentLine, "%15s %15s %15s \"%79[^\"]\" %15s %15s",
opcode, mnemonic, format, description,
cpu_string, modes_string) == 6)
{
More information about the Binutils
mailing list