-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-111178: Fix getsockaddrarg() undefined behavior #131668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
88fc5c2
1aebf4c
9eb932c
533a478
9968c1e
a95b22d
18ed09e
99dcf45
c0d7d03
7178cfd
94f7b6f
7455bf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2107,6 +2107,21 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, | |
| straddr = PyBytes_AS_STRING(args); | ||
| if (setbdaddr(straddr, &_BT_HCI_MEMB(addr, bdaddr)) < 0) | ||
| return 0; | ||
| #elif defined(__FreeBSD__) | ||
| _BT_HCI_MEMB(addr, family) = AF_BLUETOOTH; | ||
| if (!PyBytes_Check(args)) { | ||
| PyErr_Format(PyExc_OSError, "%s: " | ||
| "wrong node format", caller); | ||
| return 0; | ||
| } | ||
| const char *straddr = PyBytes_AS_STRING(args); | ||
| size_t len = PyBytes_GET_SIZE(args); | ||
| if (len >= sizeof(_BT_HCI_MEMB(addr, node))) { | ||
| PyErr_Format(PyExc_OSError, "%s: " | ||
| "node too long", caller); | ||
| return 0; | ||
| } | ||
| strcpy(_BT_HCI_MEMB(addr, node), straddr); | ||
| #else /* __NetBSD__ || __DragonFly__ */ | ||
| _BT_HCI_MEMB(addr, family) = AF_BLUETOOTH; | ||
| unsigned short dev = _BT_HCI_MEMB(addr, dev); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is it defined?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a bunch of #if (defined(HAVE_BLUETOOTH_H) || defined(HAVE_BLUETOOTH_BLUETOOTH_H)) \
&& !defined(__NetBSD__) && !defined(__DragonFly__)
#define USE_BLUETOOTH 1
#if defined(__FreeBSD__)
...
#define _BT_HCI_MEMB(sa, memb) ((sa)->hci_##memb)
...
#elif defined(__NetBSD__) || defined(__DragonFly__) // <- unreachable
...
#define _BT_HCI_MEMB(sa, memb) ((sa)->bt_##memb)
#else
...
#define _BT_HCI_MEMB(sa, memb) ((sa)->hci_##memb)
...
#endif
#endifBut AFAICT, the I think we should remove
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know about |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.