Cellular change only: fix RAT translation array bounds.
The RAT translation from the module's RAT number to the ubxlib RAT number would go wrong if the RAT number happened to go negative (i.e. no RAT of that type was present), leading to an out-of-bounds memory access. This commit fixes that.
@@ -157,11 +157,13 @@ uCellNetRat_t moduleRatToCellRat(uCellModuleType_t moduleType, int32_t rat)
{
uCellNetRat_t cellRat = U_CELL_NET_RAT_UNKNOWN_OR_NOT_USED;
+ if (rat >= 0) {
if (moduleType == U_CELL_MODULE_TYPE_SARA_U201) {
cellRat = gModuleRatToCellRatU201[rat];
} else {
cellRat = gModuleRatToCellRatR4R5[rat];
}
+ }
return cellRat;
}
