NOVA: Fixed missing break in loader & overlook case in address parse (COVERITY)

This commit is contained in:
Bob Supnik 2017-03-09 19:47:50 -08:00 committed by Mark Pizzolato
parent 97a11f2b05
commit 396dd88def

View file

@ -1,6 +1,6 @@
/* nova_sys.c: NOVA simulator interface /* nova_sys.c: NOVA simulator interface
Copyright (c) 1993-2012, 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,9 +23,11 @@
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.
09-Mar-17 RMS Fixed missing break in loader (COVERITY)
Fixed overlook case in address parse (COVERITY)
25-Mar-12 RMS Fixed declaration (Mark Pizzolato) 25-Mar-12 RMS Fixed declaration (Mark Pizzolato)
04-Jul-07 BKR DEC's IOF/ION changed to DG's INTDS/INTEN mnemonic, 04-Jul-07 BKR DEC's IOF/ION changed to DG's INTDS/INTEN mnemonic,
Fixed QTY/ADCV device name, Fixed QTY/ADCV device name
RDSW changed to DDG's READS mnemonic, RDSW changed to DDG's READS mnemonic,
fixed/enhanced 'load' command for DG-compatible binary tape format fixed/enhanced 'load' command for DG-compatible binary tape format
26-Mar-04 RMS Fixed warning with -std=c99 26-Mar-04 RMS Fixed warning with -std=c99
@ -178,9 +180,9 @@ t_stat sim_load (FILE *fileref, CONST char *cptr, CONST char *fnam, int flag)
{ {
int32 data, csum, count, state, i; int32 data, csum, count, state, i;
int32 origin; int32 origin;
int pos ; int pos;
int block_start ; int block_start;
int done ; int done;
if ((*cptr != 0) || (flag != 0)) if ((*cptr != 0) || (flag != 0))
return ( SCPE_ARG ) ; return ( SCPE_ARG ) ;
@ -193,7 +195,7 @@ for ( pos = 0 ; (! done) && ((i=getc(fileref)) != EOF) ; ++pos )
switch (state) { switch (state) {
case 0: /* leader */ case 0: /* leader */
count = i; count = i;
state = (count != 0) ; state = (count != 0);
if ( state ) if ( state )
block_start = pos ; block_start = pos ;
break; break;
@ -204,8 +206,7 @@ for ( pos = 0 ; (! done) && ((i=getc(fileref)) != EOF) ; ++pos )
case 2: /* low origin */ case 2: /* low origin */
origin = i; origin = i;
state = 3; state = 3;
break ; break;
case 3: /* high origin */ case 3: /* high origin */
origin = (i << 8) | origin; origin = (i << 8) | origin;
csum = csum + origin; csum = csum + origin;
@ -216,7 +217,7 @@ for ( pos = 0 ; (! done) && ((i=getc(fileref)) != EOF) ; ++pos )
state = 5; state = 5;
break; break;
case 5: /* high checksum */ case 5: /* high checksum */
csum = (csum + (i << 8)) & 0xFFFF ; csum = (csum + (i << 8)) & 0xFFFF;
if (count == 1) if (count == 1)
{ {
/* 'start' block */ /* 'start' block */
@ -229,22 +230,24 @@ for ( pos = 0 ; (! done) && ((i=getc(fileref)) != EOF) ; ++pos )
{ {
sim_printf( "auto start @ %05o \n", (origin & 0x7FFF) ) ; sim_printf( "auto start @ %05o \n", (origin & 0x7FFF) ) ;
} }
break ; break;
} }
if ( ((count & 0x8000) == 0) && (count > 1)) if ( ((count & 0x8000) == 0) && (count > 1))
{ {
/* 'ignore' block */ /* 'ignore' block */
state = 8 ; state = 8;
break;
} }
/* 'data' or 'repeat' block */
count = 0200000 - count ; /* 'data' or 'repeat' block */
if ( count <= 020 ) count = 0200000 - count ;
if ( count <= 020 )
{ {
/* 'data' block */ /* 'data' block */
state = 6 ; state = 6;
break ; break;
} }
/* 'repeat' block (multiple data) */ /* 'repeat' block (multiple data) */
if (count > 020) { /* large block */ if (count > 020) { /* large block */
for (count = count - 1; count > 1; count--) { for (count = count - 1; count > 1; count--) {
@ -265,9 +268,9 @@ for ( pos = 0 ; (! done) && ((i=getc(fileref)) != EOF) ; ++pos )
break; break;
case 7: /* high data */ case 7: /* high data */
data = (i << 8) | data; data = (i << 8) | data;
csum = (csum + data) & 0xFFFF ; csum = (csum + data) & 0xFFFF;
if (origin >= AMASK /* MEMSIZE? */) if (origin >= AMASK)
return SCPE_NXM; return SCPE_NXM;
M[origin] = data; M[origin] = data;
origin = origin + 1; origin = origin + 1;
@ -879,6 +882,7 @@ if (*cptr == '@') { /* indirect? */
if (*cptr == '.') { /* relative? */ if (*cptr == '.') { /* relative? */
pflag = pflag | A_PER; pflag = pflag | A_PER;
x = 1; /* "index" is PC */ x = 1; /* "index" is PC */
d = 0; /* default disp is 0 */
cptr++; cptr++;
} }
if (*cptr == '+') { /* + sign? */ if (*cptr == '+') { /* + sign? */