[opennms-devel] [PATCH] Fix bounds on mib2opennms

Alex Bennee <[email protected]>
Newsgroups gmane.network.opennms.bugs
Message-ID <1211380263.15818.15.camel__39156.3630466864$1211380812$gmane$org@danny.nin>
mib2opennms uses strcat (which adds an additional byte each time) to
build paths but only allocates strlen bytes which doesn't take the null
byte into account.

Index: mib2opennms.c
===================================================================
--- mib2opennms.c	(revision 9194)
+++ mib2opennms.c	(working copy)
@@ -238,7 +238,7 @@
     
 	smiInit(NULL);
 
-	pathlen = strlen(STANDARD_PATH) + (mibpath == NULL ? 0 : strlen(mibpath)+1 /* for the colon */);
+	pathlen = 1 + strlen(STANDARD_PATH) + (mibpath == NULL ? 0 : strlen(mibpath)+1 /* for the colon */);
 
 	newpath = (char *) malloc( pathlen * sizeof(char) );
 	newpath[0] = '\0';

Found with valgrind. The tool still seems horribly broken on 64 bit
systems but I think that may be 32/64bit breakage inside libsmi as
mib2opennms seems to use the correct types.

-- 
Alex Bennee
Software Engineer, Cambridge Broadband


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-devel mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.