Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/rlogin msg:



details:   https://anonhg.NetBSD.org/src/rev/e229dd164f86
branches:  trunk
changeset: 965860:e229dd164f86
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Oct 04 09:01:59 2019 +0000

description:
msg:
avoid passing the same pointer in multiple arguments for restrict
marked arguments:
- sigaction() wants separate in/out
- use memmove() not memcpy() for overlapping regions (this may fix
  a real bug in nvi -- but it seems unlikely)
- select() wants separate read/write/except
- sigprocmask() wants separate set/oset

diffstat:

 external/bsd/am-utils/dist/amd/info_ldap.c |  12 ++++----
 external/bsd/nvi/dist/common/options.c     |   6 ++--
 external/bsd/ppp/usr.sbin/pppd/sys-bsd.c   |   5 ++-
 tests/lib/librumphijack/h_client.c         |  10 ++++---
 usr.bin/rlogin/rlogin.c                    |  40 +++++++++++++++---------------
 5 files changed, 38 insertions(+), 35 deletions(-)

diffs (201 lines):

diff -r 38c323efb75f -r e229dd164f86 external/bsd/am-utils/dist/amd/info_ldap.c
--- a/external/bsd/am-utils/dist/amd/info_ldap.c        Fri Oct 04 08:57:37 2019 +0000
+++ b/external/bsd/am-utils/dist/amd/info_ldap.c        Fri Oct 04 09:01:59 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: info_ldap.c,v 1.2 2015/08/28 11:38:57 joerg Exp $      */
+/*     $NetBSD: info_ldap.c,v 1.3 2019/10/04 09:01:59 mrg Exp $        */
 
 /*
  * Copyright (c) 1997-2014 Erez Zadok
@@ -197,7 +197,7 @@
 {
   int e;
 #ifdef HAVE_SIGACTION
-  struct sigaction sa;
+  struct sigaction sa, osa;
 #else /* not HAVE_SIGACTION */
   void (*handler)(int);
 #endif /* not HAVE_SIGACTION */
@@ -209,7 +209,7 @@
   sa.sa_flags = 0;
   sigemptyset(&(sa.sa_mask));
   sigaddset(&(sa.sa_mask), SIGPIPE);
-  sigaction(SIGPIPE, &sa, &sa);        /* set IGNORE, and get old action */
+  sigaction(SIGPIPE, &sa, &osa);       /* set IGNORE, and get old action */
 #else /* not HAVE_SIGACTION */
   handler = signal(SIGPIPE, SIG_IGN);
 #endif /* not HAVE_SIGACTION */
@@ -217,9 +217,9 @@
   e = ldap_unbind(ld);
 
 #ifdef HAVE_SIGACTION
-  sigemptyset(&(sa.sa_mask));
-  sigaddset(&(sa.sa_mask), SIGPIPE);
-  sigaction(SIGPIPE, &sa, NULL);
+  sigemptyset(&(osa.sa_mask));
+  sigaddset(&(osa.sa_mask), SIGPIPE);
+  sigaction(SIGPIPE, &osa, NULL);
 #else /* not HAVE_SIGACTION */
   (void) signal(SIGPIPE, handler);
 #endif /* not HAVE_SIGACTION */
diff -r 38c323efb75f -r e229dd164f86 external/bsd/nvi/dist/common/options.c
--- a/external/bsd/nvi/dist/common/options.c    Fri Oct 04 08:57:37 2019 +0000
+++ b/external/bsd/nvi/dist/common/options.c    Fri Oct 04 09:01:59 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.c,v 1.6 2018/08/07 08:05:47 rin Exp $ */
+/*     $NetBSD: options.c,v 1.7 2019/10/04 09:01:59 mrg Exp $ */
 /*-
  * Copyright (c) 1991, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: options.c,v 10.65 2002/01/18 22:34:43 skimo Exp  (Berkeley) Date: 2002/01/18 22:34:43 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: options.c,v 1.6 2018/08/07 08:05:47 rin Exp $");
+__RCSID("$NetBSD: options.c,v 1.7 2019/10/04 09:01:59 mrg Exp $");
 #endif
 
 #include <sys/types.h>
@@ -356,7 +356,7 @@
 #define        OI(indx, str) {                                                 \
        a.len = STRLEN(str);                                            \
        if ((const CHAR_T*)str != b2)/* GCC puts strings in text-space. */\
