Stop the tcp_wrappers ident code sending a request which is split

across several packets. This is done by not turning off buffering
on the stdio stream for the ident connection. Originally this was
done to avoid reading back what you'd just written into the buffer.
However ANSI C gives a list of functions which should allow you to
safely change direction on a stdio stream, and Wietse found that
fseek seemed to be the most portable.

The original patch used a different workaround, but this should be
a real fix.

PR:		16086
Reviewed by:	wietse@porcupine.org
(Original version) Approved by:	markm
This commit is contained in:
David Malone 2000-07-14 15:07:37 +00:00
parent 8135b667d1
commit c268f6e47c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=63152

View File

@ -26,6 +26,10 @@ static char sccsid[] = "@(#) rfc931.c 1.10 95/01/02 16:11:34";
#include <signal.h>
#include <string.h>
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
/* Local stuff. */
#include "tcpd.h"
@ -115,13 +119,11 @@ char *dest;
#endif
/*
* Use one unbuffered stdio stream for writing to and for reading from
* the RFC931 etc. server. This is done because of a bug in the SunOS
* 4.1.x stdio library. The bug may live in other stdio implementations,
* too. When we use a single, buffered, bidirectional stdio stream ("r+"
* or "w+" mode) we read our own output. Such behaviour would make sense
* If we use a single, buffered, bidirectional stdio stream ("r+" or
* "w+" mode) we may read our own output. Such behaviour would make sense
* with resources that support random-access operations, but not with
* sockets.
* sockets. ANSI C suggests several functions which can be called when
* you want to change IO direction, fseek seems the most portable.
*/
#ifdef INET6
@ -129,8 +131,6 @@ char *dest;
#else
if ((fp = fsocket(AF_INET, SOCK_STREAM, 0)) != 0) {
#endif
setbuf(fp, (char *) 0);
/*
* Set up a timer so we won't get stuck while waiting for the server.
*/
@ -193,6 +193,7 @@ char *dest;
ntohs(our_sin->sin_port));
#endif
fflush(fp);
fseek(fp, 0, SEEK_SET);
/*
* Read response from server. Use fgets()/sscanf() so we can