From 24561faa4f9b5648038b5c3f4de7134d18cbf77d Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Tue, 4 Jan 2022 22:15:57 +0530 Subject: [PATCH] before calling atoi(), null the ';' so it is a proper string --- rigctl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rigctl.c b/rigctl.c index 85b9c12..569c0ca 100644 --- a/rigctl.c +++ b/rigctl.c @@ -3447,13 +3447,14 @@ int parse_cmd(void *data) { sprintf(reply, "RA%02d00;", att); send_resp(client->fd, reply); } else if (command[4] == ';') { - int att = atoi(&command[2]); - if (have_rx_gain) { - att = (int)((((double)att / 99.0) * 60.0) - 12.0); - } else { - att = (int)(((double)att / 99.0) * 31.0); - } - set_attenuation_value((double)att); + command[4] = '\0'; + int att = atoi(&command[2]); + if (have_rx_gain) { + att = (int)((((double)att / 99.0) * 60.0) - 12.0); + } else { + att = (int)(((double)att / 99.0) * 31.0); + } + set_attenuation_value((double)att); } break; case 'C': // RC -- 2.45.2