possible fix for unsafe access in make_status_png

master
Max 2 years ago
parent ed3334ca6c
commit 18c1cc0a54
  1. 20
      op25/gr-op25_repeater/apps/rx.py
  2. 27
      op25/gr-op25_repeater/apps/trunking.py

@ -70,8 +70,6 @@ from gr_gnuplot import setup_correlation
from terminal import op25_terminal
from sockaudio import audio_thread
from create_image import create_image
#speeds = [300, 600, 900, 1200, 1440, 1800, 1920, 2400, 2880, 3200, 3600, 3840, 4000, 4800, 6000, 6400, 7200, 8000, 9600, 14400, 19200]
speeds = [4800, 6000]
@ -679,23 +677,6 @@ class p25_rx_block (gr.top_block):
msg = gr.message().make_from_string(json.dumps(d), -4, 0, 0)
self.input_q.insert_tail(msg)
def make_status_png(self):
PNG_UPDATE_INTERVAL = 1.0
output_file = '../www/images/status.png'
tmp_output_file = '../www/images/tmp-status.png'
if time.time() < self.next_status_png:
return
self.next_status_png = time.time() + PNG_UPDATE_INTERVAL
if self.trunk_rx is None:
return ## possible race cond - just ignore
status_str = 'OP25-hls hacks (c) Copyright 2020, KA1RBI\n'
status_str += 'F %f TG %s %s at %s\n' % ( self.last_freq_params['freq'] / 1000000.0, self.last_freq_params['tgid'], self.last_freq_params['tag'], time.asctime())
status_str += self.trunk_rx.to_string()
status = status_str.split('\n')
status = [s for s in status if not s.startswith('tbl-id')]
create_image(status, imgfile=tmp_output_file, bgcolor="#c0c0c0", windowsize=(640,480))
os.rename(tmp_output_file, output_file)
def process_qmsg(self, msg):
# return true = end top block
RX_COMMANDS = 'skip lockout hold'.split()
@ -716,7 +697,6 @@ class p25_rx_block (gr.top_block):
msg = gr.message().make_from_string(js, -4, 0, 0)
self.input_q.insert_tail(msg)
self.process_ajax()
self.make_status_png()
elif s == 'set_freq':
freq = msg.arg1()
self.last_freq_params['freq'] = freq

@ -21,12 +21,14 @@
#
import sys
import os
import time
import collections
import json
sys.path.append('tdma')
import lfsr
from tsvfile import make_config, load_tsv
from create_image import create_image
def crc16(dat,len): # slow version
poly = (1<<12) + (1<<5) + (1<<0)
@ -610,6 +612,8 @@ class rx_ctl (object):
if self.logfile_workers:
self.input_rate = self.logfile_workers[0]['demod'].input_rate
self.enabled_nacs = None
self.next_status_png = time.time()
self.last_freq_params = {'freq' : 0.0, 'tgid' : None, 'tag' : "", 'tdma' : None}
if conf_file:
if conf_file.endswith('.tsv'):
@ -753,6 +757,21 @@ class rx_ctl (object):
'hold_mode': self.hold_mode}
return json.dumps(d)
def make_status_png(self):
PNG_UPDATE_INTERVAL = 1.0
output_file = '../www/images/status.png'
tmp_output_file = '../www/images/tmp-status.png'
if time.time() < self.next_status_png:
return
self.next_status_png = time.time() + PNG_UPDATE_INTERVAL
status_str = 'OP25-hls hacks (c) Copyright 2020, 2021, KA1RBI\n'
status_str += 'F %f TG %s %s at %s\n' % ( self.last_freq_params['freq'] / 1000000.0, self.last_freq_params['tgid'], self.last_freq_params['tag'], time.asctime())
status_str += self.to_string()
status = status_str.split('\n')
status = [s for s in status if not s.startswith('tbl-id')]
create_image(status, imgfile=tmp_output_file, bgcolor="#c0c0c0", windowsize=(640,480))
os.rename(tmp_output_file, output_file)
def dump_tgids(self):
for nac in self.trunked_systems.keys():
self.trunked_systems[nac].dump_tgids()
@ -843,6 +862,8 @@ class rx_ctl (object):
sys.stderr.write('type %d at %f state %d len %d/%d opcode %x [%x/%x]\n' %(mtype, time.time(), self.current_state, len(s1), len(s2), opcode, header,mbt_data))
updated += self.trunked_systems[nac].decode_mbt_data(opcode, src, header << 16, mbt_data << 32)
self.make_status_png()
if nac != self.current_nac:
if self.debug > 10: # this is occasionally expected if cycling between different tsys
cnac = self.current_nac
@ -1151,7 +1172,7 @@ class rx_ctl (object):
self.current_tgid = None
if new_frequency is not None:
self.set_frequency({
params = {
'freq': new_frequency,
'tgid': self.current_tgid,
'offset': tsys.offset,
@ -1166,7 +1187,9 @@ class rx_ctl (object):
'grpaddr': tsys.current_grpaddr,
'alg': tsys.current_alg,
'algid': tsys.current_algid,
'keyid': tsys.current_keyid })
'keyid': tsys.current_keyid }
self.last_freq_params = params
self.set_frequency(params)
if new_state is not None:
self.current_state = new_state

Loading…
Cancel
Save