mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
as of revision 41 of our libevent checkout, we no longer need to include our own evutil_rand.c
This commit is contained in:
parent
7ab14ad4b1
commit
1a4f4c5812
2 changed files with 4 additions and 151 deletions
|
@ -122,7 +122,6 @@
|
||||||
A21F15AD11729A9F00CF5A9C /* AddMagnetWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A21F1538117299F100CF5A9C /* AddMagnetWindow.xib */; };
|
A21F15AD11729A9F00CF5A9C /* AddMagnetWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A21F1538117299F100CF5A9C /* AddMagnetWindow.xib */; };
|
||||||
A21FBBAB0EDA78C300BC3C51 /* bandwidth.h in Headers */ = {isa = PBXBuildFile; fileRef = A21FBBA90EDA78C300BC3C51 /* bandwidth.h */; };
|
A21FBBAB0EDA78C300BC3C51 /* bandwidth.h in Headers */ = {isa = PBXBuildFile; fileRef = A21FBBA90EDA78C300BC3C51 /* bandwidth.h */; };
|
||||||
A21FBBAC0EDA78C300BC3C51 /* bandwidth.c in Sources */ = {isa = PBXBuildFile; fileRef = A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */; };
|
A21FBBAC0EDA78C300BC3C51 /* bandwidth.c in Sources */ = {isa = PBXBuildFile; fileRef = A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */; };
|
||||||
A220AF7513D7C4B00035C512 /* evutil_rand.c in Sources */ = {isa = PBXBuildFile; fileRef = A220AF7413D7C4B00035C512 /* evutil_rand.c */; };
|
|
||||||
A220AF7B13D7CC460035C512 /* GlobalOptionsPopover.xib in Resources */ = {isa = PBXBuildFile; fileRef = A220AF7913D7CC460035C512 /* GlobalOptionsPopover.xib */; };
|
A220AF7B13D7CC460035C512 /* GlobalOptionsPopover.xib in Resources */ = {isa = PBXBuildFile; fileRef = A220AF7913D7CC460035C512 /* GlobalOptionsPopover.xib */; };
|
||||||
A220EC5B118C8A060022B4BE /* tr-lpd.c in Sources */ = {isa = PBXBuildFile; fileRef = A220EC59118C8A060022B4BE /* tr-lpd.c */; };
|
A220EC5B118C8A060022B4BE /* tr-lpd.c in Sources */ = {isa = PBXBuildFile; fileRef = A220EC59118C8A060022B4BE /* tr-lpd.c */; };
|
||||||
A220EC5C118C8A060022B4BE /* tr-lpd.h in Headers */ = {isa = PBXBuildFile; fileRef = A220EC5A118C8A060022B4BE /* tr-lpd.h */; };
|
A220EC5C118C8A060022B4BE /* tr-lpd.h in Headers */ = {isa = PBXBuildFile; fileRef = A220EC5A118C8A060022B4BE /* tr-lpd.h */; };
|
||||||
|
@ -237,6 +236,7 @@
|
||||||
A29DF8BA0DB2544C00D04E5A /* resume.h in Headers */ = {isa = PBXBuildFile; fileRef = A29DF8B70DB2544C00D04E5A /* resume.h */; };
|
A29DF8BA0DB2544C00D04E5A /* resume.h in Headers */ = {isa = PBXBuildFile; fileRef = A29DF8B70DB2544C00D04E5A /* resume.h */; };
|
||||||
A29DF8BB0DB2544C00D04E5A /* torrent.h in Headers */ = {isa = PBXBuildFile; fileRef = A29DF8B80DB2544C00D04E5A /* torrent.h */; };
|
A29DF8BB0DB2544C00D04E5A /* torrent.h in Headers */ = {isa = PBXBuildFile; fileRef = A29DF8B80DB2544C00D04E5A /* torrent.h */; };
|
||||||
A29DF8BE0DB2545F00D04E5A /* verify.h in Headers */ = {isa = PBXBuildFile; fileRef = A2D22A110D65EED100007D5F /* verify.h */; };
|
A29DF8BE0DB2545F00D04E5A /* verify.h in Headers */ = {isa = PBXBuildFile; fileRef = A2D22A110D65EED100007D5F /* verify.h */; };
|
||||||
|
A29E653613F1603100048D71 /* evutil_rand.c in Sources */ = {isa = PBXBuildFile; fileRef = A29E653513F1603100048D71 /* evutil_rand.c */; };
|
||||||
A29EBE710DC06068006CEE80 /* libcurl.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.4.dylib */; };
|
A29EBE710DC06068006CEE80 /* libcurl.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.4.dylib */; };
|
||||||
A2A1CB7A0BF29D5500AE959F /* PeerProgressIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A1CB780BF29D5500AE959F /* PeerProgressIndicatorCell.m */; };
|
A2A1CB7A0BF29D5500AE959F /* PeerProgressIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A1CB780BF29D5500AE959F /* PeerProgressIndicatorCell.m */; };
|
||||||
A2A3065C0AAD24A80049E2AC /* UKFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306540AAD24A80049E2AC /* UKFileWatcher.m */; };
|
A2A3065C0AAD24A80049E2AC /* UKFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306540AAD24A80049E2AC /* UKFileWatcher.m */; };
|
||||||
|
@ -602,7 +602,6 @@
|
||||||
A21F15AB11729A8B00CF5A9C /* AddMagnetWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AddMagnetWindowController.h; path = macosx/AddMagnetWindowController.h; sourceTree = "<group>"; };
|
A21F15AB11729A8B00CF5A9C /* AddMagnetWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AddMagnetWindowController.h; path = macosx/AddMagnetWindowController.h; sourceTree = "<group>"; };
|
||||||
A21FBBA90EDA78C300BC3C51 /* bandwidth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bandwidth.h; path = libtransmission/bandwidth.h; sourceTree = "<group>"; };
|
A21FBBA90EDA78C300BC3C51 /* bandwidth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bandwidth.h; path = libtransmission/bandwidth.h; sourceTree = "<group>"; };
|
||||||
A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bandwidth.c; path = libtransmission/bandwidth.c; sourceTree = "<group>"; };
|
A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bandwidth.c; path = libtransmission/bandwidth.c; sourceTree = "<group>"; };
|
||||||
A220AF7413D7C4B00035C512 /* evutil_rand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = evutil_rand.c; path = "third-party/evutil_rand.c"; sourceTree = "<group>"; };
|
|
||||||
A220AF7A13D7CC460035C512 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = macosx/en.lproj/GlobalOptionsPopover.xib; sourceTree = "<group>"; };
|
A220AF7A13D7CC460035C512 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = macosx/en.lproj/GlobalOptionsPopover.xib; sourceTree = "<group>"; };
|
||||||
A220EC59118C8A060022B4BE /* tr-lpd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tr-lpd.c"; path = "libtransmission/tr-lpd.c"; sourceTree = "<group>"; };
|
A220EC59118C8A060022B4BE /* tr-lpd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tr-lpd.c"; path = "libtransmission/tr-lpd.c"; sourceTree = "<group>"; };
|
||||||
A220EC5A118C8A060022B4BE /* tr-lpd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tr-lpd.h"; path = "libtransmission/tr-lpd.h"; sourceTree = "<group>"; };
|
A220EC5A118C8A060022B4BE /* tr-lpd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tr-lpd.h"; path = "libtransmission/tr-lpd.h"; sourceTree = "<group>"; };
|
||||||
|
@ -809,6 +808,7 @@
|
||||||
A29DF8B60DB2544C00D04E5A /* resume.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = resume.c; path = libtransmission/resume.c; sourceTree = "<group>"; };
|
A29DF8B60DB2544C00D04E5A /* resume.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = resume.c; path = libtransmission/resume.c; sourceTree = "<group>"; };
|
||||||
A29DF8B70DB2544C00D04E5A /* resume.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = resume.h; path = libtransmission/resume.h; sourceTree = "<group>"; };
|
A29DF8B70DB2544C00D04E5A /* resume.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = resume.h; path = libtransmission/resume.h; sourceTree = "<group>"; };
|
||||||
A29DF8B80DB2544C00D04E5A /* torrent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = torrent.h; path = libtransmission/torrent.h; sourceTree = "<group>"; };
|
A29DF8B80DB2544C00D04E5A /* torrent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = torrent.h; path = libtransmission/torrent.h; sourceTree = "<group>"; };
|
||||||
|
A29E653513F1603100048D71 /* evutil_rand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = evutil_rand.c; path = "third-party/libevent/evutil_rand.c"; sourceTree = "<group>"; };
|
||||||
A29EBE520DC01FC9006CEE80 /* web.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = web.c; path = libtransmission/web.c; sourceTree = "<group>"; };
|
A29EBE520DC01FC9006CEE80 /* web.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = web.c; path = libtransmission/web.c; sourceTree = "<group>"; };
|
||||||
A29EBE530DC01FC9006CEE80 /* web.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = web.h; path = libtransmission/web.h; sourceTree = "<group>"; };
|
A29EBE530DC01FC9006CEE80 /* web.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = web.h; path = libtransmission/web.h; sourceTree = "<group>"; };
|
||||||
A29EBE700DC06068006CEE80 /* libcurl.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.4.dylib; path = "third-party/curl/lib/libcurl.4.dylib"; sourceTree = "<group>"; };
|
A29EBE700DC06068006CEE80 /* libcurl.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.4.dylib; path = "third-party/curl/lib/libcurl.4.dylib"; sourceTree = "<group>"; };
|
||||||
|
@ -1581,7 +1581,7 @@
|
||||||
A2074F8412BEAA6600F70985 /* evmap.c */,
|
A2074F8412BEAA6600F70985 /* evmap.c */,
|
||||||
A2074F9812BEAAAF00F70985 /* evthread.c */,
|
A2074F9812BEAAAF00F70985 /* evthread.c */,
|
||||||
A2074FA212BEAAC600F70985 /* evutil.c */,
|
A2074FA212BEAAC600F70985 /* evutil.c */,
|
||||||
A220AF7413D7C4B00035C512 /* evutil_rand.c */,
|
A29E653513F1603100048D71 /* evutil_rand.c */,
|
||||||
A2074FAA12BEAAFF00F70985 /* http.c */,
|
A2074FAA12BEAAFF00F70985 /* http.c */,
|
||||||
A2074FBE12BEAB9A00F70985 /* kqueue.c */,
|
A2074FBE12BEAB9A00F70985 /* kqueue.c */,
|
||||||
A2074FB612BEAB1E00F70985 /* listener.c */,
|
A2074FB612BEAB1E00F70985 /* listener.c */,
|
||||||
|
@ -2400,7 +2400,7 @@
|
||||||
A207503712BEADA200F70985 /* poll.c in Sources */,
|
A207503712BEADA200F70985 /* poll.c in Sources */,
|
||||||
A20750B812BEB66900F70985 /* bufferevent_ratelim.c in Sources */,
|
A20750B812BEB66900F70985 /* bufferevent_ratelim.c in Sources */,
|
||||||
A2AA9BE3132CAE2000FA131E /* evdns.c in Sources */,
|
A2AA9BE3132CAE2000FA131E /* evdns.c in Sources */,
|
||||||
A220AF7513D7C4B00035C512 /* evutil_rand.c in Sources */,
|
A29E653613F1603100048D71 /* evutil_rand.c in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
147
third-party/evutil_rand.c
vendored
147
third-party/evutil_rand.c
vendored
|
@ -1,147 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007-2010 Niels Provos and Nick Mathewson
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This file has our secure PRNG code. On platforms that have arc4random(),
|
|
||||||
* we just use that. Otherwise, we include arc4random.c as a bunch of static
|
|
||||||
* functions, and wrap it lightly. We don't expose the arc4random*() APIs
|
|
||||||
* because A) they aren't in our namespace, and B) it's not nice to name your
|
|
||||||
* APIs after their implementations. We keep them in a separate file
|
|
||||||
* so that other people can rip it out and use it for whatever.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "event2/event-config.h"
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#include "util-internal.h"
|
|
||||||
#include "evthread-internal.h"
|
|
||||||
|
|
||||||
#ifdef _EVENT_HAVE_ARC4RANDOM
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
int
|
|
||||||
evutil_secure_rng_init(void)
|
|
||||||
{
|
|
||||||
/* call arc4random() now to force it to self-initialize */
|
|
||||||
(void) arc4random();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int
|
|
||||||
evutil_secure_rng_global_setup_locks_(const int enable_locks)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ev_arc4random_buf(void *buf, size_t n)
|
|
||||||
{
|
|
||||||
#ifdef _EVENT_HAVE_ARC4RANDOM_BUF
|
|
||||||
arc4random_buf(buf, n);
|
|
||||||
#else
|
|
||||||
unsigned char *b = buf;
|
|
||||||
/* Make sure that we start out with b at a 4-byte alignment; plenty
|
|
||||||
* of CPUs care about this for 32-bit access. */
|
|
||||||
if (n >= 4 && ((ev_uintptr_t)b) & 3) {
|
|
||||||
ev_uint32_t u = arc4random();
|
|
||||||
int n_bytes = 4 - (((ev_uintptr_t)b) & 3);
|
|
||||||
memcpy(b, &u, n_bytes);
|
|
||||||
b += n_bytes;
|
|
||||||
n -= n_bytes;
|
|
||||||
}
|
|
||||||
while (n >= 4) {
|
|
||||||
*(ev_uint32_t*)b = arc4random();
|
|
||||||
b += 4;
|
|
||||||
n -= 4;
|
|
||||||
}
|
|
||||||
if (n) {
|
|
||||||
ev_uint32_t u = arc4random();
|
|
||||||
memcpy(b, &u, n);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* !_EVENT_HAVE_ARC4RANDOM { */
|
|
||||||
|
|
||||||
#ifdef _EVENT_ssize_t
|
|
||||||
#define ssize_t _EVENT_SSIZE_t
|
|
||||||
#endif
|
|
||||||
#define ARC4RANDOM_EXPORT static
|
|
||||||
#define _ARC4_LOCK() EVLOCK_LOCK(arc4rand_lock, 0)
|
|
||||||
#define _ARC4_UNLOCK() EVLOCK_UNLOCK(arc4rand_lock, 0)
|
|
||||||
#ifndef _EVENT_DISABLE_THREAD_SUPPORT
|
|
||||||
static void *arc4rand_lock;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ARC4RANDOM_UINT32 ev_uint32_t
|
|
||||||
#define ARC4RANDOM_NOSTIR
|
|
||||||
#define ARC4RANDOM_NORANDOM
|
|
||||||
#define ARC4RANDOM_NOUNIFORM
|
|
||||||
|
|
||||||
#include "./arc4random.c"
|
|
||||||
|
|
||||||
#ifndef _EVENT_DISABLE_THREAD_SUPPORT
|
|
||||||
int
|
|
||||||
evutil_secure_rng_global_setup_locks_(const int enable_locks)
|
|
||||||
{
|
|
||||||
EVTHREAD_SETUP_GLOBAL_LOCK(arc4rand_lock, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
|
||||||
evutil_secure_rng_init(void)
|
|
||||||
{
|
|
||||||
int val;
|
|
||||||
|
|
||||||
_ARC4_LOCK();
|
|
||||||
if (!arc4_seeded_ok)
|
|
||||||
arc4_stir();
|
|
||||||
val = arc4_seeded_ok ? 0 : -1;
|
|
||||||
_ARC4_UNLOCK();
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ev_arc4random_buf(void *buf, size_t n)
|
|
||||||
{
|
|
||||||
arc4random_buf(buf, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* } !_EVENT_HAVE_ARC4RANDOM */
|
|
||||||
|
|
||||||
void
|
|
||||||
evutil_secure_rng_get_bytes(void *buf, size_t n)
|
|
||||||
{
|
|
||||||
ev_arc4random_buf(buf, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
evutil_secure_rng_add_bytes(const char *buf, size_t n)
|
|
||||||
{
|
|
||||||
arc4random_addrandom((unsigned char*)buf,
|
|
||||||
n>(size_t)INT_MAX ? INT_MAX : (int)n);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue