WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xsm/flask: Eliminate "array subscript abo

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xsm/flask: Eliminate "array subscript above array bounds" warning
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 11 Mar 2010 09:45:11 -0800
Delivery-date: Thu, 11 Mar 2010 09:45:10 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1268327727 0
# Node ID 099aac2cfab614c62e3bba9eb30aee7dc950d8fd
# Parent  5b8e012641e21b3f62350b707fe1e52557f17829
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@xxxxxxxxxxxxx>
---
 xen/xsm/flask/ss/policydb.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff -r 5b8e012641e2 -r 099aac2cfab6 xen/xsm/flask/ss/policydb.c
--- a/xen/xsm/flask/ss/policydb.c       Thu Mar 11 08:09:58 2010 +0000
+++ b/xen/xsm/flask/ss/policydb.c       Thu Mar 11 17:15:27 2010 +0000
@@ -1260,7 +1260,7 @@ static int role_read(struct policydb *p,
 {
     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,
     memset(role, 0, sizeof(*role));
 
     if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
-        to_read = 3;
-
-    rc = next_entry(buf, fp, sizeof(buf[0]) * to_read);
+        rc = next_entry(buf, fp, sizeof(buf[0]) * 3);
+    else
+        rc = next_entry(buf, fp, sizeof(buf[0]) * 2);
+
     if ( rc < 0 )
         goto bad;
 
@@ -1330,7 +1331,7 @@ static int type_read(struct policydb *p,
 {
     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,
     memset(typdatum, 0, sizeof(*typdatum));
 
     if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
-        to_read = 4;
-
-    rc = next_entry(buf, fp, sizeof(buf[0]) * to_read);
+        rc = next_entry(buf, fp, sizeof(buf[0]) * 4);
+    else
+        rc = next_entry(buf, fp, sizeof(buf[0]) * 3);
+
     if ( rc < 0 )
         goto bad;
 
@@ -1423,7 +1425,7 @@ static int user_read(struct policydb *p,
 {
     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,
     memset(usrdatum, 0, sizeof(*usrdatum));
 
     if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
-        to_read = 3;
-
-    rc = next_entry(buf, fp, sizeof(buf[0]) * to_read);
+        rc = next_entry(buf, fp, sizeof(buf[0]) * 3);
+    else
+        rc = next_entry(buf, fp, sizeof(buf[0]) * 2);
+
     if ( rc < 0 )
         goto bad;
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xsm/flask: Eliminate "array subscript above array bounds" warning, Xen patchbot-unstable <=