Subject: | [PATCH] Zero-fill socket address structures befor passing them to kernel |
They may extend in future (in fact, it happened already).
Subject: | 0002-Zero-fill-socket-address-structures-befor-passing-th.patch |
From d4647da9362a62ebfa31dce291c0de941f5a68ba Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Sun, 20 Nov 2011 18:54:35 +0100
Subject: [PATCH 2/2] Zero-fill socket address structures befor passing them to kernel
They may extend in future (in fact, it happened already).
---
BlueZ.xs | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/BlueZ.xs b/BlueZ.xs
index 3eee2db..0caa75a 100644
--- a/BlueZ.xs
+++ b/BlueZ.xs
@@ -398,6 +398,7 @@ _connect(fd, addr, port, proto)
if(strcasecmp(proto, "RFCOMM") == 0) {
struct sockaddr_rc rcaddr;
+ memset(&rcaddr, 0, sizeof(rcaddr));
rcaddr.rc_family = AF_BLUETOOTH;
rcaddr.rc_channel = (uint8_t) port;
str2ba(addr, &rcaddr.rc_bdaddr);
@@ -412,6 +413,7 @@ _connect(fd, addr, port, proto)
else if(strcasecmp(proto, "L2CAP") == 0) {
struct sockaddr_l2 l2addr;
+ memset(&l2addr, 0, sizeof(l2addr));
l2addr.l2_family = AF_BLUETOOTH;
l2addr.l2_psm = htobs(port);
@@ -447,7 +449,9 @@ _bind(fd, port, proto)
if(strcasecmp(proto, "RFCOMM") == 0) {
struct sockaddr_rc rcaddr;
+
// set the connection parameters
+ memset(&rcaddr, 0, sizeof(rcaddr));
rcaddr.rc_family = AF_BLUETOOTH;
rcaddr.rc_channel = (uint8_t) port;
rcaddr.rc_bdaddr = *BDADDR_ANY;
@@ -457,7 +461,9 @@ _bind(fd, port, proto)
else if(strcasecmp(proto, "L2CAP") == 0) {
struct sockaddr_l2 l2addr;
+
// set the connection parameters
+ memset(&l2addr, 0, sizeof(l2addr));
l2addr.l2_family = AF_BLUETOOTH;
l2addr.l2_psm = htobs(port);
l2addr.l2_bdaddr = *BDADDR_ANY;
--
1.7.1