forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jesec-rtorrent: Add patch to prevent segfault
- Loading branch information
1 parent
1a335c2
commit 4b7ad2c
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
pkgs/applications/networking/p2p/jesec-rtorrent/avoid-stack-overflow-for-lockfile-buf.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters