Linux bluetooth development
 help / color / mirror / Atom feed
From: Iain Hibbert <plunky@rya-online.net>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] hcidump: use correct size to copy 'direction' value
Date: Thu, 14 Apr 2011 10:08:36 +0100	[thread overview]
Message-ID: <20110414091124.D0AB826008F@galant.ukfsn.org> (raw)

frm.in is stored as an uint8_t, so we cannot copy an int there
directly.  use an intermediate variable so that it also works
on big-endian systems.
---
 src/hcidump.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/hcidump.c b/src/hcidump.c
index 2023130..f865ad6 100644
--- a/src/hcidump.c
+++ b/src/hcidump.c
@@ -281,9 +281,11 @@ static int process_frames(int dev, int sock, int fd, unsigned long flags)
 
 		cmsg = CMSG_FIRSTHDR(&msg);
 		while (cmsg) {
+			int dir;
 			switch (cmsg->cmsg_type) {
 			case HCI_CMSG_DIR:
-				memcpy(&frm.in, CMSG_DATA(cmsg), sizeof(int));
+				memcpy(&dir, CMSG_DATA(cmsg), sizeof(int));
+				frm.in = (uint8_t) dir;
 				break;
 			case HCI_CMSG_TSTAMP:
 				memcpy(&frm.ts, CMSG_DATA(cmsg),
-- 
1.7.4.1


             reply	other threads:[~2011-04-14  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-14  9:08 Iain Hibbert [this message]
2011-04-14 17:15 ` [PATCH] hcidump: use correct size to copy 'direction' value Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110414091124.D0AB826008F@galant.ukfsn.org \
    --to=plunky@rya-online.net \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox