Date: Tue, 7 Jan 2014 23:01:05 +0000 (UTC) From: John-Mark Gurney <jmg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r260418 - head/lib/libnetgraph Message-ID: <201401072301.s07N15iS040228@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401072301.s07N15iS040228>