@@ -347,7 +347,7 @@ static int fhss_sync_with_beacon(fhss_structure_t *fhss_structure,
347
347
348
348
if (fhss_structure ) {
349
349
// Do not allow synchronising devices above 253 hops.
350
- if (payload -> hop_count > 253 ) {
350
+ if (payload -> hop_count > ( FHSS_MAX_ALLOWED_HOPS - 1 ) ) {
351
351
return 0 ;
352
352
}
353
353
// To make synchronization monitoring more effective, drop extra Beacons.
@@ -868,6 +868,35 @@ static void fhss_beacon_decode(fhss_synchronization_beacon_payload_s* dest, cons
868
868
}
869
869
}
870
870
871
+ static int fhss_synch_info_validate (fhss_synchronization_beacon_payload_s * payload )
872
+ {
873
+ if (!payload ) {
874
+ return -1 ;
875
+ }
876
+ if (payload -> data_start_delimeter != 0 ) {
877
+ return -1 ;
878
+ }
879
+ if (payload -> current_superframe >= payload -> number_of_superframes_per_channel ) {
880
+ return -1 ;
881
+ }
882
+ if (payload -> remaining_slots >= payload -> superframe_length ) {
883
+ return -1 ;
884
+ }
885
+ if (payload -> hop_count > FHSS_MAX_ALLOWED_HOPS - 1 ) {
886
+ return -1 ;
887
+ }
888
+ if (payload -> number_of_broadcast_channels == 0 ) {
889
+ return -1 ;
890
+ }
891
+ if (payload -> number_of_tx_slots == 0 ) {
892
+ return -1 ;
893
+ }
894
+ if (payload -> number_of_superframes_per_channel == 0 ) {
895
+ return -1 ;
896
+ }
897
+ return 0 ;
898
+ }
899
+
871
900
static void fhss_beacon_received (fhss_structure_t * fhss_structure , const uint8_t * synch_info , const uint32_t elapsed_time )
872
901
{
873
902
@@ -877,9 +906,11 @@ static void fhss_beacon_received(fhss_structure_t *fhss_structure, const uint8_t
877
906
fhss_synchronization_beacon_payload_s temp_payload ;
878
907
temp_payload .processing_delay = fhss_structure -> bs -> fhss_configuration .fhss_tuning_parameters .rx_processing_delay ;
879
908
fhss_beacon_decode (& temp_payload , synch_info , elapsed_time , fhss_structure -> number_of_channels );
880
-
881
- // use the received information
882
- fhss_sync_with_beacon (fhss_structure , & temp_payload );
909
+ if (!fhss_synch_info_validate (& temp_payload )) {
910
+ fhss_sync_with_beacon (fhss_structure , & temp_payload );
911
+ } else {
912
+ tr_err ("Invalid synch info received" );
913
+ }
883
914
}
884
915
}
885
916
}
0 commit comments