aboutsummaryrefslogtreecommitdiffstats
path: root/xen/xsm
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-03-11 17:15:27 +0000
committerKeir Fraser <keir.fraser@citrix.com>2010-03-11 17:15:27 +0000
commit01046a5b39339d278e6d8b55ee32d462d63092da (patch)
tree7c5a697421843e588bb9a476f1df6e6c616615a7 /xen/xsm
parent1803dc9556de65b65c870d6bbdd1acce9c1d8fe3 (diff)
downloadxen-01046a5b39339d278e6d8b55ee32d462d63092da.tar.gz
xen-01046a5b39339d278e6d8b55ee32d462d63092da.tar.bz2
xen-01046a5b39339d278e6d8b55ee32d462d63092da.zip
xsm/flask: Eliminate "array subscript above array bounds" warning
gcc 4.4 incorrectly reports an "array subscript above array bounds" warning in the flask policydb code, causing the build to fail with FLASK_ENABLE=y. Rework the code slightly to make it go away. Signed-off-by: Stephen D. Smalley <sds@tycho.nsa.gov>
Diffstat (limited to 'xen/xsm')
-rw-r--r--xen/xsm/flask/ss/policydb.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/xen/xsm/flask/ss/policydb.c b/xen/xsm/flask/ss/policydb.c
index 357227a34a..26097b967a 100644
--- a/xen/xsm/flask/ss/policydb.c
+++ b/xen/xsm/flask/ss/policydb.c
@@ -1260,7 +1260,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
{
char *key = NULL;
struct role_datum *role;
- int rc, to_read = 2;
+ int rc;
__le32 buf[3];
u32 len;
@@ -1273,9 +1273,10 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
memset(role, 0, sizeof(*role));
if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
- to_read = 3;
+ rc = next_entry(buf, fp, sizeof(buf[0]) * 3);
+ else
+ rc = next_entry(buf, fp, sizeof(buf[0]) * 2);
- rc = next_entry(buf, fp, sizeof(buf[0]) * to_read);
if ( rc < 0 )
goto bad;
@@ -1330,7 +1331,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
{
char *key = NULL;
struct type_datum *typdatum;
- int rc, to_read = 3;
+ int rc;
__le32 buf[4];
u32 len;
@@ -1343,9 +1344,10 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
memset(typdatum, 0, sizeof(*typdatum));
if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
- to_read = 4;
+ rc = next_entry(buf, fp, sizeof(buf[0]) * 4);
+ else
+ rc = next_entry(buf, fp, sizeof(buf[0]) * 3);
- rc = next_entry(buf, fp, sizeof(buf[0]) * to_read);
if ( rc < 0 )
goto bad;
@@ -1423,7 +1425,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
{
char *key = NULL;
struct user_datum *usrdatum;
- int rc, to_read = 2;
+ int rc;
__le32 buf[3];
u32 len;
@@ -1436,9 +1438,10 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
memset(usrdatum, 0, sizeof(*usrdatum));
if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
- to_read = 3;
+ rc = next_entry(buf, fp, sizeof(buf[0]) * 3);
+ else
+ rc = next_entry(buf, fp, sizeof(buf[0]) * 2);
- rc = next_entry(buf, fp, sizeof(buf[0]) * to_read);
if ( rc < 0 )
goto bad;