All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/xsm/flask: Eliminate "array subscript above array bounds" warning
@ 2010-03-11 14:03 Stephen Smalley
  0 siblings, 0 replies; only message in thread
From: Stephen Smalley @ 2010-03-11 14:03 UTC (permalink / raw)
  To: Xen; +Cc: George S. Coker, II

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

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>

---

 xen/xsm/flask/ss/policydb.c |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

-- 
Stephen Smalley
National Security Agency

[-- Attachment #2: xen-policydb.diff --]
[-- Type: text/x-patch, Size: 1736 bytes --]

diff -r 132ac04cbdba xen/xsm/flask/ss/policydb.c
--- a/xen/xsm/flask/ss/policydb.c	Tue Mar 09 18:18:19 2010 +0000
+++ b/xen/xsm/flask/ss/policydb.c	Wed Mar 10 10:23:09 2010 -0500
@@ -1260,7 +1260,7 @@
 {
     char *key = NULL;
     struct role_datum *role;
-    int rc, to_read = 2;
+    int rc;
     __le32 buf[3];
     u32 len;
 
@@ -1273,9 +1273,10 @@
     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 @@
 {
     char *key = NULL;
     struct type_datum *typdatum;
-    int rc, to_read = 3;
+    int rc;
     __le32 buf[4];
     u32 len;
 
@@ -1343,9 +1344,10 @@
     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 @@
 {
     char *key = NULL;
     struct user_datum *usrdatum;
-    int rc, to_read = 2;
+    int rc;
     __le32 buf[3];
     u32 len;
 
@@ -1436,9 +1438,10 @@
     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;
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-03-11 14:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-11 14:03 [PATCH] xen/xsm/flask: Eliminate "array subscript above array bounds" warning Stephen Smalley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.