Source-Changes-HG archive

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

[src/netbsd-2]: src/sys/net Pull up following revision(s) (requested by marti...



details:   https://anonhg.NetBSD.org/src/rev/874fba2aedd1
branches:  netbsd-2
changeset: 564419:874fba2aedd1
user:      tron <tron%NetBSD.org@localhost>
date:      Wed Feb 01 20:51:20 2006 +0000

description:
Pull up following revision(s) (requested by martin in ticket #10239):
        sys/net/if_pppoe.c: revision 1.64
Make sure error messages (received from the access concentrator) are
zero terminated.

diffstat:

 sys/net/if_pppoe.c |  34 ++++++++++++++++++++++------------
 1 files changed, 22 insertions(+), 12 deletions(-)

diffs (87 lines):

diff -r ac53c4dc0dd9 -r 874fba2aedd1 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c        Mon Jan 30 14:49:44 2006 +0000
+++ b/sys/net/if_pppoe.c        Wed Feb 01 20:51:20 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.51 2003/11/28 08:56:48 keihan Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.51.4.1 2006/02/01 20:51:20 tron Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.51 2003/11/28 08:56:48 keihan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.51.4.1 2006/02/01 20:51:20 tron Exp $");
 
 #include "pppoe.h"
 #include "bpfilter.h"
@@ -399,7 +399,8 @@
        u_int16_t tag, len;
        u_int16_t session, plen;
        struct pppoe_softc *sc;
-       const char *err_msg, *err_txt;
+       const char *err_msg, *devname;
+       char *error;
        u_int8_t *ac_cookie;
        size_t ac_cookie_len;
 #ifdef PPPOE_SERVER
@@ -412,7 +413,8 @@
        int noff, err, errortag;
        struct ether_header *eh;
 
-       err_msg = err_txt = NULL;
+       devname = "pppoe";      /* as long as we don't know which instance */
+       err_msg = NULL;
        errortag = 0;
        if (m->m_len < sizeof(*eh)) {
                m = m_pullup(m, sizeof(*eh));
@@ -462,8 +464,7 @@
        while (off + sizeof(*pt) <= m->m_pkthdr.len) {
                n = m_pulldown(m, off, sizeof(*pt), &noff);
                if (!n) {
-                       printf("%s: parse error\n",
-                           sc ? sc->sc_sppp.pp_if.if_xname : "pppoe");
+                       printf("%s: parse error\n", devname);
                        m = NULL;
                        goto done;
                }
@@ -497,6 +498,8 @@
 #endif
                        sc = pppoe_find_softc_by_hunique(mtod(n, caddr_t) + noff,
                            len, m->m_pkthdr.rcvif);
+                       if (sc != NULL)
+                               devname = sc->sc_sppp.pp_if.if_xname;
                        break;
                case PPPOE_TAG_ACCOOKIE:
                        if (ac_cookie == NULL) {
@@ -525,16 +528,23 @@
                        break;
                }
                if (err_msg) {
-                       err_txt = "";
+                       error = NULL;
                        if (errortag && len) {
+                               error = malloc(len+1, M_TEMP, M_NOWAIT);
                                n = m_pulldown(m, off + sizeof(*pt), len,
                                    &noff);
-                               if (n)
-                                       err_txt = mtod(n, caddr_t) + noff;
+                               if (n && error) {
+                                       strncpy(error, 
+                                           mtod(n, caddr_t) + noff, len);
+                                       error[len-1] = '\0';
+                               }
                        }
-                       printf("%s: %s: %*s\n",
-                           sc ? sc->sc_sppp.pp_if.if_xname : "pppoe*",
-                           err_msg, len, err_txt);
+                       if (error) {
+                               printf("%s: %s: %s\n", devname,
+                                   err_msg, error);
+                               free(error, M_TEMP);
+                       } else
+                               printf("%s: %s\n", devname, err_msg);
                        if (errortag)
                                goto done;
                }



Home | Main Index | Thread Index | Old Index