pkgs.jesec-rtorrent: use upstream with patch

This commit is contained in:
makefu 2025-01-31 22:06:44 +01:00
parent 478938fe0b
commit e768397cda
No known key found for this signature in database
GPG key ID: 36F7711F3FC0F225
4 changed files with 151 additions and 44 deletions

View file

@ -0,0 +1,30 @@
From dd4a96073d4a60ca8fff55be6ea6b17018de96a8 Mon Sep 17 00:00:00 2001
From: Varun Madiath <git@madiathv.com>
Date: Wed, 19 Jul 2023 15:30:57 -0400
Subject: [PATCH] utils: lockfile: avoid stack overflow for lockfile buffer
Original patch by @cyphar was submitted to rakshasa/rtorrent at
https://github.com/rakshasa/rtorrent/pull/1169.
Observed the segfault on nixos-unstable.
---
src/utils/lockfile.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/utils/lockfile.cc b/src/utils/lockfile.cc
index 76e4b8f..441f5c8 100644
--- a/src/utils/lockfile.cc
+++ b/src/utils/lockfile.cc
@@ -75,7 +75,8 @@ Lockfile::try_lock() {
int pos = ::gethostname(buf, 255);
if (pos == 0) {
- ::snprintf(buf + std::strlen(buf), 255, ":+%i\n", ::getpid());
+ ssize_t len = std::strlen(buf);
+ ::snprintf(buf + len, 255 - len, ":+%i\n", ::getpid());
ssize_t __attribute__((unused)) result = ::write(fd, buf, std::strlen(buf));
}
--
2.41.0

View file

@ -1,31 +1,30 @@
{
lib,
callPackage,
stdenv,
fetchFromGitHub,
cmake,
curl,
gtest,
ncurses,
jsonRpcSupport ? true,
nlohmann_json,
xmlRpcSupport ? true,
xmlrpc_c,
{ lib
, stdenv
, fetchFromGitHub
, cmake
, curl
, gtest
, libtorrent
, ncurses
, jsonRpcSupport ? true, nlohmann_json
, xmlRpcSupport ? true, xmlrpc_c
}:
let
libtorrent = callPackage ./libtorrent.nix {};
in
stdenv.mkDerivation rec {
pname = "jesec-rtorrent";
version = "0.9.8-r16-unstable-2023-07-21";
version = "0.9.8-r16";
src = fetchFromGitHub {
owner = "jesec";
repo = "rtorrent";
rev = "199e8f85244c8eb1c30163d51755570ad86139bb";
hash = "sha256-AWWOvvUNNOIbNiwY/uz55iKt8A0YuMsyWGjaLgKUOCY=";
rev = "v${version}";
hash = "sha256-i7c1jSawHshj1kaXl8tdpelIKU24okeg9K5/+ht6t2k=";
};
patches = [
./avoid-stack-overflow-for-lockfile-buf.patch
];
passthru = {
inherit libtorrent;
};
@ -34,21 +33,19 @@ stdenv.mkDerivation rec {
cmake
];
buildInputs =
[
curl
libtorrent
ncurses
]
++ lib.optional jsonRpcSupport nlohmann_json
++ lib.optional xmlRpcSupport xmlrpc_c;
buildInputs = [
curl
libtorrent
ncurses
]
++ lib.optional jsonRpcSupport nlohmann_json
++ lib.optional xmlRpcSupport xmlrpc_c;
cmakeFlags =
[
"-DUSE_RUNTIME_CA_DETECTION=NO"
]
++ lib.optional (!jsonRpcSupport) "-DUSE_JSONRPC=NO"
++ lib.optional (!xmlRpcSupport) "-DUSE_XMLRPC=NO";
cmakeFlags = [
"-DUSE_RUNTIME_CA_DETECTION=NO"
]
++ lib.optional (!jsonRpcSupport) "-DUSE_JSONRPC=NO"
++ lib.optional (!xmlRpcSupport) "-DUSE_XMLRPC=NO";
doCheck = true;

View file

@ -0,0 +1,78 @@
From ed30d713e06dbe14edffd3afdf465d67ad69174f Mon Sep 17 00:00:00 2001
From: Jesse Chan <jc@linux.com>
Date: Sat, 14 May 2022 16:21:31 -0700
Subject: [PATCH] include: include what you use
---
include/protocol/handshake.h | 1 +
include/protocol/protocol_base.h | 2 ++
include/test/helpers/mock_compare.h | 3 +++
include/torrent/object_raw_bencode.h | 1 +
include/torrent/utils/allocators.h | 1 +
5 files changed, 8 insertions(+)
diff --git a/include/protocol/handshake.h b/include/protocol/handshake.h
index 8ce8268d..bc654f0a 100644
--- a/include/protocol/handshake.h
+++ b/include/protocol/handshake.h
@@ -7,6 +7,7 @@
#include "handshake_encryption.h"
#include "net/protocol_buffer.h"
#include "net/socket_stream.h"
+#include "net/throttle_list.h"
#include "torrent/bitfield.h"
#include "torrent/peer/peer_info.h"
#include "torrent/utils/priority_queue_default.h"
diff --git a/include/protocol/protocol_base.h b/include/protocol/protocol_base.h
index 18229b0b..0f23fdd4 100644
--- a/include/protocol/protocol_base.h
+++ b/include/protocol/protocol_base.h
@@ -5,6 +5,8 @@
#define LIBTORRENT_NET_PROTOCOL_BASE_H
#include "net/protocol_buffer.h"
+#include "net/throttle_list.h"
+#include "torrent/data/piece.h"
#include "torrent/utils/timer.h"
namespace torrent {
diff --git a/include/test/helpers/mock_compare.h b/include/test/helpers/mock_compare.h
index 9be92ee0..80f78a01 100644
--- a/include/test/helpers/mock_compare.h
+++ b/include/test/helpers/mock_compare.h
@@ -2,8 +2,11 @@
#define LIBTORRENT_TEST_HELPERS_MOCK_COMPARE_H
#include <algorithm>
+#include <map>
#include <type_traits>
+#include <gtest/gtest.h>
+
#include "torrent/event.h"
#include "torrent/net/socket_address.h"
diff --git a/include/torrent/object_raw_bencode.h b/include/torrent/object_raw_bencode.h
index c90d6b0b..8201d7d1 100644
--- a/include/torrent/object_raw_bencode.h
+++ b/include/torrent/object_raw_bencode.h
@@ -8,6 +8,7 @@
#include <cstring>
#include <string>
#include <torrent/common.h>
+#include <torrent/exceptions.h>
namespace torrent {
diff --git a/include/torrent/utils/allocators.h b/include/torrent/utils/allocators.h
index e77549f3..08b85e78 100644
--- a/include/torrent/utils/allocators.h
+++ b/include/torrent/utils/allocators.h
@@ -7,6 +7,7 @@
#define LIBTORRENT_UTILS_ALLOCATORS_H
#include <cstddef>
+#include <cstdlib>
#include <limits>
#include <sys/types.h>

View file

@ -1,22 +1,21 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
gtest,
openssl,
zlib,
{ lib
, stdenv
, fetchFromGitHub
, cmake
, gtest
, openssl
, zlib
}:
stdenv.mkDerivation rec {
pname = "jesec-libtorrent";
version = "0.13.8-r4-unstable-2023-07-04";
version = "0.13.8-r4";
src = fetchFromGitHub {
owner = "jesec";
repo = "libtorrent";
rev = "35d844d4d78a671f8840fe6ae973ebb39a0e8f34";
hash = "sha256-H2oUW9iC2pIUSmP9j0U4RfzO1uiIEWVmeZAfF3Ca48k=";
rev = "v${version}";
hash = "sha256-jC/hgGSi2qy+ToZgdxl1PhASLYbUL0O8trX0th2v5H0=";
};
nativeBuildInputs = [
@ -27,6 +26,9 @@ stdenv.mkDerivation rec {
openssl
zlib
];
patches = [
./ed30d713e06dbe14edffd3afdf465d67ad69174f.patch
];
# Disabled because a test is flaky; see https://github.com/jesec/libtorrent/issues/4.
# doCheck = true;