More afl fixes.
This commit is contained in:
@@ -90,8 +90,10 @@ static bool json_parse_header(json_t *in, struct packet *packet, struct json_par
|
||||
}
|
||||
|
||||
if (mlat_timestamp_mhz > UINT16_MAX ||
|
||||
mlat_timestamp_max < 0 ||
|
||||
rssi_max > UINT32_MAX) {
|
||||
mlat_timestamp_mhz <= 0 ||
|
||||
mlat_timestamp_max <= 0 ||
|
||||
rssi_max > UINT32_MAX ||
|
||||
rssi_max <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ char *packet_type_names[] = {
|
||||
};
|
||||
|
||||
static uint64_t packet_mlat_timestamp_scale_mhz_in(uint64_t timestamp, uint32_t mhz) {
|
||||
assert(mhz > 0);
|
||||
return timestamp * (PACKET_MLAT_MHZ / mhz);
|
||||
}
|
||||
|
||||
@@ -27,10 +28,12 @@ static uint64_t packet_mlat_timestamp_scale_width_in(uint64_t timestamp, uint64_
|
||||
}
|
||||
|
||||
static uint64_t packet_mlat_timestamp_scale_mhz_out(uint64_t timestamp, uint64_t mhz) {
|
||||
assert(mhz > 0);
|
||||
return timestamp / (PACKET_MLAT_MHZ / mhz);
|
||||
}
|
||||
|
||||
static uint64_t packet_mlat_timestamp_scale_width_out(uint64_t timestamp, uint64_t max) {
|
||||
assert(max > 0);
|
||||
return timestamp % max;
|
||||
}
|
||||
|
||||
@@ -43,10 +46,12 @@ uint64_t packet_mlat_timestamp_scale_out(uint64_t timestamp, uint64_t max, uint1
|
||||
}
|
||||
|
||||
uint32_t packet_rssi_scale_in(uint32_t value, uint32_t max) {
|
||||
assert(max > 0);
|
||||
return value * (PACKET_RSSI_MAX / max);
|
||||
}
|
||||
|
||||
uint32_t packet_rssi_scale_out(uint32_t value, uint32_t max) {
|
||||
assert(max > 0);
|
||||
return value / (PACKET_RSSI_MAX / max);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,11 +91,16 @@ static bool proto_parse_header(AdsbHeader *header, struct packet *packet, struct
|
||||
return false;
|
||||
}
|
||||
|
||||
state->have_header = true;
|
||||
fprintf(stderr, "R %s: Connected to server ID: %s\n", packet->source_id, header->server_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool proto_parse_packet(AdsbPacket *in, struct packet *packet, struct proto_parser_state *state, size_t len) {
|
||||
if (!state->have_header) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (in->payload.len != len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user