[PATCH] sapi: Add param check to rtems_extension_create()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Apr 17 08:11:24 UTC 2020
Check that the extensions table is not NULL. Change format.
Update #3953.
---
cpukit/sapi/src/extensioncreate.c | 14 ++++++++++----
testsuites/sptests/sp07/init.c | 5 +++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/cpukit/sapi/src/extensioncreate.c b/cpukit/sapi/src/extensioncreate.c
index 59f41d2ec2..5751f47bef 100644
--- a/cpukit/sapi/src/extensioncreate.c
+++ b/cpukit/sapi/src/extensioncreate.c
@@ -32,15 +32,21 @@ rtems_status_code rtems_extension_create(
{
Extension_Control *the_extension;
- if ( !id )
+ if ( !rtems_is_name_valid( name ) ) {
+ return RTEMS_INVALID_NAME;
+ }
+
+ if ( extension_table == NULL ) {
return RTEMS_INVALID_ADDRESS;
+ }
- if ( !rtems_is_name_valid( name ) )
- return RTEMS_INVALID_NAME;
+ if ( id == NULL ) {
+ return RTEMS_INVALID_ADDRESS;
+ }
the_extension = _Extension_Allocate();
- if ( !the_extension ) {
+ if ( the_extension == NULL ) {
_Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
diff --git a/testsuites/sptests/sp07/init.c b/testsuites/sptests/sp07/init.c
index b44b5b967e..083fd21317 100644
--- a/testsuites/sptests/sp07/init.c
+++ b/testsuites/sptests/sp07/init.c
@@ -73,6 +73,11 @@ rtems_task Init(
Extension_name[ 1 ] = rtems_build_name( 'E', 'X', 'T', '1' );
Extension_name[ 2 ] = rtems_build_name( 'E', 'X', 'T', '2' );
+ puts ( "rtems_extension_create - bad table -- RTEMS_INVALID_ADDRESS" );
+ status = rtems_extension_create( 0xa5a5a5a5, NULL, &id );
+ fatal_directive_status(
+ status, RTEMS_INVALID_ADDRESS, "rtems_extension_create" );
+
puts ( "rtems_extension_create - bad id pointer -- RTEMS_INVALID_ADDRESS" );
status = rtems_extension_create( 0xa5a5a5a5, &Extensions, NULL );
fatal_directive_status(
--
2.16.4
More information about the devel
mailing list