[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] tools/blktap2: fix out of bounds access in block-log.c


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Mon, 14 May 2012 16:32:18 +0000
  • Delivery-date: Mon, 14 May 2012 16:32:23 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1336645204 -3600
# Node ID 83a02f225bde5ca7c51a483381cfc4ce5eae9800
# Parent  ca02580986d2e78a6ccb90dae66f7cbd1ad8058c
tools/blktap2: fix out of bounds access in block-log.c

block-log.c: In function 'ctl_close_sock':
block-log.c:363:23: warning: array subscript is above array bounds
[-Warray-bounds]

Adjust loop condition in ctl_close_sock() to fix warning.
Adjust array acccess in ctl_close() to actually access the array
member.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r ca02580986d2 -r 83a02f225bde tools/blktap2/drivers/block-log.c
--- a/tools/blktap2/drivers/block-log.c Thu May 10 11:19:05 2012 +0100
+++ b/tools/blktap2/drivers/block-log.c Thu May 10 11:20:04 2012 +0100
@@ -324,11 +324,11 @@ static int ctl_open(struct tdlog_state* 
 static int ctl_close(struct tdlog_state* s)
 {
   while (s->connected) {
+    s->connected--;
     tapdisk_server_unregister_event(s->connections[s->connected].id);
     close(s->connections[s->connected].fd);
     s->connections[s->connected].fd = -1;
     s->connections[s->connected].id = 0;
-    s->connected--;
   }
 
   if (s->ctl.fd >= 0) {
@@ -359,7 +359,7 @@ static int ctl_close_sock(struct tdlog_s
 {
   int i;
 
-  for (i = 0; i <= s->connected; i++) {
+  for (i = 0; i < s->connected; i++) {
     if (s->connections[i].fd == fd) {
       tapdisk_server_unregister_event(s->connections[i].id);
       close(s->connections[i].fd);

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.