From joost@jodocus.org  Sun Sep  7 20:35:23 2008
Return-Path: <joost@jodocus.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E8E001065686
	for <freebsd-gnats-submit@freebsd.org>; Sun,  7 Sep 2008 20:35:23 +0000 (UTC)
	(envelope-from joost@jodocus.org)
Received: from viefep13-int.chello.at (viefep18-int.chello.at [213.46.255.22])
	by mx1.freebsd.org (Postfix) with ESMTP id 5B6248FC19
	for <freebsd-gnats-submit@freebsd.org>; Sun,  7 Sep 2008 20:35:22 +0000 (UTC)
	(envelope-from joost@jodocus.org)
Received: from edge01.upc.biz ([192.168.13.236]) by viefep15-int.chello.at
          (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP
          id <20080907201926.UZNW13197.viefep15-int.chello.at@edge01.upc.biz>
          for <freebsd-gnats-submit@freebsd.org>;
          Sun, 7 Sep 2008 22:19:26 +0200
Received: from bps.jodocus.org ([62.194.47.110])
	by edge01.upc.biz with edge01
	id BwKD1a00r2NeSae01wKSAP; Sun, 07 Sep 2008 22:19:26 +0200
Received: from jodocus.org (localhost [127.0.0.1])
	by bps.jodocus.org (8.14.2/8.14.2) with ESMTP id m87KJDHS082892
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 7 Sep 2008 22:19:13 +0200 (CEST)
	(envelope-from joost@jodocus.org)
Received: (from joost@localhost)
	by jodocus.org (8.14.2/8.14.2/Submit) id m87KJDl8082891;
	Sun, 7 Sep 2008 22:19:13 +0200 (CEST)
	(envelope-from joost)
Message-Id: <200809072019.m87KJDl8082891@jodocus.org>
Date: Sun, 7 Sep 2008 22:19:13 +0200 (CEST)
From: Joost Bekkers <joost@jodocus.org>
Reply-To: Joost Bekkers <joost@jodocus.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] arpa/telnet.h: TELOPT(x) returns wrong result / segfaults
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         127194
>Category:       bin
>Synopsis:       [patch] telnet(1): arpa/telnet.h: TELOPT(x) returns wrong result / segfaults
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    antoine
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 07 20:40:02 UTC 2008
>Closed-Date:    Sat Jan 10 17:01:09 UTC 2009
>Last-Modified:  Sat Jan 10 17:01:09 UTC 2009
>Originator:     Joost Bekkers
>Release:        FreeBSD 7.0-RELEASE-p4 amd64
>Organization:
>Environment:
System: FreeBSD bps.jodocus.org 7.0-RELEASE-p4 FreeBSD 7.0-RELEASE-p4 #3: Wed Sep 3 23:33:23 CEST 2008 joost@bps.jodocus.org:/usr/src/sys/amd64/compile/bps amd64


>Description:

The telnet options added to src/contrib/telnet/arpa/telnet.h in rev
1.9 (==RELENG_5_2_0_RELEASE==HEAD) were discontinuous, but names
were added to telopts[] without the corresponding gaps. This can cause
TELOPT to return pointers outside of telopts[] even though TELOPT_OK
returns 'true'.



>How-To-Repeat:

#include <stdio.h>
#define TELOPTS
#include <arpa/telnet.h>

int main(int argc,char *argv[]) {
  unsigned int opt;

  opt=TELOPT_KERMIT;
  if (TELOPT_OK(opt)) 
    printf("Option name:%s\n",TELOPT(opt));
  else
    printf("Unknown option %d\n",opt);
  return 0;
}

depending on your luck, this either tells you the option is "(null)" or segfaults.

>Fix:

--- telnet.h.org        2008-09-07 21:45:53.000000000 +0200
+++ telnet.h    2008-09-07 22:12:19.000000000 +0200
@@ -140,8 +140,8 @@
        "TACACS UID", "OUTPUT MARKING", "TTYLOC",
        "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
        "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
