From nobody@FreeBSD.org  Thu May 10 10:42:48 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id F137D1065670
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 May 2012 10:42:48 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id DBC038FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 May 2012 10:42:48 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q4AAgmvL059303
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 May 2012 10:42:48 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q4AAgmEk059293;
	Thu, 10 May 2012 10:42:48 GMT
	(envelope-from nobody)
Message-Id: <201205101042.q4AAgmEk059293@red.freebsd.org>
Date: Thu, 10 May 2012 10:42:48 GMT
From: "Alexey V. Panfilov" <ports@subnets.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] net-mgmt/mrtg fix rateup's coredump
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         167771
>Category:       ports
>Synopsis:       [patch] net-mgmt/mrtg fix rateup's coredump
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    scheidell
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 10 10:50:10 UTC 2012
>Closed-Date:    Fri May 11 19:23:45 UTC 2012
>Last-Modified:  Fri May 11 19:23:45 UTC 2012
>Originator:     Alexey V. Panfilov
>Release:        8.3-STABLE amd64
>Organization:
Meganet-2003 LLC
>Environment:
FreeBSD wco-mur.atvnet.com.br 8.3-STABLE FreeBSD 8.3-STABLE #0: Sat Apr
28 03:28:18 BRT 2012
hmm@wco-mur.atvnet.com.br:/usr/obj/usr/src/sys/wco8  amd64
>Description:
Reported via private mail:

"problem appeared after 2.16.4,1 => 2.17.4,7, my log is flooded by
every run with:
kernel: pid 90528 (rateup), uid 0: exited on signal 11 (core dumped)

a tipical KMG setting is kMG[whatever]: ,M,G,

when I comment this line rateup conlcudes without error

funny is, the graph is still updated, so seems rateup dies after doing
it's job"
>How-To-Repeat:
Compose config with option kMG.
>Fix:
Apply diff (between 2.17.4 release and current):
http://oss.oetiker.ch/mrtg-trac/changeset?reponame=&new=402@trunk%2Fsrc%2Fsrc%2Frateup.c&old=397@trunk%2Fsrc%2Fsrc%2Frateup.c

Patch attached with submission follows:

--- src/rateup.c.orig	2012-05-10 05:40:49.259760823 -0300
+++ src/rateup.c	2012-05-10 05:44:32.297657818 -0300
@@ -1132,9 +1132,10 @@
   gdImageDestroy (brush_outp);
   free (lhist);
   free (graph_label);
-  if (kMG)
+  if (kMG) {
     free(short_si);
-
+    short_si = short_si_def;
+  }

 #ifdef WIN32
   /* got to remove the target under win32
@@ -1563,8 +1564,10 @@
 	}
       else
 	{
-	  strcpy (last.in, in);
-	  strcpy (last.out, out);
+	  strncpy (last.in, in, MAXL);
+	  last.in[MAXL-1]='\0';
+	  strncpy (last.out, out,MAXL);
+	  last.out[MAXL-1]='\0';
 	}
       fprintf (fo, "%lu " LLD " " LLD " " LLD " " LLD "\n",
 	       (unsigned long) now, inrate, outrate, inrate, outrate);
@@ -2114,6 +2117,7 @@
 	      history[x].in = rand () % atoi (argv[argi + 1]);
 	      history[x].out = rand () % atoi (argv[argi + 2]);
 	    }
+	   /* fallthrough */
 	case 'u':		/* Update file */
 	  if (argv[argi][1] == 'p')
 	    {


>Release-Note:
>Audit-Trail:

From: "Alexey V. Panfilov" <ports@subnets.ru>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-ports-bugs@FreeBSD.org
Cc:  
Subject: Re: ports/167771: [patch] net-mgmt/mrtg fix rateup's coredump
Date: Thu, 10 May 2012 14:57:22 +0400

 This is a multi-part message in MIME format.
 --------------090800080601000900090905
 Content-Type: text/plain; charset=KOI8-R; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Forgot add PORTREVISION to Makefile
 
 --
 Simple Lehisnoe ;-)
 
 --------------090800080601000900090905
 Content-Type: text/plain; charset=KOI8-R;
  name="mrtg_diff.txt"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="mrtg_diff.txt"
 
 diff -ruN mrtg.old/Makefile mrtg/Makefile
 --- mrtg/Makefile	2012-05-10 14:51:08.000000000 +0400
 +++ mrtg/Makefile	2012-05-10 14:48:26.000000000 +0400
 @@ -7,6 +7,7 @@
  
  PORTNAME=	mrtg
  PORTVERSION=	2.17.4
 +PORTREVISION=	1
  PORTEPOCH=	1
  CATEGORIES=	net-mgmt ipv6
  MASTER_SITES=	http://oss.oetiker.ch/mrtg/pub/ \
 diff -ruN mrtg.old/files/patch-aaa.txt mrtg/files/patch-aaa.txt
 --- mrtg/files/patch-aaa.txt	1970-01-01 03:00:00.000000000 +0300
 +++ mrtg/files/patch-aaa.txt	2012-05-10 14:34:05.000000000 +0400
 @@ -0,0 +1,36 @@
 +--- src/rateup.c.orig	2012-05-10 05:40:49.259760823 -0300
 ++++ src/rateup.c	2012-05-10 05:44:32.297657818 -0300
 +@@ -1132,9 +1132,10 @@
 +   gdImageDestroy (brush_outp);
 +   free (lhist);
 +   free (graph_label);
 +-  if (kMG)
 ++  if (kMG) {
 +     free(short_si);
 +-
 ++    short_si = short_si_def;
 ++  }
 +
 + #ifdef WIN32
 +   /* got to remove the target under win32
 +@@ -1563,8 +1564,10 @@
 + 	}
 +       else
 + 	{
 +-	  strcpy (last.in, in);
 +-	  strcpy (last.out, out);
 ++	  strncpy (last.in, in, MAXL);
 ++	  last.in[MAXL-1]='\0';
 ++	  strncpy (last.out, out,MAXL);
 ++	  last.out[MAXL-1]='\0';
 + 	}
 +       fprintf (fo, "%lu " LLD " " LLD " " LLD " " LLD "\n",
 + 	       (unsigned long) now, inrate, outrate, inrate, outrate);
 +@@ -2114,6 +2117,7 @@
 + 	      history[x].in = rand () % atoi (argv[argi + 1]);
 + 	      history[x].out = rand () % atoi (argv[argi + 2]);
 + 	    }
 ++	   /* fallthrough */
 + 	case 'u':		/* Update file */
 + 	  if (argv[argi][1] == 'p')
 + 	    {
 
 --------------090800080601000900090905--
Responsible-Changed-From-To: freebsd-ports-bugs->scheidell 
Responsible-Changed-By: scheidell 
Responsible-Changed-When: Fri May 11 19:09:17 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167771 
State-Changed-From-To: open->closed 
State-Changed-By: scheidell 
State-Changed-When: Fri May 11 19:23:43 UTC 2012 
State-Changed-Why:  
Committed, minor change: used standardized name for patch-src__rateup.c. 
Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167771 
>Unformatted:
