Skip to contentSkip to conversation

libsepol: potential error_msg resource leak

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: potential error_msg resource leak

This patch addresses a potential bug found by Coverity:

I'm not sure whether this condition is possible or not, but judging by the logic it should be. The 'error_msg' is created by expand_terule_helper if 'conflict' is true, but an erorr is then only returned if both 'conflict' and 'cond' are non-NULL.

expand.c +9 -1
Index: src/expand.c
===================================================================
@@ -429,6 +429,7 @@ static int alias_copy_callback(hashtab_k
         new_alias = (type_datum_t *) malloc(sizeof(type_datum_t));
         if (!new_alias) {
                 write_error (state, "Out of memory!");
+		free(new_id);
                 return -ENOMEM;
         }
         memset(new_alias, 0, sizeof(type_datum_t));
@@ -1194,9 +1195,16 @@ static int cond_avrule_list_copy(policyd
 			}
 			return -1;
 		}
+
+		if (error_msg) {
+			write_error (state, "%s", error_msg);
+			free(error_msg);
+			error_msg = NULL;
+		}
+
 		cur = cur->next;
 	}
-	
+
 	return 0;
 }
 

--
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.