[MOAB-dev] r3076 - in MOAB/trunk: . mhdf/src parallel

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Jul 30 13:41:07 CDT 2009


Author: kraftche
Date: 2009-07-30 13:41:07 -0500 (Thu, 30 Jul 2009)
New Revision: 3076

Modified:
   MOAB/trunk/WriteHDF5.cpp
   MOAB/trunk/WriteHDF5.hpp
   MOAB/trunk/mhdf/src/file-desc.c
   MOAB/trunk/mhdf/src/tags.c
   MOAB/trunk/parallel/MBProcConfig.hpp
Log:
fix buffer overflow in WriteHDF5.cpp and fix misc warnings reported by icc

Modified: MOAB/trunk/WriteHDF5.cpp
===================================================================
--- MOAB/trunk/WriteHDF5.cpp	2009-07-30 17:22:08 UTC (rev 3075)
+++ MOAB/trunk/WriteHDF5.cpp	2009-07-30 18:41:07 UTC (rev 3076)
@@ -39,6 +39,7 @@
 #include <string.h>
 #include <limits>
 #include <cstdio>
+#include <iostream>
 #include <H5Tpublic.h>
 #include <H5Ppublic.h>
 #include "MBInterface.hpp"
@@ -2660,7 +2661,7 @@
   mhdf_TagDataType mhdf_type;
   int tag_size, elem_size, mhdf_size, storage;
   hid_t hdf_type = (hid_t)0;
-  hid_t handles[2];
+  hid_t handles[3];
   std::string tag_name;
   MBErrorCode rval;
   mhdf_Status status;
@@ -2783,6 +2784,10 @@
   return MB_SUCCESS;
 }
 
+void WriteHDF5::print_id_map( ) const
+{
+  print_id_map( std::cout, "" ) ;
+}
 
 void WriteHDF5::print_id_map( std::ostream& s, const char* pfx ) const
 {

Modified: MOAB/trunk/WriteHDF5.hpp
===================================================================
--- MOAB/trunk/WriteHDF5.hpp	2009-07-30 17:22:08 UTC (rev 3075)
+++ MOAB/trunk/WriteHDF5.hpp	2009-07-30 18:41:07 UTC (rev 3076)
@@ -261,6 +261,7 @@
   //! For parallel, may request collective IO.
   hid_t writeProp;
 
+  void print_id_map() const;
   void print_id_map( std::ostream& str, const char* prefix = "" ) const;
   
   

Modified: MOAB/trunk/mhdf/src/file-desc.c
===================================================================
--- MOAB/trunk/mhdf/src/file-desc.c	2009-07-30 17:22:08 UTC (rev 3075)
+++ MOAB/trunk/mhdf/src/file-desc.c	2009-07-30 18:41:07 UTC (rev 3076)
@@ -20,7 +20,7 @@
   
   memset( result, 0, sizeof(struct mhdf_FileDesc) );
   result->total_size = 4000;
-  result->offset = ((char*)result) + sizeof(struct mhdf_FileDesc);
+  result->offset = ((unsigned char*)result) + sizeof(struct mhdf_FileDesc);
   return result;
 }
 
@@ -362,6 +362,7 @@
   struct mhdf_FileDesc* result;
   hid_t table_id;
   int i, j, k, size, *indices, have;
+  unsigned int ui;
   void* ptr;
   char **elem_handles = 0, **tag_names = 0;
   unsigned char *array, *matrix;
@@ -428,13 +429,15 @@
   
     /* get element list */
   elem_handles = mhdf_getElemHandles( file_handle, 
-                                      &result->num_elem_desc, 
+                                      &ui, 
                                       status );
   if (elem_handles == NULL) {
     free( result );
     return NULL;
   }
+  result->num_elem_desc = ui;
   
+  
     /* allocate array of element descriptors */
   size = result->num_elem_desc * sizeof(struct mhdf_ElemDesc);
   ptr = realloc_data( &result, size, status );

Modified: MOAB/trunk/mhdf/src/tags.c
===================================================================
--- MOAB/trunk/mhdf/src/tags.c	2009-07-30 17:22:08 UTC (rev 3075)
+++ MOAB/trunk/mhdf/src/tags.c	2009-07-30 18:41:07 UTC (rev 3076)
@@ -1090,7 +1090,7 @@
                       int is_var_len, 
                       mhdf_Status* status )
 {
-  int rval;
+  int rval, ilen;
   unsigned index;
   hid_t read_type = type_id;
   hsize_t len;
@@ -1111,12 +1111,14 @@
   if (is_var_len) 
   {
     /* len = get_attrib_array_length_index(tag_id, index); */
-    len = get_attrib_array_length_name(tag_id, attrib_name);
-    if (len < 0) 
+    ilen = get_attrib_array_length_name(tag_id, attrib_name);
+    if (ilen < 0) 
     {
       mhdf_setFail( status, "Failed to read length of default/mesh value for tag" );
       return 0;
     }
+    len = ilen;
+    
       /* caller passes type_id == 0 for OPAQUE */
     if (0 == type_id)
       read_type = H5Tcreate( H5T_OPAQUE, len );

Modified: MOAB/trunk/parallel/MBProcConfig.hpp
===================================================================
--- MOAB/trunk/parallel/MBProcConfig.hpp	2009-07-30 17:22:08 UTC (rev 3075)
+++ MOAB/trunk/parallel/MBProcConfig.hpp	2009-07-30 18:41:07 UTC (rev 3076)
@@ -77,7 +77,7 @@
   crystal_data *crystal_router(bool construct_if_missing = true);
 
     //! get/set the communicator for this proc config
-  const MPI_Comm proc_comm() const {return procComm;}
+  MPI_Comm proc_comm() const {return procComm;}
   void proc_comm(MPI_Comm this_comm) {procComm = this_comm;}
 
     //! set rank/size; USED FOR TESTING ONLY!



More information about the moab-dev mailing list