From 9e318d16a203a3efae3420ea3f5700a8d7e3bec3 Mon Sep 17 00:00:00 2001 From: Leo Broukhis Date: Thu, 9 Mar 2017 21:32:23 -0800 Subject: [PATCH] BESM6: Fixed memory access issues (COVERITY). --- BESM6/besm6_mmu.c | 6 +++--- BESM6/besm6_punchcard.c | 4 ++-- BESM6/besm6_tty.c | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/BESM6/besm6_mmu.c b/BESM6/besm6_mmu.c index e03a742a..35d2f3c6 100644 --- a/BESM6/besm6_mmu.c +++ b/BESM6/besm6_mmu.c @@ -2,7 +2,7 @@ * besm6_mmu.c: BESM-6 fast write cache and TLB registers *(стойка БРУС) * - * Copyright (c) 2009, Leonid Broukhis + * Copyright (c) 2009-2017, Leonid Broukhis * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -623,7 +623,7 @@ t_value mmu_prefetch (int addr, int actual) return 0; } else { /* Чтобы лампочки мигали */ - i = addr & 3; + i = addr; } if (addr < 0100000) { @@ -645,7 +645,7 @@ t_value mmu_prefetch (int addr, int actual) } } else val = memory[addr]; - BRS[i] = val; + BRS[i & 3] = val; return val; } diff --git a/BESM6/besm6_punchcard.c b/BESM6/besm6_punchcard.c index bae4bc19..8cc5ac16 100644 --- a/BESM6/besm6_punchcard.c +++ b/BESM6/besm6_punchcard.c @@ -173,7 +173,7 @@ static void pi_to_bytes(int unit, int card, unsigned char buf[120]) { static void pi_punch_binary(int unit, int card) { UNIT *u = &pi_unit[unit]; FILE * f = u->fileref; - unsigned char buf[120]; + static unsigned char buf[120]; pi_to_bytes(unit, card, buf); fwrite(buf, 120, 1, f); } @@ -226,7 +226,7 @@ static void pi_punch_visual(int unit, int card) { static void pi_punch_gost(int unit, int card) { UNIT *u = &pi_unit[unit]; FILE * f = u->fileref; - unsigned char buf[120]; + static unsigned char buf[120]; int len; int cur; int zero_expected = 0; diff --git a/BESM6/besm6_tty.c b/BESM6/besm6_tty.c index e4a313fd..f9117d95 100644 --- a/BESM6/besm6_tty.c +++ b/BESM6/besm6_tty.c @@ -1,7 +1,7 @@ /* * besm6_tty.c: BESM-6 teletype device * - * Copyright (c) 2009, Leo Broukhis + * Copyright (c) 2009-2017, Leo Broukhis * Copyright (c) 2009, Serge Vakulenko * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -72,8 +72,10 @@ char * process (int sym) /* For serial lines */ int tty_active [TTY_MAX+1], tty_sym [TTY_MAX+1]; int tty_typed [TTY_MAX+1], tty_instate [TTY_MAX+1]; -time_t tty_last_time [TTY_MAX+1]; -int tty_idle_count [TTY_MAX+1]; + +/* For all lines */ +time_t tty_last_time [LINES_MAX+1]; +int tty_idle_count [LINES_MAX+1]; /* The serial interrupt generator frequency, common for all VT lines */ int tty_rate = 300;