Skip to contentSkip to conversation

ecc: fix potential buffer overrun

PATCH Applied James Prestwood 2 participants 2 messages Feb 7, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ecc: fix potential buffer overrun

l_ecc_curve_get_[tls|ike]_group were iterating over curves and assuming a NULL terminated list which was not the case. This never got caught because IWD played nice and only got groups it already new existed.

This was changed to iterate over L_ARRAY_SIZE(curves).

---
 ell/ecc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
ell/ecc.c +4 -4
index eeb12dd..88c8373 100644
@@ -134,9 +134,9 @@ LIB_EXPORT size_t l_ecc_curve_get_scalar_bytes(const struct l_ecc_curve *curve)
 LIB_EXPORT const struct l_ecc_curve *l_ecc_curve_get_ike_group(
 							unsigned int group)
 {
-	int i;
+	unsigned int i;
 
-	for (i = 0; curves[i]; i++) {
+	for (i = 0; i < L_ARRAY_SIZE(curves); i++) {
 		if (curves[i]->ike_group == group)
 			return curves[i];
 	}
@@ -147,9 +147,9 @@ LIB_EXPORT const struct l_ecc_curve *l_ecc_curve_get_ike_group(
 LIB_EXPORT const struct l_ecc_curve *l_ecc_curve_get_tls_group(
 							unsigned int group)
 {
-	int i;
+	unsigned int i;
 
-	for (i = 0; curves[i]; i++) {
+	for (i = 0; i < L_ARRAY_SIZE(curves); i++) {
 		if (curves[i]->tls_group == group)
 			return curves[i];
 	}
Signature · 1 line
2.17.1
#1 lore raw

Hi James,

Quoted 9 lines · James Prestwood

l_ecc_curve_get_[tls|ike]_group were iterating over curves and assuming a NULL terminated list which was not the case. This never got caught because IWD played nice and only got groups it already new existed.

This was changed to iterate over L_ARRAY_SIZE(curves).

---
  ell/ecc.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks.

Regards,
-Denis