[rtems commit] sapi: Add param check to rtems_extension_create()
Sebastian Huber
sebh at rtems.org
Fri Apr 17 17:51:24 UTC 2020
Module: rtems
Branch: master
Commit: 3d73642d9e341a4c65fb86a15d696686e7f28d6d
Changeset: http://git.rtems.org/rtems/commit/?id=3d73642d9e341a4c65fb86a15d696686e7f28d6d
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Apr 17 10:00:15 2020 +0200
sapi: Add param check to rtems_extension_create()
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 59f41d2..5751f47 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 b44b5b9..083fd21 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(
More information about the vc
mailing list