X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=security%2Fselinux%2Fss%2Febitmap.c;h=ad34294aa368a68448cdc84856d8435ed5330956;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=0912af410c87092c03300040935a9cb993eb0b2f;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c index 0912af410..ad34294aa 100644 --- a/security/selinux/ss/ebitmap.c +++ b/security/selinux/ss/ebitmap.c @@ -237,15 +237,15 @@ void ebitmap_destroy(struct ebitmap *e) int ebitmap_read(struct ebitmap *e, void *fp) { - int rc = -EINVAL; + int rc; struct ebitmap_node *n, *l; - u32 *buf, mapsize, count, i; + u32 buf[3], mapsize, count, i; u64 map; ebitmap_init(e); - buf = next_entry(fp, sizeof(u32)*3); - if (!buf) + rc = next_entry(buf, fp, sizeof buf); + if (rc < 0) goto out; mapsize = le32_to_cpu(buf[0]); @@ -256,7 +256,7 @@ int ebitmap_read(struct ebitmap *e, void *fp) printk(KERN_ERR "security: ebitmap: map size %u does not " "match my size %Zd (high bit was %d)\n", mapsize, MAPSIZE, e->highbit); - goto out; + goto bad; } if (!e->highbit) { e->node = NULL; @@ -269,8 +269,8 @@ int ebitmap_read(struct ebitmap *e, void *fp) } l = NULL; for (i = 0; i < count; i++) { - buf = next_entry(fp, sizeof(u32)); - if (!buf) { + rc = next_entry(buf, fp, sizeof(u32)); + if (rc < 0) { printk(KERN_ERR "security: ebitmap: truncated map\n"); goto bad; } @@ -296,12 +296,11 @@ int ebitmap_read(struct ebitmap *e, void *fp) n->startbit, (e->highbit - MAPSIZE)); goto bad_free; } - buf = next_entry(fp, sizeof(u64)); - if (!buf) { + rc = next_entry(&map, fp, sizeof(u64)); + if (rc < 0) { printk(KERN_ERR "security: ebitmap: truncated map\n"); goto bad_free; } - memcpy(&map, buf, sizeof(u64)); n->map = le64_to_cpu(map); if (!n->map) { @@ -330,6 +329,8 @@ out: bad_free: kfree(n); bad: + if (!rc) + rc = -EINVAL; ebitmap_destroy(e); goto out; }