Resolves: #1358845 - prevent nghttpx from crashing on armv7hl

This commit is contained in:
Kamil Dudka 2016-07-26 16:41:11 +02:00
parent d3007a7c90
commit 6f4f38d657
2 changed files with 105 additions and 1 deletions

View File

@ -0,0 +1,97 @@
From 9fcf3200342603e9aa86a4bd3ba62f890237a200 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Tue, 26 Jul 2016 12:58:46 +0200
Subject: [PATCH] nghttpx: avoid using std::function to fix crash on armv7hl
Bug: https://bugzilla.redhat.com/1358845
---
src/shrpx_client_handler.cc | 8 ++++----
src/shrpx_client_handler.h | 6 ++++--
src/shrpx_http_downstream_connection.cc | 6 +++---
src/shrpx_http_downstream_connection.h | 5 +++--
4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/src/shrpx_client_handler.cc b/src/shrpx_client_handler.cc
index 2c9b2a1..890143e 100644
--- a/src/shrpx_client_handler.cc
+++ b/src/shrpx_client_handler.cc
@@ -612,18 +612,18 @@ int ClientHandler::validate_next_proto() {
return -1;
}
-int ClientHandler::do_read() { return read_(*this); }
-int ClientHandler::do_write() { return write_(*this); }
+int ClientHandler::do_read() { return (this->*read_)(); }
+int ClientHandler::do_write() { return (this->*write_)(); }
int ClientHandler::on_read() {
- auto rv = on_read_(*this);
+ auto rv = (this->*on_read_)();
if (rv != 0) {
return rv;
}
conn_.handle_tls_pending_read();
return 0;
}
-int ClientHandler::on_write() { return on_write_(*this); }
+int ClientHandler::on_write() { return (this->*on_write_)(); }
const std::string &ClientHandler::get_ipaddr() const { return ipaddr_; }
diff --git a/src/shrpx_client_handler.h b/src/shrpx_client_handler.h
index bdfdafd..08f42b3 100644
--- a/src/shrpx_client_handler.h
+++ b/src/shrpx_client_handler.h
@@ -167,8 +167,10 @@ private:
// The client address used in "for" parameter of Forwarded header
// field.
std::string forwarded_for_;
- std::function<int(ClientHandler &)> read_, write_;
- std::function<int(ClientHandler &)> on_read_, on_write_;
+ int (ClientHandler::*read_)();
+ int (ClientHandler::*write_)();
+ int (ClientHandler::*on_read_)();
+ int (ClientHandler::*on_write_)();
// Address of frontend listening socket
const UpstreamAddr *faddr_;
Worker *worker_;
diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc
index 077844c..8a38788 100644
--- a/src/shrpx_http_downstream_connection.cc
+++ b/src/shrpx_http_downstream_connection.cc
@@ -1177,13 +1177,13 @@ int HttpDownstreamConnection::connected() {
return 0;
}
-int HttpDownstreamConnection::on_read() { return do_read_(*this); }
+int HttpDownstreamConnection::on_read() { return (this->*do_read_)(); }
-int HttpDownstreamConnection::on_write() { return do_write_(*this); }
+int HttpDownstreamConnection::on_write() { return (this->*do_write_)(); }
void HttpDownstreamConnection::on_upstream_change(Upstream *upstream) {}
-void HttpDownstreamConnection::signal_write() { do_signal_write_(*this); }
+void HttpDownstreamConnection::signal_write() { (this->*do_signal_write_)(); }
int HttpDownstreamConnection::actual_signal_write() {
ev_feed_event(conn_.loop, &conn_.wev, EV_WRITE);
diff --git a/src/shrpx_http_downstream_connection.h b/src/shrpx_http_downstream_connection.h
index 8fad535..0ab430c 100644
--- a/src/shrpx_http_downstream_connection.h
+++ b/src/shrpx_http_downstream_connection.h
@@ -83,8 +83,9 @@ public:
private:
Connection conn_;
- std::function<int(HttpDownstreamConnection &)> do_read_, do_write_,
- do_signal_write_;
+ int (HttpDownstreamConnection::*do_read_)();
+ int (HttpDownstreamConnection::*do_write_)();
+ int (HttpDownstreamConnection::*do_signal_write_)();
Worker *worker_;
// nullptr if TLS is not used.
SSL_CTX *ssl_ctx_;
--
2.5.5

View File

@ -1,12 +1,15 @@
Summary: Experimental HTTP/2 client, server and proxy
Name: nghttp2
Version: 1.13.0
Release: 1%{?dist}
Release: 2%{?dist}
License: MIT
Group: Applications/Internet
URL: https://nghttp2.org/
Source0: https://github.com/tatsuhiro-t/nghttp2/releases/download/v%{version}/nghttp2-%{version}.tar.xz
# prevent nghttpx from crashing on armv7hl (#1358845)
Patch1: 0001-nghttp2-1.13.0-armv7hl-sigsegv.patch
BuildRequires: CUnit-devel
BuildRequires: libev-devel
BuildRequires: openssl-devel
@ -40,6 +43,7 @@ for building applications with libnghttp2.
%prep
%setup -q
%patch1 -p1
%build
@ -101,6 +105,9 @@ make %{?_smp_mflags} check
%changelog
* Tue Jul 26 2016 Kamil Dudka <kdudka@redhat.com> 1.13.0-2
- prevent nghttpx from crashing on armv7hl (#1358845)
* Thu Jul 21 2016 Kamil Dudka <kdudka@redhat.com> 1.13.0-1
- update to the latest upstream release