Date: Fri, 15 Feb 2013 01:25:28 +0000 (UTC) From: Lawrence Stewart <lstewart@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r246815 - projects/diffused_head/sbin/ipfw/diffuse_exporter Message-ID: <201302150125.r1F1PSds039848@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: lstewart Date: Fri Feb 15 01:25:27 2013 New Revision: 246815 URL: http://svnweb.freebsd.org/changeset/base/246815 Log: Mitigate against possible unaligned access when serialising data into a buffer. Reported by: clang Modified: projects/diffused_head/sbin/ipfw/diffuse_exporter/diffuse_exporter.c Modified: projects/diffused_head/sbin/ipfw/diffuse_exporter/diffuse_exporter.c ============================================================================== --- projects/diffused_head/sbin/ipfw/diffuse_exporter/diffuse_exporter.c Fri Feb 15 01:24:05 2013 (r246814) +++ projects/diffused_head/sbin/ipfw/diffuse_exporter/diffuse_exporter.c Fri Feb 15 01:25:27 2013 (r246815) @@ -43,6 +43,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/endian.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/tree.h> @@ -628,19 +629,17 @@ handle_anode_state_request(struct action /* Add the IE data for the default flowrule template. */ for (i = 0; i < N_DEFAULT_FLOWRULE_TEMPLATE_ITEMS; i++) { - *((uint16_t *)(dstbuf + offs)) = - htons(dip_info[def_flowrule_template[i]].id); + be16enc(dstbuf + offs, + dip_info[def_flowrule_template[i]].id); offs += sizeof(uint16_t); if (def_flowrule_template[i] == DIP_IE_ACTION || def_flowrule_template[i] == DIP_IE_EXPORT_NAME || def_flowrule_template[i] == DIP_IE_CLASSIFIER_NAME) { - *((uint16_t *)(dstbuf + offs)) = - htons((uint16_t)DI_MAX_NAME_STR_LEN); + be16enc(dstbuf + offs, DI_MAX_NAME_STR_LEN); offs += sizeof(uint16_t); } else if (def_flowrule_template[i] == DIP_IE_ACTION_PARAMS) { - *((uint16_t *)(dstbuf + offs)) = - htons((uint16_t)DI_MAX_PARAM_STR_LEN); + be16enc(dstbuf + offs, DI_MAX_PARAM_STR_LEN); offs += sizeof(uint16_t); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302150125.r1F1PSds039848>