@@ -50,7 +50,7 @@ static uint8_t otp_slot_item_cache[SIZEOF_KEYSTORE_SLOT];
5050uint8_t * keystore_get_buffer (int id )
5151{
5252 struct keystore_slot * slot ;
53- if (id >= keystore_num_pubkeys ())
53+ if (id < 0 || id >= keystore_num_pubkeys ())
5454 return (uint8_t * )0 ;
5555 if (hal_flash_otp_read (FLASH_OTP_BASE +
5656 OTP_HDR_SIZE + id * SIZEOF_KEYSTORE_SLOT , otp_slot_item_cache ,
@@ -63,7 +63,7 @@ uint8_t *keystore_get_buffer(int id)
6363int keystore_get_size (int id )
6464{
6565 struct keystore_slot * slot ;
66- if (id >= keystore_num_pubkeys ())
66+ if (id < 0 || id >= keystore_num_pubkeys ())
6767 return -1 ;
6868 if (hal_flash_otp_read (FLASH_OTP_BASE +
6969 OTP_HDR_SIZE + id * SIZEOF_KEYSTORE_SLOT , otp_slot_item_cache ,
@@ -76,7 +76,7 @@ int keystore_get_size(int id)
7676uint32_t keystore_get_mask (int id )
7777{
7878 struct keystore_slot * slot ;
79- if (id >= keystore_num_pubkeys ())
79+ if (id < 0 || id >= keystore_num_pubkeys ())
8080 return 0 ;
8181 if (hal_flash_otp_read (FLASH_OTP_BASE +
8282 OTP_HDR_SIZE + id * SIZEOF_KEYSTORE_SLOT , otp_slot_item_cache ,
@@ -89,7 +89,7 @@ uint32_t keystore_get_mask(int id)
8989uint32_t keystore_get_key_type (int id )
9090{
9191 struct keystore_slot * slot ;
92- if (id >= keystore_num_pubkeys ())
92+ if (id < 0 || id >= keystore_num_pubkeys ())
9393 return -1 ;
9494 if (hal_flash_otp_read (FLASH_OTP_BASE +
9595 OTP_HDR_SIZE + id * SIZEOF_KEYSTORE_SLOT , otp_slot_item_cache ,
0 commit comments