]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
before calling atoi(), null the ';' so it is a proper string
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Tue, 4 Jan 2022 16:45:57 +0000 (22:15 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Tue, 4 Jan 2022 16:45:57 +0000 (22:15 +0530)
rigctl.c

index 85b9c12262d1aae4955b8c714d6be92aa43fd471..569c0cafcb7d420846eb510ce0cddbed0ce14d79 100644 (file)
--- 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