+2019-10-28 Nick Clifton <nickc@redhat.com>
+
+ * tic30-dis.c (OPERAND_BUFFER_LEN): Define. Use as length of
+ operand buffer. Set value to 15 not 13.
+ (get_register_operand): Use OPERAND_BUFFER_LEN.
+ (get_indirect_operand): Likewise.
+ (print_two_operand): Likewise.
+ (print_three_operand): Likewise.
+ (print_oar_insn): Likewise.
+
2019-10-28 Nick Clifton <nickc@redhat.com>
* ns32k-dis.c (bit_extract): Add sanitiy check of parameters.
return 1;
}
+#define OPERAND_BUFFER_LEN 15
+
static int
get_register_operand (unsigned char fragment, char *buffer)
{
{
if ((fragment & 0x1F) == current_reg->opcode)
{
- strcpy (buffer, current_reg->name);
+ strncpy (buffer, current_reg->name, OPERAND_BUFFER_LEN);
+ buffer[OPERAND_BUFFER_LEN - 1] = 0;
return 1;
}
}
int bufcnt;
len = strlen (current_ind->syntax);
+
for (i = 0, bufcnt = 0; i < len; i++, bufcnt++)
{
buffer[bufcnt] = current_ind->syntax[i];
+
if (bufcnt > 0
+ && bufcnt < OPERAND_BUFFER_LEN - 1
&& buffer[bufcnt - 1] == 'a'
&& buffer[bufcnt] == 'r')
buffer[++bufcnt] = arnum + '0';
- if (buffer[bufcnt] == '('
+
+ if (bufcnt < OPERAND_BUFFER_LEN - 1
+ && buffer[bufcnt] == '('
&& current_ind->displacement == DISP_REQUIRED)
{
- sprintf (&buffer[bufcnt + 1], "%u", disp);
- bufcnt += strlen (&buffer[bufcnt + 1]);
+ snprintf (buffer + (bufcnt + 1),
+ OPERAND_BUFFER_LEN - (bufcnt + 1),
+ "%u", disp);
+ bufcnt += strlen (buffer + (bufcnt + 1));
}
}
buffer[bufcnt + 1] = '\0';
struct instruction *insn)
{
char name[12];
- char operand[2][13] =
+ char operand[2][OPERAND_BUFFER_LEN] =
{
{0},
{0}
unsigned long insn_word,
struct instruction *insn)
{
- char operand[3][13] =
+ char operand[3][OPERAND_BUFFER_LEN] =
{
{0},
{0},
{
size_t i, len;
char *name1, *name2;
- char operand[2][3][13] =
+ char operand[2][3][OPERAND_BUFFER_LEN] =
{
{
{0},