Skip to content

Commit

Permalink
Correct HamRadio frequency validation (#1266)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotherNgineer committed Jul 12, 2023
1 parent fa4623d commit 4ed06b9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions firmware/application/freqman_db.cpp
Expand Up @@ -336,11 +336,18 @@ bool parse_freqman_entry(std::string_view str, freqman_entry& entry) {
if (entry.type == freqman_type::Unknown)
return false;

// Ranges should have both frequencies set and A <= B.
// Frequency A must be set for all types
if (entry.frequency_a == 0)
return false;

// Frequency B must be set for type Range or Ham Radio
if (entry.type == freqman_type::Range || entry.type == freqman_type::HamRadio) {
if (entry.frequency_a == 0 || entry.frequency_b == 0)
if (entry.frequency_b == 0)
return false;
}

// Ranges should have frequencies A <= B.
if (entry.type == freqman_type::Range) {
if (entry.frequency_a > entry.frequency_b)
return false;
}
Expand Down Expand Up @@ -457,4 +464,4 @@ bool FreqmanDB::empty() const {
// FileWrapper always presents a single line even for empty files.
// A DB is only really empty if the file size is 0.
return !wrapper_ || wrapper_->size() == 0;
}
}

0 comments on commit 4ed06b9

Please sign in to comment.