From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-relay-01-2.dondominio.net ([31.214.176.25]) by ur; Tue Mar 15 14:38:18 EDT 2016 Received: from mail-node.dondominio.com by smtp-relay.dondominio.com (Postfix) with ESMTP id EE94A42253 for <9front@9front.org>; Tue, 15 Mar 2016 19:37:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shike2.com; s=dddk; t=1458067064; bh=RpRSTU+KDOZAqIag2dzSsn4udpbE9m4FijzUqS4fraY=; h=Message-ID:To:Subject:Date:From:Content-Type; b=IJt28FyMUA0J2SzS7TzqZSsTEQAHN/GgBhyCZ8zy3xrfJ4AFidbBYgZt+SvH6C926 RvXpp6BoxKBnxDBwfHxUBEGDSLgrX5wdZIj2N66ZH0X8Tf3YgRjasBpIwAuPKR1iEZ d8JvJu/n/Qit9eCXqQGVNMgD5z21pCbpXEp8mrH4= Received: by mail-node.dondominio.com (Postfix, from userid 4000) id EBBA04204D; Tue, 15 Mar 2016 19:37:44 +0100 (CET) Received: from hal9000 (87.177.216.87.static.jazztel.es [87.216.177.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: k0ga@shike2.com) by mail-node.dondominio.com (Postfix) with ESMTPSA id 068B041D27 for <9front@9front.org>; Tue, 15 Mar 2016 19:37:43 +0100 (CET) Message-ID: <97ab192120fc1d85f999e195e39d29fd@shike2.com> To: 9front@9front.org Subject: Patches for ppp and pppoe Date: Tue, 15 Mar 2016 19:37:42 +0100 From: k0ga@shike2.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-lclugntuucxzhqwydkkunylnyn" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (mail-node.dondominio.com [0.0.0.0]); Tue, 15 Mar 2016 19:37:44 +0100 (CET) List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: agile abstract app This is a multi-part message in MIME format. --upas-lclugntuucxzhqwydkkunylnyn Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Hi, I had some problems setting my pppoe connection with my ISP, and in the process I discovered a few things in the code of ppp and pppoe. I attach 5 patches to this mail: p1.patch: Add support for -c and -C in pppoe p2.patch: Do not request encriptation with -c or -C in ppp (it was a bit annoying request compression, and when the ACK from the server was received then send a NAK). p3.patch: Add support for md5 and mschap in in chap (without this patch ppp was passing to the net stage without worring about chap). p4.patch: Small format and log fixes p5.patch: Avoid buffer overflow in ppp (ppp->secret comes from factotum and it can have any size) This patch also sets the correct state after success and failure cases in chap negotiation (without them the code was working because it expected the other point to pass to net phase or due to the timer). Regard, --upas-lclugntuucxzhqwydkkunylnyn Content-Disposition: attachment; filename=p1.patch Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit diff -r 94844cc7f1fd -r 3e63050481a8 sys/man/8/ppp --- a/sys/man/8/ppp Tue Mar 01 21:27:37 2016 -0500 +++ b/sys/man/8/ppp Sat Mar 05 07:44:02 2016 +0100 @@ -34,7 +34,7 @@ .PP .B ip/pppoe [ -.B -Pd +.B -PdcC ] [ .B -A diff -r 94844cc7f1fd -r 3e63050481a8 sys/src/cmd/ip/pppoe.c --- a/sys/src/cmd/ip/pppoe.c Tue Mar 01 21:27:37 2016 -0500 +++ b/sys/src/cmd/ip/pppoe.c Sat Mar 05 07:44:02 2016 +0100 @@ -28,11 +28,12 @@ int cookielen; uchar etherdst[6]; int mtu = 1492; +int pktcompress, hdrcompress; void usage(void) { - fprint(2, "usage: pppoe [-Pd] [-A acname] [-S srvname] [-k keyspec] [-m mtu] [-x pppnet] [ether0]\n"); + fprint(2, "usage: pppoe [-PdcC] [-A acname] [-S srvname] [-k keyspec] [-m mtu] [-x pppnet] [ether0]\n"); exits("usage"); } @@ -75,6 +76,12 @@ case 'k': keyspec = EARGF(usage()); break; + case 'c': + pktcompress = 1; + break; + case 'C': + hdrcompress = 1; + break; case 'x': pppnetmtpt = EARGF(usage()); break; @@ -526,6 +533,10 @@ argv[argc++] = "-d"; if(primary) argv[argc++] = "-P"; + if(hdrcompress) + argv[argc++] = "-C"; + if(pktcompress) + argv[argc++] = "-c"; if(pppnetmtpt){ argv[argc++] = "-x"; argv[argc++] = pppnetmtpt; --upas-lclugntuucxzhqwydkkunylnyn Content-Disposition: attachment; filename=p2.patch Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit diff -r 3e63050481a8 sys/src/cmd/ip/ppp/ppp.c --- a/sys/src/cmd/ip/ppp/ppp.c Sat Mar 05 07:44:02 2016 +0100 +++ b/sys/src/cmd/ip/ppp/ppp.c Sat Mar 05 07:47:52 2016 +0100 @@ -276,7 +276,14 @@ ppp->rctlmap = 0; ppp->ipcp->state = Sclosed; ppp->ipcp->optmask = 0xffffffff; - + if(noipcompress) { + p->optmask &= ~Fac; + ppp->ipcp->optmask &= ~Fipaddrs; + } + if(nocompress) { + p->optmask &= ~Fpc; + ppp->ipcp->optmask &= ~Fipcompress; + } p->echotimeout = 0; /* quality goo */ --upas-lclugntuucxzhqwydkkunylnyn Content-Disposition: attachment; filename=p3.patch Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit diff -r 3e63050481a8 sys/src/cmd/ip/ppp/ppp.c --- a/sys/src/cmd/ip/ppp/ppp.c Sat Mar 05 07:44:02 2016 +0100 +++ b/sys/src/cmd/ip/ppp/ppp.c Mon Mar 14 23:36:40 2016 +0100 @@ -243,12 +244,21 @@ } break; case Pauth: - if(server) + if(server) { chapinit(ppp); - else if(ppp->chap->proto == APpasswd) - papinit(ppp); - else - setphase(ppp, Pnet); + } else { + switch (ppp->chap->proto) { + case APpasswd: + papinit(ppp); + break; + case APmd5: + case APmschap: + break; + default: + setphase(ppp, Pnet); + break; + } + } break; case Pnet: pinit(ppp, ppp->ccp); --upas-lclugntuucxzhqwydkkunylnyn Content-Disposition: attachment; filename=p4.patch Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit diff -r 3e63050481a8 sys/src/cmd/ip/ppp/ppp.c --- a/sys/src/cmd/ip/ppp/ppp.c Sat Mar 05 07:44:02 2016 +0100 +++ b/sys/src/cmd/ip/ppp/ppp.c Mon Mar 14 23:36:40 2016 +0100 @@ -693,10 +709,10 @@ } break; case Pipcp: - if(p->optmask & Fipaddr) -{syslog(0, "ppp", "requesting %I", ppp->local); + if(p->optmask & Fipaddr){ + syslog(0, "ppp", "requesting %I", ppp->local); putv4o(b, Oipaddr, ppp->local); -} + } if(primary && (p->optmask & Fipdns)) putv4o(b, Oipdns, ppp->dns[0]); if(primary && (p->optmask & Fipdns2)) @@ -1350,7 +1366,7 @@ break; case Lprotorej: proto = nhgets(m->data); - netlog("ppp: proto reject %ux", proto); + netlog("ppp: proto reject %ux\n", proto); if(proto == Pccp) newstate(ppp, ppp->ccp, Sclosed); break; --upas-lclugntuucxzhqwydkkunylnyn Content-Disposition: attachment; filename=p5.patch Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit diff -r 3e63050481a8 sys/src/cmd/ip/ppp/ppp.c --- a/sys/src/cmd/ip/ppp/ppp.c Sat Mar 05 07:44:02 2016 +0100 +++ b/sys/src/cmd/ip/ppp/ppp.c Mon Mar 14 23:36:40 2016 +0100 @@ -2081,18 +2097,23 @@ netlog("PPP: chap: bad challenge len\n"); break; } id = m->id; switch(ppp->chap->proto){ default: abort(); case APmd5: + n = strlen(ppp->secret); + if(n + vlen + 1 > sizeof(md5buf)) { + netlog("PPP: chap: bad challenge len\n"); + goto end; + } md5buf[0] = m->id; - strcpy(md5buf+1, ppp->secret); - n = strlen(ppp->secret) + 1; - memmove(md5buf+n, m->data+1, vlen); - n += vlen; - md5((uchar*)md5buf, n, digest, nil); + memcpy(md5buf+1, ppp->secret, n); + memcpy(md5buf+1+n, m->data+1, vlen); + md5((uchar*)md5buf, n + vlen + 1, digest, nil); resp = digest; nresp = 16; break; @@ -2213,14 +2234,17 @@ break; case Csuccess: netlog("ppp: chap succeeded\n"); + setphase(ppp, Pnet); break; case Cfailure: netlog("ppp: chap failed\n"); + terminate(ppp, 0); break; default: syslog(0, LOG, "chap code %d?", m->code); break; } +end: qunlock(ppp); freeb(b); } --upas-lclugntuucxzhqwydkkunylnyn--