-               (void)MEMCPY(b2, str, a.len+1);                         \
+               (void)MEMMOVE(b2, str, a.len+1);                        \
        if (opts_set(sp, argv, NULL)) {                                 \
                 optindx = indx;                                        \
                goto err;                                               \
diff -r 38c323efb75f -r e229dd164f86 external/bsd/ppp/usr.sbin/pppd/sys-bsd.c
--- a/external/bsd/ppp/usr.sbin/pppd/sys-bsd.c  Fri Oct 04 08:57:37 2019 +0000
+++ b/external/bsd/ppp/usr.sbin/pppd/sys-bsd.c  Fri Oct 04 09:01:59 2019 +0000
@@ -1045,11 +1045,12 @@
 void
 wait_input(struct timeval *timo)
 {
-    fd_set ready;
+    fd_set ready, eready;
     int n;
 
     ready = in_fds;
-    n = select(max_in_fd + 1, &ready, NULL, &ready, timo);
+    eready = in_fds;
+    n = select(max_in_fd + 1, &ready, NULL, &eready, timo);
     if (n < 0 && errno != EINTR)
        fatal("%s: select: %m", __func__);
 }
diff -r 38c323efb75f -r e229dd164f86 tests/lib/librumphijack/h_client.c
--- a/tests/lib/librumphijack/h_client.c        Fri Oct 04 08:57:37 2019 +0000
+++ b/tests/lib/librumphijack/h_client.c        Fri Oct 04 09:01:59 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: h_client.c,v 1.8 2012/04/20 05:15:11 jruoho Exp $      */
+/*     $NetBSD: h_client.c,v 1.9 2019/10/04 09:02:00 mrg Exp $ */
 
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -71,16 +71,18 @@
                        errx(EXIT_FAILURE, "stdin fileno is still set");
                return EXIT_SUCCESS;
        } else if (strcmp(argv[1], "select_allunset") == 0) {
-               fd_set fds;
+               fd_set rfds, wfds, efds;
                struct timeval tv;
                int rv;
 
                tv.tv_sec = 0;
                tv.tv_usec = 1;
 
-               FD_ZERO(&fds);
+               FD_ZERO(&rfds);
+               FD_ZERO(&wfds);
+               FD_ZERO(&efds);
 
-               rv = select(100, &fds, &fds, &fds, &tv);
+               rv = select(100, &rfds, &wfds, &efds, &tv);
                if (rv == -1)
                        err(EXIT_FAILURE, "select");
                if (rv != 0)
diff -r 38c323efb75f -r e229dd164f86 usr.bin/rlogin/rlogin.c
--- a/usr.bin/rlogin/rlogin.c   Fri Oct 04 08:57:37 2019 +0000
+++ b/usr.bin/rlogin/rlogin.c   Fri Oct 04 09:01:59 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rlogin.c,v 1.44 2015/10/28 08:15:53 shm Exp $  */
+/*     $NetBSD: rlogin.c,v 1.45 2019/10/04 09:02:00 mrg Exp $  */
 
 /*
  * Copyright (c) 1983, 1990, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)rlogin.c   8.4 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: rlogin.c,v 1.44 2015/10/28 08:15:53 shm Exp $");
+__RCSID("$NetBSD: rlogin.c,v 1.45 2019/10/04 09:02:00 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -132,7 +132,7 @@
        struct passwd *pw;
        struct servent *sp;
        struct termios tty;
-       sigset_t smask;
+       sigset_t imask, omask;
        uid_t uid;
        int argoff, ch, dflag, nflag, one;
        int i, len, len2;
@@ -247,10 +247,10 @@
        sa.sa_handler = lostpeer;
        (void)sigaction(SIGPIPE, &sa, (struct sigaction *)0);
        /* will use SIGUSR1 for window size hack, so hold it off */
-       sigemptyset(&smask);
-       sigaddset(&smask, SIGURG);
-       sigaddset(&smask, SIGUSR1);
-       (void)sigprocmask(SIG_SETMASK, &smask, &smask);
+       sigemptyset(&imask);
+       sigaddset(&imask, SIGURG);
+       sigaddset(&imask, SIGUSR1);
+       (void)sigprocmask(SIG_SETMASK, &imask, &omask);
        /*
         * We set SIGURG and SIGUSR1 below so that an
         * incoming signal will be held pending rather than being
@@ -291,7 +291,7 @@
        }
 
        (void)setuid(uid);
-       doit(&smask);
+       doit(&omask);
        /*NOTREACHED*/
        return (0);
 }
@@ -345,21 +345,21 @@
 static void
 setsignal(int sig)
 {
-       struct sigaction sa;
-       sigset_t sigs;
+       struct sigaction isa, osa;
+       sigset_t isigs, osigs;
 
-       sigemptyset(&sigs);
-       sigaddset(&sigs, sig);
-       sigprocmask(SIG_BLOCK, &sigs, &sigs);
+       sigemptyset(&isigs);
+       sigaddset(&isigs, sig);
+       sigprocmask(SIG_BLOCK, &isigs, &osigs);
 
-       sigemptyset(&sa.sa_mask);
-       sa.sa_handler = exit;
-       sa.sa_flags = SA_RESTART;
-       (void)sigaction(sig, &sa, &sa);
-       if (sa.sa_handler == SIG_IGN)
-               (void)sigaction(sig, &sa, (struct sigaction *) 0);
+       sigemptyset(&isa.sa_mask);
+       isa.sa_handler = exit;
+       isa.sa_flags = SA_RESTART;
+       (void)sigaction(sig, &isa, &osa);
+       if (osa.sa_handler == SIG_IGN)
+               (void)sigaction(sig, &osa, (struct sigaction *) 0);
 
-       (void)sigprocmask(SIG_SETMASK, &sigs, (sigset_t *) 0);
+       (void)sigprocmask(SIG_SETMASK, &osigs, (sigset_t *) 0);
 }
 
 static void



Home | Main Index | Thread Index | Old Index