Skip to content

Commit b599bc5

Browse files
authored
Merge pull request #3389 from jbrazio/fix/set-af-validation
Validate set af input to prevent out-of-range airtime factors
2 parents 0984111 + f722794 commit b599bc5

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/helpers/CommonRadioPrefs.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
6767
return true;
6868
}
6969
if (memcmp(command, "set af ", 7) == 0) {
70-
setAirtimeFactor(atof(&command[7]));
71-
strcpy(reply, "OK");
70+
char* end;
71+
float af = strtof(&command[7], &end);
72+
if (end == &command[7] || af < 0 || af > 9) {
73+
strcpy(reply, "ERROR: af must be 0-9");
74+
} else {
75+
setAirtimeFactor(af);
76+
strcpy(reply, "OK");
77+
}
7278
return true;
7379
}
7480

0 commit comments

Comments
 (0)