-       "ENCRYPT", "NEW-ENVIRON", "TN3270E", "CHARSET", "COM-PORT",
-       "KERMIT",
+       "ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
+       "RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
        0
 };
 #define        TELOPT_FIRST    TELOPT_BINARY


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->antoine 
Responsible-Changed-By: antoine 
Responsible-Changed-When: Wed Sep 10 18:37:35 UTC 2008 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=127194 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/127194: commit references a PR
Date: Sat, 13 Sep 2008 17:48:43 +0000 (UTC)

 antoine     2008-09-13 17:46:50 UTC
 
   FreeBSD src repository
 
   Modified files:
     contrib/telnet/arpa  telnet.h 
     include/arpa         telnet.h 
   Log:
   SVN rev 183004 on 2008-09-13 17:46:50Z by antoine
   
   Fix TELOPT(opt) when opt > TELOPT_TN3270E.
   
   PR:             127194
   Submitted by:   Joost Bekkers
   MFC after:      1 month
   
   Revision  Changes    Path
   1.10      +2 -2      src/contrib/telnet/arpa/telnet.h
   1.10      +2 -2      src/include/arpa/telnet.h
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: antoine 
State-Changed-When: Sat Sep 13 17:52:36 UTC 2008 
State-Changed-Why:  
Patch committed in head. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=127194 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/127194: commit references a PR
Date: Sat, 10 Jan 2009 11:46:07 +0000 (UTC)

 Author: antoine
 Date: Sat Jan 10 11:45:47 2009
 New Revision: 187017
 URL: http://svn.freebsd.org/changeset/base/187017
 
 Log:
   MFC r183004 to stable/7:
     Fix TELOPT(opt) when opt > TELOPT_TN3270E.
   
     PR:		127194
     Submitted by:	Joost Bekkers
     MFC after:	1 month
 
 Modified:
   stable/7/contrib/telnet/   (props changed)
   stable/7/contrib/telnet/arpa/telnet.h
   stable/7/include/   (props changed)
   stable/7/include/arpa/telnet.h
 
 Modified: stable/7/contrib/telnet/arpa/telnet.h
 ==============================================================================
 --- stable/7/contrib/telnet/arpa/telnet.h	Sat Jan 10 10:58:41 2009	(r187016)
 +++ stable/7/contrib/telnet/arpa/telnet.h	Sat Jan 10 11:45:47 2009	(r187017)
 @@ -140,8 +140,8 @@ const char *telopts[NTELOPTS+1] = {
  	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
  	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
  	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
 -	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "CHARSET", "COM-PORT",
 -	"KERMIT",
 +	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
 +	"RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
  	0
  };
  #define	TELOPT_FIRST	TELOPT_BINARY
 
 Modified: stable/7/include/arpa/telnet.h
 ==============================================================================
 --- stable/7/include/arpa/telnet.h	Sat Jan 10 10:58:41 2009	(r187016)
 +++ stable/7/include/arpa/telnet.h	Sat Jan 10 11:45:47 2009	(r187017)
 @@ -140,8 +140,8 @@ const char *telopts[NTELOPTS+1] = {
  	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
  	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
  	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
 -	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "CHARSET", "COM-PORT",
 -	"KERMIT",
 +	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
 +	"RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
  	0
  };
  #define	TELOPT_FIRST	TELOPT_BINARY
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/127194: commit references a PR
Date: Sat, 10 Jan 2009 16:57:35 +0000 (UTC)

 Author: antoine
 Date: Sat Jan 10 16:57:22 2009
 New Revision: 187026
 URL: http://svn.freebsd.org/changeset/base/187026
 
 Log:
   MFC r183004 to stable/6:
     Fix TELOPT(opt) when opt > TELOPT_TN3270E.
   
     PR:		127194
     Submitted by:	Joost Bekkers
     MFC after:	1 month
 
 Modified:
   stable/6/contrib/telnet/   (props changed)
   stable/6/contrib/telnet/arpa/telnet.h
   stable/6/include/   (props changed)
   stable/6/include/arpa/telnet.h
 
 Modified: stable/6/contrib/telnet/arpa/telnet.h
 ==============================================================================
 --- stable/6/contrib/telnet/arpa/telnet.h	Sat Jan 10 16:42:13 2009	(r187025)
 +++ stable/6/contrib/telnet/arpa/telnet.h	Sat Jan 10 16:57:22 2009	(r187026)
 @@ -140,8 +140,8 @@ const char *telopts[NTELOPTS+1] = {
  	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
  	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
  	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
 -	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "CHARSET", "COM-PORT",
 -	"KERMIT",
 +	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
 +	"RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
  	0
  };
  #define	TELOPT_FIRST	TELOPT_BINARY
 
 Modified: stable/6/include/arpa/telnet.h
 ==============================================================================
 --- stable/6/include/arpa/telnet.h	Sat Jan 10 16:42:13 2009	(r187025)
 +++ stable/6/include/arpa/telnet.h	Sat Jan 10 16:57:22 2009	(r187026)
 @@ -140,8 +140,8 @@ const char *telopts[NTELOPTS+1] = {
  	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
  	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
  	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
 -	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "CHARSET", "COM-PORT",
 -	"KERMIT",
 +	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
 +	"RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
  	0
  };
  #define	TELOPT_FIRST	TELOPT_BINARY
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: antoine 
State-Changed-When: Sat Jan 10 17:00:34 UTC 2009 
State-Changed-Why:  
Fixed in head, stable/7 and stable/6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=127194 
>Unformatted:
