1 Taken from https://salsa.debian.org/debian/libtirpc/-/raw/master/debian/patches/06-hurd-client-port.diff
3 Description: Fix client code for hurd, avoiding malloc overflow
4 When trying to setup a inet connection, it happens the following:
5 - in libtirp, src/clnt_vc.c, clnt_vc_create gets called
6 - when trying to allocate vc_fd_locks, __rpc_dtbsize() is used as size
7 for that array of fd locks
8 - __rpc_dtbsize(), in src/rpc_generic.c, queries using rlimit the
9 maximum (rlim_max) number of file descriptors (RLIMIT_NOFILE):
10 - on Linux, the default is { rlim_cur = 1024, rlim_max = 4096 }
11 - on kFreeBSD, the default is { rlim_cur = 1024, rlim_max = 1024 }
12 - on Hurd, the default is { rlim_cur = 1024, rlim_max = RLIM_INFINITY }
13 meaning that on Hurd the memory allocation fails (as
14 __rpc_dtbsize() * sizeof(int) overflows and is negative)
16 Change libtiprc so __rpc_dtbsize falls back on rlim_cur if rlim_max
19 This patch fixes the client connection using inet sockets; local unix
20 sockets are not working, for two reasons so far:
21 - getpeername on them gives EOPNOTSUPP
22 - SO_REUSEADDR is not implemented for them
23 Author: Pino Toscano <pino@debian.org>
25 Bug-Debian: http://bugs.debian.org/739674
27 Reviewed-By: Petter Reinholdtsen
28 Last-Update: 2014-03-03
30 --- a/src/rpc_generic.c
31 +++ b/src/rpc_generic.c
41 if (getrlimit(RLIMIT_NOFILE, &rl) == 0) {
42 - return (tbsize = (int)rl.rlim_max);
44 + if (lim == RLIM_INFINITY) {
47 + return (tbsize = (int)lim);
50 * Something wrong. I'll try to save face by returning a