Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Mar 2017 18:01:01 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315206 - head/contrib/bsnmp/snmpd
Message-ID:  <201703131801.v2DI11ue072031@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Mon Mar 13 18:01:01 2017
New Revision: 315206
URL: https://svnweb.freebsd.org/changeset/base/315206

Log:
  bsnmpd: fix segfault when trans_insert_port(..) is called with multiple
  out of order addresses
  
  Move `port->transport` initialization before the TAILQ_FOREACH(..) loop
  to ensure that the value is properly initialized before it's inserted
  into the TAILQ.
  
  MFC after:	1 week
  PR:		217760
  Submitted by:	eugen
  Sponsored by:	Dell EMC Isilon

Modified:
  head/contrib/bsnmp/snmpd/main.c

Modified: head/contrib/bsnmp/snmpd/main.c
==============================================================================
--- head/contrib/bsnmp/snmpd/main.c	Mon Mar 13 17:58:08 2017	(r315205)
+++ head/contrib/bsnmp/snmpd/main.c	Mon Mar 13 18:01:01 2017	(r315206)
@@ -765,13 +765,13 @@ trans_insert_port(struct transport *t, s
 {
 	struct tport *p;
 
+	port->transport = t;
 	TAILQ_FOREACH(p, &t->table, link) {
 		if (asn_compare_oid(&p->index, &port->index) > 0) {
 			TAILQ_INSERT_BEFORE(p, port, link);
 			return;
 		}
 	}
-	port->transport = t;
 	TAILQ_INSERT_TAIL(&t->table, port, link);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703131801.v2DI11ue072031>