From 85aa0b62ddd139c6a0544db9917979ab93d5c4f1 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Thu, 28 Sep 2017 16:42:58 -0400 Subject: [PATCH] Mark methods_stream as const. Function pointer tables require relocations, so this goes into .data.rel.ro, not .rodata, but this will at least mark the pages read-only after relocations are resolved. Bug: None Change-Id: I8625e7466b2dcadafc4e4e5f9c6eccbd87af7109 Reviewed-on: https://webrtc-review.googlesource.com/4580 Reviewed-by: Taylor Brandstetter Commit-Queue: Taylor Brandstetter Cr-Commit-Position: refs/heads/master@{#20029} --- rtc_base/opensslstreamadapter.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/rtc_base/opensslstreamadapter.cc b/rtc_base/opensslstreamadapter.cc index 60ce6ae0dc..4efdd6f1a2 100644 --- a/rtc_base/opensslstreamadapter.cc +++ b/rtc_base/opensslstreamadapter.cc @@ -165,16 +165,14 @@ static long stream_ctrl(BIO* h, int cmd, long arg1, void* arg2); static int stream_new(BIO* h); static int stream_free(BIO* data); -// TODO(davidben): This should be const once BoringSSL is assumed. -static BIO_METHOD methods_stream = { +static const BIO_METHOD methods_stream = { BIO_TYPE_BIO, "stream", stream_write, stream_read, stream_puts, 0, stream_ctrl, stream_new, stream_free, nullptr, }; -static BIO_METHOD* BIO_s_stream() { return(&methods_stream); } - static BIO* BIO_new_stream(StreamInterface* stream) { - BIO* ret = BIO_new(BIO_s_stream()); + // TODO(davidben): Remove the const_cast when BoringSSL is assumed. + BIO* ret = BIO_new(const_cast(&methods_stream)); if (ret == nullptr) return nullptr; ret->ptr = stream;