libsemanage: fix OOB cleanup in semanage_direct_list()
Stephen Smalley
maintainerPATCH 1/1 libsemanage: fix OOB cleanup in semanage_direct_list()
On the error path semanage_direct_list() indexes modinfo rather than (*modinfo), thereby reading and writing the wrong pointers.
Signed-off-by Stephen Smalley <[email protected]>
--- libsemanage/src/direct_api.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
libsemanage/src/direct_api.c +3 -4
@@ -2006,12 +2006,11 @@ static int semanage_direct_list(semanage_handle_t *sh, cleanup:if (retval <0 ) { -for (i =0 ; i < *num_modules; i++) { -semanage_module_info_destroy (sh, &(*modinfo[i])); - modinfo[i] =NULL ; - } +for (i =0 ; i < *num_modules; i++) +semanage_module_info_destroy (sh, &(*modinfo)[i]);free (*modinfo); *modinfo =NULL ; + *num_modules =0 ; }if (!sh->is_in_transaction) {
Signature · 1 line
2.54.0
Quoted 5 lines · Stephen Smalley
On the error path
semanage_direct_list()indexes modinfo rather than (*modinfo), thereby reading and writing the wrong pointers.Signed-off-by Stephen Smalley <[email protected]>
Acked-by James Carter <[email protected]>
Quoted 27 lines
--- libsemanage/src/direct_api.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)libsemanage/src/direct_api.c +3
-5@@ -2006,12 +2006,11 @@ static int semanage_direct_list(semanage_handle_t *sh, cleanup:if (retval <0 ) { -for (i =0 ; i < *num_modules; i++) { -semanage_module_info_destroy (sh, &(*modinfo[i])); - modinfo[i] =NULL ; - } +for (i =0 ; i < *num_modules; i++) +semanage_module_info_destroy (sh, &(*modinfo)[i]);free (*modinfo); *modinfo =NULL ; + *num_modules =0 ; }if (!sh->is_in_transaction) { --2.54.0
Stephen Smalley
maintainerQuoted 10 lines · James Carter
Quoted 5 lines · Stephen Smalley
On the error path
semanage_direct_list()indexes modinfo rather than (*modinfo), thereby reading and writing the wrong pointers.Signed-off-by Stephen Smalley <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Quoted 28 lines
Quoted 28 lines
--- libsemanage/src/direct_api.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)libsemanage/src/direct_api.c +3
-5@@ -2006,12 +2006,11 @@ static int semanage_direct_list(semanage_handle_t *sh, cleanup:if (retval <0 ) { -for (i =0 ; i < *num_modules; i++) { -semanage_module_info_destroy (sh, &(*modinfo[i])); - modinfo[i] =NULL ; - } +for (i =0 ; i < *num_modules; i++) +semanage_module_info_destroy (sh, &(*modinfo)[i]);free (*modinfo); *modinfo =NULL ; + *num_modules =0 ; }if (!sh->is_in_transaction) { --2.54.0