I1401: Fixed MTF length checking (COVERITY)

This commit is contained in:
Bob Supnik 2017-03-20 07:43:41 -07:00 committed by Mark Pizzolato
parent 0e6a79f078
commit a040eb4e32
2 changed files with 26 additions and 20 deletions

View file

@ -919,8 +919,8 @@ switch (I_GETOP (MB)) { /* case on <1:6> */
t2 = GETDBL_S (SEXT (AR), BR); /* get A'B */ t2 = GETDBL_S (SEXT (AR), BR); /* get A'B */
t3 = t2 << t1; /* "arith" left */ t3 = t2 << t1; /* "arith" left */
PUTDBL_S (t3); /* store A'B */ PUTDBL_S (t3); /* store A'B */
if ((t2 >> (31 - t1)) != /* shf out = sgn? */ if ((t2 >> (31 - t1)) != ((AR & SIGN)? -1: 0)) /* shf out = sgn? */
((AR & SIGN)? -1: 0)) C = 1; C = 1;
break; break;
case 012: /* LLR */ case 012: /* LLR */

View file

@ -1,6 +1,6 @@
/* i1401_cpu.c: IBM 1401 CPU simulator /* i1401_cpu.c: IBM 1401 CPU simulator
Copyright (c) 1993-2015, Robert M. Supnik Copyright (c) 1993-2017, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -23,6 +23,7 @@
used in advertising or otherwise to promote the sale, use or other dealings used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik. in this Software without prior written authorization from Robert M Supnik.
13-Mar-17 RMS Fixed MTF length checking (COVERITY)
30-Jan-15 RMS Fixed treatment of overflow (Ken Shirriff) 30-Jan-15 RMS Fixed treatment of overflow (Ken Shirriff)
08-Oct-12 RMS Clear storage and branch preserves B register (Van Snyder) 08-Oct-12 RMS Clear storage and branch preserves B register (Van Snyder)
19-Mar-11 RMS Reverted multiple tape indicator implementation 19-Mar-11 RMS Reverted multiple tape indicator implementation
@ -720,7 +721,7 @@ CHECK_LENGTH:
1 chained A and B 1 chained A and B
2,3 invalid A-address 2,3 invalid A-address
4 chained B address 4 chained B address
5,6 invalid B-address 5,6 invalid B-address - checked in fetch
7 normal 7 normal
8+ normal + modifier 8+ normal + modifier
*/ */
@ -772,9 +773,9 @@ CHECK_LENGTH:
Instruction lengths: Instruction lengths:
1 chained 1 chained
2,3 invalid A-address 2,3 invalid A-address - checked in fetch
4 self (B-address = A-address) 4 self (B-address = A-address)
5,6 invalid B-address 5,6 invalid B-address - checked in fetch
7 normal 7 normal
8+ normal + ignored modifier 8+ normal + ignored modifier
*/ */
@ -1027,7 +1028,7 @@ CHECK_LENGTH:
WR write and read if branch WR write and read if branch
P punch a card if branch P punch a card if branch
RP read and punch if branch RP read and punch if branch
WP : write and punch if branch WP write and punch if branch
WRP write read and punch if branch WRP write read and punch if branch
RF read feed (nop) RF read feed (nop)
PF punch feed (nop) PF punch feed (nop)
@ -1148,19 +1149,24 @@ CHECK_LENGTH:
Instruction lengths: Instruction lengths:
1-3 invalid I/O address 1-3 invalid I/O address - checked here
4 normal, d-character is unit 4 normal, d-character is unit
5 normal 5 normal, d-character is last character
6+ normal, d-character is last character 6+ normal, d-character is last character
*/ */
case OP_MTF: /* magtape function */ case OP_MTF: /* magtape function */
if (ilnt < 4) /* too short? */ if (ilnt < 4) { /* too short? */
reason = STOP_INVL; reason = STOP_INVL;
else if (ioind != BCD_PERCNT) /* valid dev addr? */
reason = STOP_INVA;
else if ((reason = iomod (ilnt, D, mtf_mod))) /* valid modifier? */
break; break;
}
if (ioind != BCD_PERCNT) { /* valid dev addr? */
reason = STOP_INVA;
break;
}
if (reason = iomod (ilnt, D, mtf_mod)) /* valid modifier? */
break;
if (dev == IO_MT) /* BCD? */ if (dev == IO_MT) /* BCD? */
reason = mt_func (unit, 0, D); reason = mt_func (unit, 0, D);
else if (dev == IO_MTB) /* binary? */ else if (dev == IO_MTB) /* binary? */
@ -1196,9 +1202,9 @@ CHECK_LENGTH:
Instruction lengths: Instruction lengths:
1 chained 1 chained
2,3 invalid A-address 2,3 invalid A-address - checked in fetch
4 self (B-address = A-address) 4 self (B-address = A-address)
5,6 invalid B-address 5,6 invalid B-address - checked in fetch
7 normal 7 normal
8+ normal + ignored modifier 8+ normal + ignored modifier
*/ */
@ -1372,9 +1378,9 @@ CHECK_LENGTH:
Instruction lengths: Instruction lengths:
1 chained 1 chained
2,3 invalid A-address 2,3 invalid A-address - checked in fetch
4 self (B-address = A-address) 4 self (B-address = A-address)
5,6 invalid B-address 5,6 invalid B-address - checked in fetch
7 normal 7 normal
8+ normal + ignored modifier 8+ normal + ignored modifier
*/ */
@ -1449,9 +1455,9 @@ CHECK_LENGTH:
Instruction lengths: Instruction lengths:
1 chained 1 chained
2,3 invalid A-address 2,3 invalid A-address - checked in fetch
4 self (B-address = A-address) 4 self (B-address = A-address)
5,6 invalid B-address 5,6 invalid B-address - checked in fetch
7 normal 7 normal
8+ normal + ignored modifier 8+ normal + ignored modifier
*/ */