gnu: libevent@2.0: Add fix from upstream.

This fix was cherry-picked by Mozilla from upstream libevent-2.1 to its
bundled copy of libevent-2.0.21 in mozilla-esr45.

* gnu/packages/patches/libevent-2.0-evbuffer-add-use-last-with-datap.patch:
New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/libevent.scm (libevent-2.0)[source][patches]: Add it.
This commit is contained in:
Mark H Weaver 2017-03-18 02:29:12 -04:00
parent 26e34e1e12
commit 512fc6db7b
No known key found for this signature in database
GPG Key ID: 7CEF29847562C516
3 changed files with 54 additions and 13 deletions

View File

@ -677,6 +677,7 @@ dist_patch_DATA = \
%D%/packages/patches/libdrm-symbol-check.patch \
%D%/packages/patches/libepoxy-gl-null-checks.patch \
%D%/packages/patches/libevent-dns-tests.patch \
%D%/packages/patches/libevent-2.0-evbuffer-add-use-last-with-datap.patch \
%D%/packages/patches/libevent-2.0-evdns-fix-remote-stack-overread.patch \
%D%/packages/patches/libevent-2.0-evdns-fix-searching-empty-hostnames.patch \
%D%/packages/patches/libevent-2.0-evutil-fix-buffer-overflow.patch \

View File

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015, 2017 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015 Eric Dvorsak <eric@dvorsak.fr>
;;; Copyright © 2016 David Thompson <davet@gnu.org>
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
@ -74,18 +74,20 @@ loop.")
(inherit libevent)
(version "2.0.22")
(source (origin
(method url-fetch)
(uri (string-append
"https://github.com/libevent/libevent/releases/download/release-"
version "-stable/libevent-" version "-stable.tar.gz"))
(sha256
(base32
"18qz9qfwrkakmazdlwxvjmw8p76g70n3faikwvdwznns1agw9hki"))
(patches (search-patches
"libevent-dns-tests.patch"
"libevent-2.0-evdns-fix-remote-stack-overread.patch"
"libevent-2.0-evutil-fix-buffer-overflow.patch"
"libevent-2.0-evdns-fix-searching-empty-hostnames.patch"))))))
(method url-fetch)
(uri (string-append
"https://github.com/libevent/libevent/releases/download/release-"
version "-stable/libevent-" version "-stable.tar.gz"))
(sha256
(base32
"18qz9qfwrkakmazdlwxvjmw8p76g70n3faikwvdwznns1agw9hki"))
(patches
(search-patches
"libevent-dns-tests.patch"
"libevent-2.0-evdns-fix-remote-stack-overread.patch"
"libevent-2.0-evutil-fix-buffer-overflow.patch"
"libevent-2.0-evdns-fix-searching-empty-hostnames.patch"
"libevent-2.0-evbuffer-add-use-last-with-datap.patch"))))))
(define-public libev
(package

View File

@ -0,0 +1,38 @@
From a8769ef12d7e223e33fc47bed03fba2bfa2f3536 Mon Sep 17 00:00:00 2001
From: Marcus Sundberg <marcus@marcussundberg.com>
Date: Sat, 26 Mar 2016 20:11:43 +0100
Subject: [PATCH] evbuffer_add: Use last_with_datap if set, not last.
evbuffer_add() would always put data in the last chain, even if there
was available space in a previous chain, and in doing so it also
failed to update last_with_datap, causing subsequent calls to other
functions that do look at last_with_datap to add data in the middle
of the evbuffer instead of at the end.
Fixes the evbuffer_add() part of issue #335, and the evbuffer/add2 and
evbuffer/add3 tests, and also prevents wasting space available in the
chain pointed to by last_with_datap.
---
buffer.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/buffer.c b/buffer.c
index 7cca0e8a..f378b731 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1732,7 +1732,11 @@ evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen)
goto done;
}
- chain = buf->last;
+ if (*buf->last_with_datap == NULL) {
+ chain = buf->last;
+ } else {
+ chain = *buf->last_with_datap;
+ }
/* If there are no chains allocated for this buffer, allocate one
* big enough to hold all the data. */
--
2.12.0