projects
/
folly.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7bf1835
)
fix dangling pointer bug in IPAddressV6
author
Tianjiao Yin
<ytj@fb.com>
Fri, 19 Feb 2016 18:40:46 +0000
(10:40 -0800)
committer
facebook-github-bot-0
<folly-bot@fb.com>
Fri, 19 Feb 2016 19:20:26 +0000
(11:20 -0800)
Summary: `mask(numBits)` returns a temporary variable. After its lifetime ends, subbytes becomes a dangling pointer.
Reviewed By: yfeldblum
Differential Revision:
D2953699
fb-gh-sync-id:
5d5a35716ecaa1b3d96edb5a459615756848b92f
shipit-source-id:
5d5a35716ecaa1b3d96edb5a459615756848b92f
folly/IPAddressV6.cpp
patch
|
blob
|
history
diff --git
a/folly/IPAddressV6.cpp
b/folly/IPAddressV6.cpp
index 290f1c0bf671772a3bef5f92c8d2fbf0dca02c52..915767b493d9a620b21e89780ee203150eac3c9a 100644
(file)
--- a/
folly/IPAddressV6.cpp
+++ b/
folly/IPAddressV6.cpp
@@
-374,8
+374,8
@@
const ByteArray16 IPAddressV6::fetchMask(size_t numBits) {
// protected
bool IPAddressV6::inBinarySubnet(const std::array<uint8_t, 2> addr,
size_t numBits) const {
-
const unsigned char* subbytes = mask(numBits).bytes(
);
- return (std::memcmp(addr.data(),
subbytes
, 2) == 0);
+
auto masked = mask(numBits
);
+ return (std::memcmp(addr.data(),
masked.bytes()
, 2) == 0);
}
// static private