Skip to contentSkip to conversation

don't risk returning freed data in get_failsafe_context

PATCH New [email protected] 1 participant 1 message Aug 10, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 don't risk returning freed data in get_failsafe_context

This patch fixes a bug found in get_context_list.c by Coverity:

If get_failsafe_context() fails, 'reachable' is freed, then we goto out:, where we set *list=reachable. I suspect reachable should first be set to NULL. Though the rc<0 may keep users from trying to use *list (quick audit of libselinux/{src,utils} suggests that's the case), this still seems prudent.

get_context_list.c +1 -0
Index: src/get_context_list.c
===================================================================
@@ -410,6 +410,7 @@ failsafe:
     rc = get_failsafe_context(user, &reachable[0]);
     if (rc < 0) {
 	    freeconary(reachable);
+	    reachable = NULL;
 	    goto out;
     }
     rc = 1; /* one context in the list */

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.