openssl: Use dynamically allocated array to determine EC curves
This avoids the use of a variable length array, which should probably be avoided in general due to potential performance, portability and security issues (not in this particular case, though). Closes strongswan/strongswan#1095
This commit is contained in:
@@ -345,13 +345,15 @@ static bool ecdh_group_supported(EC_builtin_curve *curves, size_t num_curves,
|
||||
static void add_ecdh_features(plugin_feature_t *features,
|
||||
plugin_feature_t *to_add, int count, int *pos)
|
||||
{
|
||||
EC_builtin_curve *curves;
|
||||
size_t num_curves;
|
||||
int i;
|
||||
|
||||
num_curves = EC_get_builtin_curves(NULL, 0);
|
||||
|
||||
EC_builtin_curve curves[num_curves];
|
||||
|
||||
if (num_curves)
|
||||
{
|
||||
curves = calloc(num_curves, sizeof(EC_builtin_curve));
|
||||
num_curves = EC_get_builtin_curves(curves, num_curves);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
@@ -362,6 +364,8 @@ static void add_ecdh_features(plugin_feature_t *features,
|
||||
features[(*pos)++] = to_add[i];
|
||||
}
|
||||
}
|
||||
free(curves);
|
||||
}
|
||||
}
|
||||
#endif /* OPENSSL_NO_ECDH */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user