Subject: pppd2.2.0f Patch (fwd)

From: Ricardo Kleemann <[email-masked]>
Date: Tue, 6 Aug 1996 07:11:26 -0700 (PDT)

Guys... saw this in linux-ppp mailing list... Has this patch been 
incorporated into the debian pppd??

---------- Forwarded message ----------
Date: Mon, 05 Aug 1996 19:58:33 +0200
From: Michael Lausch <[email-masked]>
To: [email-masked]
Subject: pppd2.2.0f Patch 

This is a patch which removes an error when using Linux as a server
and Windows for Workgroups as a client with PAP authorization.

Forwarded: Mon, 05 Aug 1996 17:57:13 +0200
Forwarded: [email-masked]
Forwarded: [email-masked]
Replied: Thu, 01 Aug 1996 10:53:49 +0200
Replied: [email-masked]
Replied: Wed, 24 Jul 1996 08:18:57 +0200
Replied: [email-masked]
>>From [email-masked]  Wed Jul 24 02:36:19 1996
Date: Wed, 24 Jul 1996 10:35:29 +1000
From: Paul Mackerras <[email-masked]>
To: [email-masked]
Subject: Re: FW: pppd2.0.2f and Trumpet Winsock
Reply-to: [email-masked]

> You get more then requested :-). I'm including the whole debug trace.
> It's MIME encoded to preserve formatting.

Oops, looks like the NAK from Trumpet was perfectly OK, and the bug is
in pppd.  This is something I fixed a little while ago in ppp-2.3,
which is only in alpha release as yet, and its linux port needs some
more work.  So I've tried to isolate the necessary changes to
pppd/lcp.c and put them into the ppp-2.2.0f source.  I've included the
patch below.  Let me know if it works.

Paul.

--- lcp.c.orig	Wed Dec 27 13:25:51 1995
+++ lcp.c	Wed Jul 24 10:30:17 1996
@@ -792,19 +792,22 @@
      */
     if ((go->neg_chap || go->neg_upap)
 	&& len >= CILEN_SHORT
-	&& p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT) {
+	&& p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) {
 	cilen = p[1];
+	len -= cilen;
+	no.neg_chap = go->neg_chap;
+	no.neg_upap = go->neg_upap;
 	INCPTR(2, p);
         GETSHORT(cishort, p);
 	if (cishort == PPP_PAP && cilen == CILEN_SHORT) {
 	    /*
-	     * If they are asking for PAP, then they don't want to do CHAP.
+	     * If we were asking for CHAP, they obviously don't want to do it.
 	     * If we weren't asking for CHAP, then we were asking for PAP,
 	     * in which case this Nak is bad.
 	     */
 	    if (!go->neg_chap)
 		goto bad;
-	    go->neg_chap = 0;
+	    try.neg_chap = 0;
 
 	} else if (cishort == PPP_CHAP && cilen == CILEN_CHAP) {
 	    GETCHAR(cichar, p);
@@ -822,7 +825,7 @@
 		/*
 		 * Stop asking for PAP if we were asking for it.
 		 */
-		go->neg_upap = 0;
+		try.neg_upap = 0;
 	    }
 
 	} else {
@@ -831,25 +834,14 @@
 	     * Stop asking for what we were asking for.
 	     */
 	    if (go->neg_chap)
-		go->neg_chap = 0;
+		try.neg_chap = 0;
 	    else
-		go->neg_upap = 0;
+		try.neg_upap = 0;
 	    p += cilen - CILEN_SHORT;
 	}
     }
 
     /*
-     * Peer shouldn't send Nak for protocol compression or
-     * address/control compression requests; they should send
-     * a Reject instead.  If they send a Nak, treat it as a Reject.
-     */
-    if (!go->neg_chap ){
-	NAKCISHORT(CI_AUTHTYPE, neg_upap,
-		   try.neg_upap = 0;
-		   );
-    }
-
-    /*
      * If they can't cope with our link quality protocol, we'll have
      * to stop asking for LQR.  We haven't got any other protocol.
      * If they Nak the reporting period, take their value XXX ?
@@ -869,6 +861,11 @@
 	      looped_back = 1;
 	      );
 
+    /*
+     * Peer shouldn't send Nak for protocol compression or
+     * address/control compression requests; they should send
+     * a Reject instead.  If they send a Nak, treat it as a Reject.
+     */
     NAKCIVOID(CI_PCOMPRESSION, neg_pcompression,
 	      try.neg_pcompression = 0;
 	      );
@@ -895,7 +892,7 @@
     while (len > CILEN_VOID) {
 	GETCHAR(citype, p);
 	GETCHAR(cilen, p);
-	if ((len -= cilen) < 0)
+	if (cilen < CILEN_VOID || (len -= cilen) < 0)
 	    goto bad;
 	next = p + cilen - 2;
 
@@ -903,6 +900,9 @@
 	case CI_MRU:
 	    if (go->neg_mru || no.neg_mru || cilen != CILEN_SHORT)
 		goto bad;
+	    GETSHORT(cishort, p);
+	    if (cishort < DEFMRU)
+		try.mru = cishort;
 	    break;
 	case CI_ASYNCMAP:
 	    if (go->neg_asyncmap || no.neg_asyncmap || cilen != CILEN_LONG)
@@ -1141,6 +1141,7 @@
 	    orc = CONFREJ;		/* Reject bad CI */
 	    cilen = l;			/* Reject till end of packet */
 	    l = 0;			/* Don't loop again */
+	    citype = 0;
 	    goto endswitch;
 	}
 	GETCHAR(citype, p);		/* Parse CI type */

---
sysadm of g.a.m.s. edv dienstleistungen gmbh
finger [email-masked] for PGP key
<http://www.gams.at/~mla>