* amd/map.c (get_next_exported_ap): Avoid running off the end of
authorErez Zadok <ezk@cs.sunysb.edu>
Thu, 30 Jun 2005 14:58:22 +0000 (14:58 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Thu, 30 Jun 2005 14:58:22 +0000 (14:58 +0000)
the exported_ap[] array.  Patch from jon+amd-at-spock.org.  Fixed
bug #301.

AUTHORS
ChangeLog
amd/map.c

diff --git a/AUTHORS b/AUTHORS
index 9829b54c2bcc7290e4ef5ab49df12a98fb4b8ae1..f0f6f690d80d0d8e34bcd358a2662f19326a8bd6 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -395,6 +395,7 @@ AIX.
 * Jonathan Chen <jon+amd@spock.org>
 October 22, 2004: patch/fix to move mlock/mlockall/plock code after the
 fork().
+June 29, 2005: core dump going off end of exported_ap[] array.
 
 * David Rage <rage@ucl.ac.uk>
 January 17, 2005: prevent Amd from logging 'Read-only filesystem' errors
index a1eda8bff84260c125863429d2938fde9f2b8f69..6b8d4ad9306a624769f8019200ada8392a9a3048 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-06-30  Erez Zadok  <ezk@cs.sunysb.edu>
+
+       * amd/map.c (get_next_exported_ap): Avoid running off the end of
+       the exported_ap[] array.  Patch from jon+amd-at-spock.org.  Fixed
+       bug #301.
+
 2005-06-25  Erez Zadok  <ezk@cs.sunysb.edu>
 
        * Makefile.am (EXTRA_DIST_CONF): distribute new mtab_linux.c.
index 59c4e5c0160a1b7a18e4cf8389e121c2f4db2546..ad7fb1e16bc4f3b4a550202cb13d74a32da8a0fe 100644 (file)
--- a/amd/map.c
+++ b/amd/map.c
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: map.c,v 1.53 2005/03/18 01:11:33 ezk Exp $
+ * $Id: map.c,v 1.54 2005/06/30 14:58:22 ezk Exp $
  *
  */
 
@@ -122,12 +122,12 @@ am_node *
 get_next_exported_ap(int *index)
 {
   (*index)++;
-  while (exported_ap[*index] == NULL) {
-    if (*index >= exported_ap_size)
-      return NULL;
+  while (*index < exported_ap_size) {
+    if (exported_ap[*index] != NULL)
+      return exported_ap[*index];
     (*index)++;
   }
-  return exported_ap[*index];
+  return NULL;
 }