summaryrefslogtreecommitdiffstats
path: root/contrib/tcp_wrappers
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2000-07-14 15:07:37 +0000
committerdwmalone <dwmalone@FreeBSD.org>2000-07-14 15:07:37 +0000
commit65587821d3f45cfed345eba4a9a7eef90c3c273e (patch)
treeb95d80629bff5adb1f3f1fc5169674b8411f3bd9 /contrib/tcp_wrappers
parent60096aed79a0b536b5de962ad074ba06c7d97e3e (diff)
downloadFreeBSD-src-65587821d3f45cfed345eba4a9a7eef90c3c273e.zip
FreeBSD-src-65587821d3f45cfed345eba4a9a7eef90c3c273e.tar.gz
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
Diffstat (limited to 'contrib/tcp_wrappers')
-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 c666f58..e7fb3d1 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
OpenPOWER on IntegriCloud