[openib-general] [PATCH] osm: trivial memory allocation bug in parsing opensm.opts

Eitan Zahavi eitan at mellanox.co.il
Thu Mar 9 01:47:32 PST 2006


Hi Hal

I just run into a memory violation reported by glibc.
I was able to trace it into the options cache parser.
Allocation missed the null char ... 

Eitan

Signed-off-by:  Eitan Zahavi <eitan at mellanox.co.il>

Index: opensm/osm_subnet.c
===================================================================
--- opensm/osm_subnet.c	(revision 5628)
+++ opensm/osm_subnet.c	(working copy)
@@ -596,7 +596,7 @@ __osm_subn_opts_unpack_charp(
               p_key, p_val_str);
       printf(buff);
       cl_log_event("OpenSM", LOG_INFO, buff, NULL, 0);
-      *p_val = (char *)cl_malloc(strlen(p_val_str));
+      *p_val = (char *)cl_malloc( strlen(p_val_str) +1 );
       strcpy( *p_val, p_val_str);
     }
   }




More information about the general mailing list