Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/ftp if getsockopt() returns a buffer size of <= 0, s...



details:   https://anonhg.NetBSD.org/src/rev/ac51dbba3a2c
branches:  trunk
changeset: 476666:ac51dbba3a2c
user:      lukem <lukem%NetBSD.org@localhost>
date:      Fri Sep 24 06:14:40 1999 +0000

description:
if getsockopt() returns a buffer size of <= 0, set them to 8192.
this works around a problem in certain OS from Sun with a version < 5.6...

diffstat:

 usr.bin/ftp/main.c |  19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diffs (44 lines):

diff -r c0747387f5d0 -r ac51dbba3a2c usr.bin/ftp/main.c
--- a/usr.bin/ftp/main.c        Fri Sep 24 05:35:09 1999 +0000
+++ b/usr.bin/ftp/main.c        Fri Sep 24 06:14:40 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.50 1999/09/22 07:18:36 lukem Exp $  */
+/*     $NetBSD: main.c,v 1.51 1999/09/24 06:14:40 lukem Exp $  */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -72,7 +72,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.50 1999/09/22 07:18:36 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.51 1999/09/24 06:14:40 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -158,15 +158,20 @@
        s = socket(AF_INET, SOCK_STREAM, 0);
        if (s == -1)
                err(1, "can't create socket");
+       len = sizeof(rcvbuf_size);
+       if (getsockopt(s, SOL_SOCKET, SO_RCVBUF, (void *) &rcvbuf_size, &len)
+           < 0)
+               err(1, "unable to get default rcvbuf size");
        len = sizeof(sndbuf_size);
        if (getsockopt(s, SOL_SOCKET, SO_SNDBUF, (void *) &sndbuf_size, &len)
            < 0)
                err(1, "unable to get default sndbuf size");
-       len = sizeof(rcvbuf_size);
-       if (getsockopt(s, SOL_SOCKET, SO_RCVBUF, (void *) &rcvbuf_size, &len)
-           < 0)
-               err(1, "unable to get default rcvbuf size");
-       close(s);
+       (void)close(s);
+                                       /* sanity check returned buffer sizes */
+       if (rcvbuf_size <= 0)
+               rcvbuf_size = 8192;
+       if (sndbuf_size <= 0)
+               sndbuf_size = 8192;
 
        marg_sl = sl_init();
        if ((tmpdir = getenv("TMPDIR")) == NULL)



Home | Main Index | Thread Index | Old Index