From a7dd3bff82e650cfa70732369772d0852d9bb01e Mon Sep 17 00:00:00 2001 From: Mathieu Faverge <mathieu.faverge@inria.fr> Date: Thu, 6 Jul 2023 14:36:50 +0200 Subject: [PATCH] descriptors: Protect dist_m, dist_n against negative values --- control/descriptor_helpers.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/control/descriptor_helpers.c b/control/descriptor_helpers.c index f11e487d3..87846e3a5 100644 --- a/control/descriptor_helpers.c +++ b/control/descriptor_helpers.c @@ -139,6 +139,15 @@ int chameleon_getrankof_custom_init( custom_dist_t **custom_dist, return CHAMELEON_ERR_ILLEGAL_VALUE; } + if ( (dist_m <= 0 ) || (dist_n <= 0) ) { + char message[300]; + snprintf( message, 300, "Incorrect values for dist_m(%d) and/or dist_n(%d)", dist_m, dist_n ); + chameleon_error( "chameleon_getrankof_custom_init", message ); + free( result ); + fclose( f ); + return CHAMELEON_ERR_ILLEGAL_VALUE; + } + result->dist_m = dist_m; result->dist_n = dist_n; -- GitLab