Skip to contentSkip to conversation

check ebitmap_write return value in policydb_write

PATCH In review [email protected] 2 participants 2 messages Aug 12, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 check ebitmap_write return value in policydb_write

The following patch fixes a bug found by Coverity in libsepol:

In policydb_write, the return value of ebitmap_write() is not checked.

write.c +4 -2
Index: src/write.c
===================================================================
@@ -1514,8 +1514,10 @@ int policydb_write(policydb_t * p, struc
         }
 
 	if (policy_type == POLICY_KERN && policyvers >= POLICYDB_VERSION_AVTAB) {
-		for (i = 0; i < p->p_types.nprim; i++)
-			ebitmap_write(&p->type_attr_map[i], fp);
+		for (i = 0; i < p->p_types.nprim; i++) {
+			if (ebitmap_write(&p->type_attr_map[i], fp) == -1)
+				return -1;
+		}
 	}
 
 	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.

#1 lore raw
Quoted 4 lines · On Fri, 2005-08-12 at 14:28 -0500, [email protected] wrote:

The following patch fixes a bug found by Coverity in libsepol:

In policydb_write, the return value of ebitmap_write() is not checked.

Thanks, merged this one, and a corrected fix for the prior one. Also fixed policydb_destroy to correctly handle the case where type_attr_map/attr_type_map are NULL.

Signature · 8 lines
Stephen Smalley
National Security Agency


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