Commit Graph

87 Commits

Author SHA1 Message Date
Bruce Evans
d142a33b7f Fixed wrong prototypes. Most of the prototypes had missing return types,
or missing const's or `short *' instead of `[ug]id_t *' in argument types.
1998-01-16 13:33:09 +00:00
Philippe Charnier
125c8263d8 Convert to mdoc format. 1998-01-05 07:12:16 +00:00
Bill Paul
acbf996600 In clntudp_call(), it is possible that xdr_replymsg() might fail
partway through its attempt to decode the result structure sent by
the server. If this happens, it can leave the result partially
populated with dynamically allocated memory. In this event, the
xdr_replymsg() failure is detected and RPC_CANTDECODERES is returned,
but the memory in the partially populated result struct is not
free()d.

The end result is that memory is leaked when an RPC_CANTDECODERES
error occurs. (This condition can occur if a CLIENT * handle is created
using clntudp_bufcreate() with a receive buffer size that is too small
to handle the result sent by the server.)

Fixed by setting reply_xdrs.x_op to XDR_FREE and calling
xdr_replymsg() again to free the memory if an RPC_CANTDECODERES error
is detected.

I suspect that the clnt_tcp.c, clnt_unix.c and clnt_raw.c modules
may ha a similar problem, but I haven't duplicated the condition with
those yet.

Found by: dbmalloc
1997-10-26 18:47:31 +00:00
Bruce Evans
b966cc2394 Sorted lists. 1997-10-21 08:41:15 +00:00
John Polstra
7019f59e32 Fix two bugs which caused various RPC programs (mountd, nfsd, ...)
to fail under certain circumstances.

1. In one spot, the ifr_flags member was being examined in the
wrong structure, thus it contained garbage.  On a machine in which
only the loopback interface was up, this caused everything that
wanted to talk to the portmapper to fail -- a particular problem
with laptops, where the pccard ethernet interface is likely to come
up long after the attempt to start mountd, nfsd, amd, etc.

2. Compounding the above problem, get_myaddress() returned a
successful status even though it failed to find an address that it
considered good enough.
1997-10-17 04:59:56 +00:00
Bruce Evans
2bc3b4d735 Removed the subdirectory paths from the definitions of MAN[1-9]. They
were a workaround for limitations in bsd.man.mk that were fixed about
2 years ago.
1997-10-15 16:16:41 +00:00
Bill Paul
4c45fb08aa Correct a bug in the 'allow arbitrary number of socket descriptors' changes
made to the RPC code some months ago. The value of __svc_fdsetsize is being
calculated incorrectly.

Logically, one would assume that __svc_fdsetsize is being used as a
substitute for FD_SETSIZE, with the difference being that __svc_fdsetsize
can be expanded on the fly to accomodate more descriptors if need be.
There are two problems: first, __svc_fdsetsize is not initialized to 0.
Second, __svc_fdsetsize is being calculated in svc.c:xprt_registere() as:

                __svc_fdsetsize = howmany(sock+1, NFDBITS);

This is wrong. If we are adding a socket with index value 4 to the
descriptor set, then __svc_fdsetsize will be 1 (since fds_bits is
an unsigned long, it can support any descriptor from 0 to 31, so we
only need one of them). In order for this to make sense with the
rest of the code though, it should be:

                __svc_fdsetsize = howmany(sock+1, NFDBITS) * NFDBITS;

Now if sock == 4, __svc_fdsetsize will be 32.

This bug causes 2 errors to occur. First, in xprt_register(), it
causes the __svc_fdset descriptor array to be freed and reallocated
unnecessarily. The code checks if it needs to expand the array using
the test: if (sock + 1 > __svc_fdsetsize). The very first time through,
__svc_fdsetsize is 0, which is fine: an array has to be allocated the
first time out. However __svc_fdsetsize is incorrectly set to 1, so
on the second time through, the test (sock + 1 > __svc_fdsetsize)
will still succeed, and the __svc_fdset array will be destroyed and
reallocated for no reason.

Second, the code in svc_run.c:svc_run() can become hopelessly confused.
The svc_run() routine malloc()s its own fd_set array using the value
of __svc_fdsetsize to decide how much memory to allocate. Once the
xprt_register() function expands the __svc_fdset array the first time,
the value for __svc_fdsetsize becomes 2, which is too small: the resulting
calculation causes the code to allocate an array that's only 32 bits wide
when it actually needs 64 bits. It also uses the valuse of __svc_fdsetsize
when copying the contents of the __svc_fdset array into the new array.
The end result is that all but the first 32 file descriptors get lost.

Note: from what I can tell, this bug originated in OpenBSD and was
brought over to us when the code was merged. The bug is still there
in the OpenBSD source.

Total nervous breakdown averted by: Electric Fence 2.0.5
1997-10-14 21:50:17 +00:00
Bill Paul
0e710e8f95 Make selection logic more strict. Only select AF_INET loopback interfaces
that are up on second (loopback only) pass, and only select non-loopback
AF_INET interfaces that are up on first pass.
1997-09-21 23:04:51 +00:00
John Polstra
9295bb8d0d Add a stub version of getpublickey(), in order to eliminate an
undefined symbol referenced from libc.  Without the stub, it is
impossible to execute any program using the shared library if
LD_BIND_NOW=1 is in the environment.  The stub always returns
failure, but it can be overridden outside the library when necessary.

I don't know whether this is the "correct" fix, but it is intolerable
to have any undefined symbols referenced from libc.
1997-08-28 21:50:33 +00:00
Bruce Evans
d437803036 Add to CLEANFILES instead of setting it absolutely. Cleaning of *.S and
tags was broken.
1997-07-21 16:02:09 +00:00
Steve Price
681e5e7a09 Show the real revision date and not the date that this
manpage is being viewed.
1997-06-23 04:03:49 +00:00
Bill Paul
b1d8279802 Hm... wonder how long this has been here.
The logic in get_myaddress() is broken: it always returns the loopback
address due to the following rule:

                if ((ifreq.ifr_flags & IFF_UP) &&
                    ifr->ifr_addr.sa_family == AF_INET &&
                    (loopback == 1 && (ifreq.ifr_flags & IFF_LOOPBACK))) {

The idea is that we want to select the interface address only if it's
up and it's in the AF_INET family. If it turns uout we don't have
such an interface available, we make a second pass through the loop,
this time settling for the loopback interface. But the logic inadvertently
locks out all cases when loopback == 0, so nothing is ever selected until
the second pass (when loopback == 1).

This is changed to:

                if (((ifreq.ifr_flags & IFF_UP) &&
                    ifr->ifr_addr.sa_family == AF_INET) ||
                    (loopback == 1 && (ifreq.ifr_flags & IFF_LOOPBACK))) {

which I think does the right thing.

This is yet another bogon I discovered during NIS+ testing; I need
get_myaddress() to work correctly so that the callback code in the
client library will work.
1997-06-20 17:54:11 +00:00
Bill Paul
c88fdb1d1d Remember to zero sockaddr_in struct before calling uaddr_to_sockaddr() to
populate it. Not doing this can result in a garbage sockaddr_in, which
will cause connect() to block inside clnttcp_create().
1997-06-15 21:03:32 +00:00
Bill Paul
f7cf1c1d14 getnetid() crashes if no /etc/netid file is present (it tries to fclose()
a FILE * handle that wasn't really open).
1997-06-12 18:42:43 +00:00
Bill Paul
973ddb8378 Fix other small things that got lost in the merge:
- bde's change to includes section in getrpcent.3
- Lost comment in svc_run.c (the code here was actually the same since
  I had fixed the 'fds + 1' bug in my stuff at home before mailing
  Peter about it, but I didn't notce that he'd made a change to the
  comment right above the changed line).

Also pointed out by the ever vigilant: bde
1997-05-28 16:38:35 +00:00
Bill Paul
ad133ed648 Resolve conflicts.
This concludes tonight's entertainment. Once I'm sure I haven't destroyed
the world with all these changes, I'll import the utilities. Everything
should continue to work as before. If it doesn't let me know.

Special thanks to Mark Murray for running a test 'make world' for me to
shake out the bugs, which, hopefully, I have fixed.

(And there was much rejoicing.)
1997-05-28 05:05:31 +00:00
Bill Paul
9f3e964560 This commit was generated by cvs2svn to compensate for changes in r26219,
which included commits to RCS files with non-trunk default branches.
1997-05-28 05:00:11 +00:00
Bill Paul
e8636dfd57 Now the biggest step: import the changes to the main RPC code.
Note: you'll need to rinstalkl all your includes before compiling libc
the next time you update your sources in order for all this to work.

Reviewed by:	Mark Murray
1997-05-28 05:00:11 +00:00
John Birrell
870039320f Changed all paths to be relative to src/lib instead of src/lib/libc
so that all these makefiles can be used to build libc_r too.

Added .if ${LIB} == "c" tests to restrict man page builds to libc
to avoid needlessly building them with libc_r too.

Split libc Makefile into Makefile and Makefile.inc to allow the
libc_r Makefile to include Makefile.inc too.
1997-05-03 03:50:06 +00:00
Bruce Evans
a88d7a4bc2 Fixed wrong #include in synopsis. 1997-04-13 13:29:06 +00:00
Peter Wemm
7e546392b5 Revert $FreeBSD$ to $Id$ 1997-02-22 15:12:41 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Peter Wemm
f809a5f8dd Correct logic braino when attempting to exclude loopback addresses on
the first pass.

Submitted by: Greg Lehey <grog@lemis.de>
1997-01-09 16:38:05 +00:00
Peter Wemm
45eccbb217 Two minor changes to try and make it more robust in the face of many
interfaces, until it's redone to use sysctl().
- bump the SIOCGIFCONF buffer size from 1K to 8K
- if we didn't find a suitable address, return a failure.  Previously
  if it didn't find anything it left the return address uninitialised.
  Perhaps it would be better to return AF_INET/111/127.0.0.1 rather than
  failing?
1997-01-09 14:55:15 +00:00
Jordan K. Hubbard
799dbaaffc Eliminate unnecessary warning introduced by a missing forward declaration. 1997-01-01 10:06:37 +00:00
Peter Wemm
a856779ff8 prototype of shared function now in include file 1996-12-31 09:16:12 +00:00
Peter Wemm
e85cee866d use svc_maxfd + 1 in the select() call.
(There may be a behavior difference between the 2.1 and 2.2/3.0 kernels
in this area, it seemed to work for me but I have a horribly hacked
select() that might have a bug in the handling of this)

Submitted by: wpaul
1996-12-31 09:13:59 +00:00
Peter Wemm
c5bb6008ce Oops! Bad Idea! (TM)
Restore the clamp on the return value from rpc_dtablesize()..  Some programs
(eg: ypserv) use this as an indication of how large svc_fdset is in their
hand-rolled svc_run() loops.  The svc_fdset table is maintained by the
rpc library explicitly for compatability with such programs.  (It uses
a different variable-sized bitmap itself internally)
1996-12-30 18:41:20 +00:00
Peter Wemm
9180f99125 - make wire protocol 64 bit type safe
- extern prototypes now in include file
- fix local prototypes
- use standard functions

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 15:21:19 +00:00
Peter Wemm
9ff75e1aac - prototypes now in include file
- overhaul for unlimited fd's
- OpenBSD's ftp port bounce attack fix
- fix timeouts

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 15:19:08 +00:00
Peter Wemm
75a98e21b1 - canonical function declaration
- prototypes now in common include file
- use standard functions

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 15:16:22 +00:00
Peter Wemm
0143afc23b - overhaul for unlimited file descriptors
- prototypes now in include files

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.

Note: potential bug here, It looks like there could be a null pointer
dereference depending on what has already been called to initialise some
shared data.
1996-12-30 15:14:29 +00:00
Peter Wemm
3a6ebf3676 - make wire protocol 64 bit type safe
- use standard functions

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 15:10:14 +00:00
Peter Wemm
ae1e6afd31 - major overhaul to make this deal with unlimited fd's.
- kill non-FD_SETSIZE code

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.

Note, there was a nasty bug with our old code here.  It would trash the
stack if a fd > 31 was passed in.  It was using a "long" as though it
was an "fd_set", ie: it was assuming that a long was 256 bits wide. :-(
This has been lurking here for a while, since the FD_SETSIZE #ifdef's
were first implemented.
1996-12-30 15:07:33 +00:00
Peter Wemm
39f377845f - make wire protocol 64 bit type safe
Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 15:00:53 +00:00
Peter Wemm
c8df2bbd52 Remove our code that clamped the max select() fd number to FD_SETSIZE (256)
This function is now unused.
1996-12-30 14:59:12 +00:00
Peter Wemm
47c49966f6 - kill non-FD_SETSIZE code
Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:57:33 +00:00
Peter Wemm
ec3ca1a2d3 - 64 bit type safe on-the-wire protocol
- use standard functions
- prototype now in include file

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:55:38 +00:00
Peter Wemm
b93e2c954d - prototype now in include file, plus no longer needed anyway
- fix timeout code
- better sequence number generation (for long running daemons)
- dont close an unopen socket
- use standard functions
- 64 bit type safe for wire protocols
- unlimited file descriptors

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:53:20 +00:00
Peter Wemm
fadfbc36c6 - dont close an unopen socket
Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:49:24 +00:00
Peter Wemm
df7da8069f - Don't close an unopened socket
Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:48:28 +00:00
Peter Wemm
ec53c6fa4a - don't close unopen socket
- ensure we're not spoofed/confused while trying to talk to the portmapper
- handle new get_myaddress failure cases
- prototype now in include file

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:46:33 +00:00
Peter Wemm
726212fc09 - missing prototype from include file
- canconical function declaration (ctags safe)
- use standard functions

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:43:42 +00:00
Peter Wemm
e7485a4786 - OpenBSD's strncpy fixes to ensure NULL termination
- missed endrpcent() in some cases.

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:42:31 +00:00
Peter Wemm
5df070f36d - prototypes now in include file
- fix timeout code
- better "random" initial transaction id for long running daemons
- unlimited number of file descriptors to select().
- 64 bit type safe wire protocol
Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.

- typo (spelling police :-)
- dont die on select() that returns time remaining (on my systems)
1996-12-30 14:40:34 +00:00
Peter Wemm
7bdb2acfaa - prototypes now in standard include file
- improve initial "random" sequence number, to make it harder to guess
  in long running daemons.
- fix timeout code.
- unlimited number of fd's in select.
Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.

- Protect against select() that returns time remaining (on my systems).
1996-12-30 14:36:17 +00:00
Peter Wemm
d7c57d7159 - update return type of an "internal but documented" function
- warn about FD_SETSIZE in certain internal functions

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:30:27 +00:00
Peter Wemm
f3c1d59c73 - tags in correct order
- list missing functions
- list missing args

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:28:10 +00:00
Peter Wemm
ad51fb4d83 - canonical function declaration
- don't exit. It's bad form for libc to exit() or abort() instead of
  returning an error.
- only use loopback addresses after checking the real interfaces.

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:26:28 +00:00
Peter Wemm
0ab74c6fd6 - don't close an unopen socket
- canonical function declaration
- use constants from includes, not magic numbers
- use standard functions

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
1996-12-30 14:23:50 +00:00