freebsd-nq/usr.sbin/ypserv
Bill Paul 9ecc3726d9 Fix a very stupid heap corruption bug: in ypproc_match_2_svc(), when
we decide to do a DNS lookup, we NUL terminate the key string provided
by the client before passing it into the DNS lookup module. This is
actually wrong. Assume the key is 'foo.com'. In this case, key.keydat_val
will be "foo.com" and key.keydat_len will be 7 (seven characters; the
string is not NUL-terminated so it is not 8 as you might expect).
The string "foo.com" is actually allocated by the XDR routines when the
RPC request is decoded; exactly 7 bytes are allocated. By adding a NUL,
the string becomes "foo.com\0", but the '\0' goes into an 8th byte which
was never allocated for this string and which could be anywhere. The result
is that while the initial request may succeed, we could trash other
dynamically allocated structures (like, oh, I dunno, the circular map
cache queue?) and SEGV later. This is in fact what happens.

The fix is to copy the string into a larger local buffer and NUL-terminate
that buffer instead.

Crash first reported by: Ricky Chan <ricky@come.net.uk>
Bug finally located with: Electric Fence 2.0.5
1997-07-21 17:39:39 +00:00
..
Makefile Revert $FreeBSD$ to $Id$ 1997-02-22 16:15:28 +00:00
Makefile.yp Revert $FreeBSD$ to $Id$ 1997-02-22 16:15:28 +00:00
yp_access.c Revert $FreeBSD$ to $Id$ 1997-02-22 16:15:28 +00:00
yp_dblookup.c Revert $FreeBSD$ to $Id$ 1997-02-22 16:15:28 +00:00
yp_dnslookup.c Revert $FreeBSD$ to $Id$ 1997-02-22 16:15:28 +00:00
yp_error.c Revert $FreeBSD$ to $Id$ 1997-02-22 16:15:28 +00:00
yp_extern.h Revert $FreeBSD$ to $Id$ 1997-02-22 16:15:28 +00:00
yp_main.c compare return value from getopt against -1 rather than EOF, per the final 1997-03-31 05:11:47 +00:00
yp_server.c Fix a very stupid heap corruption bug: in ypproc_match_2_svc(), when 1997-07-21 17:39:39 +00:00
yp_svc_udp.c Revert $FreeBSD$ to $Id$ 1997-02-22 16:15:28 +00:00
ypserv.8 fix some typos, and some slight clean up... 1997-04-15 07:41:10 +00:00