[hobbit] hobbitd_larrd is crashing

Henrik Stoerner henrik at hswn.dk
Fri Jun 9 23:52:05 CEST 2006


On Fri, Jun 09, 2006 at 11:40:48PM +0200, Henrik Stoerner wrote:
> My guess is that this filename is just too long. It *could* overflow the
> buffer set aside for the RRD filename - in that case, the attached patch 
> against 4.1.2p1 should help.

Correction, there is one more place that is sensitive to the filename
length. Please use this corrected patch instead of the one I sent
earlier.


Regards,
Henrik

-------------- next part --------------
--- hobbitd/do_rrd.c.orig	2005-08-02 14:59:18.000000000 +0200
+++ hobbitd/do_rrd.c	2006-06-09 23:38:05.307993923 +0200
@@ -118,7 +118,8 @@
 			return -1;
 		}
 	}
-	strcat(filedir, "/"); strcat(filedir, fn);
+	snprintf(filedir, sizeof(filedir)-1, "%s/%s/%s", rrddir, hostname, fn);
+	filedir[sizeof(filedir)-1] = '\0';
 	creparams[1] = filedir;	/* Icky */
 
 	if (stat(filedir, &st) == -1) {
--- hobbitd/rrd/do_net.c.orig	2005-09-28 23:20:56.000000000 +0200
+++ hobbitd/rrd/do_net.c	2006-06-09 23:50:40.404367975 +0200
@@ -43,7 +43,8 @@
 
 				if (strncmp(urlfn, "http://", 7) == 0) urlfn += 7;
 				p = urlfn; while ((p = strchr(p, '/')) != NULL) *p = ',';
-				sprintf(rrdfn, "tcp.http.%s.rrd", urlfn);
+				snprintf(rrdfn, sizeof(rrdfn)-1, "tcp.http.%s.rrd", urlfn);
+				rrdfn[sizeof(rrdfn)-1] = '\0';
 				sprintf(rrdvalues, "%d:%.2f", (int)tstamp, seconds);
 				create_and_update_rrd(hostname, rrdfn, bbnet_params, bbnet_tpl);
 				xfree(url); url = NULL;


More information about the Xymon mailing list