aboutsummaryrefslogtreecommitdiff
path: root/contrib/tcp_wrappers/rfc931.c
diff options
context:
space:
mode:
authorDavid Malone <dwmalone@FreeBSD.org>2000-07-14 15:07:37 +0000
committerDavid Malone <dwmalone@FreeBSD.org>2000-07-14 15:07:37 +0000
commitc268f6e47c59d80b0107f96ded36ca146a17c6be (patch)
treeaf5adf1c703ed93c740b1970d854bad1c915d51c /contrib/tcp_wrappers/rfc931.c
parent8135b667d10c937cd6ccd049ebb53b3154d49398 (diff)
downloadsrc-c268f6e47c59d80b0107f96ded36ca146a17c6be.tar.gz
src-c268f6e47c59d80b0107f96ded36ca146a17c6be.zip
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
Notes
Notes: svn path=/head/; revision=63152
Diffstat (limited to 'contrib/tcp_wrappers/rfc931.c')
-rw-r--r--contrib/tcp_wrappers/rfc931.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/contrib/tcp_wrappers/rfc931.c b/contrib/tcp_wrappers/rfc931.c
index c666f58f29ca..e7fb3d1d1294 100644
--- a/contrib/tcp_wrappers/rfc931.c
+++ b/contrib/tcp_wrappers/rfc931.c
@@ -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