From owner-svn-src-all@FreeBSD.ORG Tue Jan 7 23:01:05 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EDDFC82D; Tue, 7 Jan 2014 23:01:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C718817FB; Tue, 7 Jan 2014 23:01:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s07N157q040229; Tue, 7 Jan 2014 23:01:05 GMT (envelope-from jmg@svn.freebsd.org) Received: (from jmg@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s07N15iS040228; Tue, 7 Jan 2014 23:01:05 GMT (envelope-from jmg@svn.freebsd.org) Message-Id: <201401072301.s07N15iS040228@svn.freebsd.org> From: John-Mark Gurney Date: Tue, 7 Jan 2014 23:01:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r260418 - head/lib/libnetgraph X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2014 23:01:06 -0000 Author: jmg Date: Tue Jan 7 23:01:05 2014 New Revision: 260418 URL: http://svnweb.freebsd.org/changeset/base/260418 Log: make sure that rbuf is aligned by making a union w/ the structure we need to access... access the struct through the union too... PR: 185165 Submitted by: Guy Yur MFC after: 1 week Modified: head/lib/libnetgraph/sock.c Modified: head/lib/libnetgraph/sock.c ============================================================================== --- head/lib/libnetgraph/sock.c Tue Jan 7 23:00:58 2014 (r260417) +++ head/lib/libnetgraph/sock.c Tue Jan 7 23:01:05 2014 (r260418) @@ -111,9 +111,12 @@ gotNode: /* Save node name */ strlcpy(namebuf, name, sizeof(namebuf)); } else if (dsp != NULL) { - u_char rbuf[sizeof(struct ng_mesg) + sizeof(struct nodeinfo)]; - struct ng_mesg *const resp = (struct ng_mesg *) rbuf; - struct nodeinfo *const ni = (struct nodeinfo *) resp->data; + union { + u_char rbuf[sizeof(struct ng_mesg) + + sizeof(struct nodeinfo)]; + struct ng_mesg res; + } res; + struct nodeinfo *const ni = (struct nodeinfo *) res.res.data; /* Find out the node ID */ if (NgSendMsg(cs, ".", NGM_GENERIC_COOKIE, @@ -123,7 +126,7 @@ gotNode: NGLOG("send nodeinfo"); goto errout; } - if (NgRecvMsg(cs, resp, sizeof(rbuf), NULL) < 0) { + if (NgRecvMsg(cs, &res.res, sizeof(res.rbuf), NULL) < 0) { errnosv = errno; if (_gNgDebugLevel >= 1) NGLOG("recv nodeinfo");