Same proble as other proc scanning, need to terminate string
before calling strstr.
---
 agent/mibgroup/hardware/memory/memory_linux.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

--- a/agent/mibgroup/hardware/memory/memory_linux.c     2009-03-16 
16:44:16.512954764 -0700
+++ b/agent/mibgroup/hardware/memory/memory_linux.c     2009-03-17 
08:41:26.373292297 -0700
@@ -40,14 +40,14 @@ int netsnmp_mem_arch_load( netsnmp_cache
     }
     if (bsize == 0) {
         bsize = MEMINFO_INIT_SIZE;
-        buff = malloc(bsize);
+        buff = malloc(bsize+1);
         if (NULL == buff) {
             snmp_log(LOG_ERR, "malloc failed\n");
             return -1;
         }
     }
     while ((bytes_read = read(statfd, buff, bsize)) == bsize) {
-        b = realloc(buff, bsize + MEMINFO_STEP_SIZE);
+        b = realloc(buff, bsize + MEMINFO_STEP_SIZE + 1);
         if (NULL == b) {
             snmp_log(LOG_ERR, "malloc failed\n");
             return -1;
@@ -66,6 +66,7 @@ int netsnmp_mem_arch_load( netsnmp_cache
     if (bytes_read <= 0) {
         snmp_log_perror(MEMINFO_FILE);
     }
+    buff[bytes_read] = '\0';
 
     /*
      * ... parse this into a more useable form...

-- 


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to