Subject: bin/10938: kpasswd crashes on machine w/o Kerberos
To: None <gnats-bugs@gnats.netbsd.org>
From: Dave Huang <khym@bga.com>
List: netbsd-bugs
Date: 09/02/2000 19:27:14
>Number:         10938
>Category:       bin
>Synopsis:       kpasswd crashes on machine w/o Kerberos
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 02 19:28:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Dave Huang
>Release:        NetBSD-1.5_ALPHA2 as of September 1, 2000
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 24 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Environment:
	
System: NetBSD yerfable.metonymy.com 1.5_ALPHA2 NetBSD 1.5_ALPHA2 (YERFABLE) #107: Thu Aug 31 02:43:29 CDT 2000 khym@yerfable.metonymy.com:/usr/src.local/sys/arch/alpha/compile/YERFABLE alpha
NetBSD dahan.metonymy.com 1.5_ALPHA2 NetBSD 1.5_ALPHA2 (SPIFF) #338: Fri Aug 25 06:21:24 CDT 2000     khym@dahan.metonymy.com:/usr/src.local/sys/arch/i386/compile/SPIFF i386


>Description:
	kpasswd crashes with a segmentation fault when run on a
machine that doesn't have Kerberos configured.
>How-To-Repeat:
GNU gdb 4.17
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "alpha--netbsd"...
(gdb) run
Starting program: /usr/src.local/usr.bin/kpasswd/obj.alpha/kpasswd

Program received signal SIGSEGV, Segmentation fault.
0x16069d310 in com_right ()
(gdb) where
#0  0x16069d310 in com_right ()
#1  0x16023e1a4 in krb5_get_err_text ()
#2  0x1200014dc in main (argc=0, argv=0x1fffff5c0)
    at /usr/src.local/usr.bin/kpasswd/../../crypto/dist/heimdal/kpasswd/kpasswd.c:93
>Fix:
I don't know... krb5_init_context() is failing, so krb5_get_err_text()
is called to get a description of the error. context isn't set to
anything, and being an automatic variable, contains junk, which
krb5_get_err_text() doesn't like.

Perhaps krb5_init_context() should set context to NULL if it fails
early on, and krb5_get_err_text() should skip the com_right() business
if context is NULL? I.e. something to the effect of this (but I don't
know what the API says these functions are supposed to do...)

--- /usr/src/crypto/dist/heimdal/lib/krb5/context.c	Sat Sep  2 21:07:50 2000
+++ context.c	Sat Sep  2 21:18:28 2000
@@ -162,6 +162,7 @@
     krb5_config_section *tmp_cf;
     krb5_error_code ret;
 
+    *context = NULL;
     ALLOC(p, 1);
     if(!p)
 	return ENOMEM;
@@ -280,7 +281,7 @@
 const char *
 krb5_get_err_text(krb5_context context, krb5_error_code code)
 {
-    const char *p = com_right(context->et_list, code);
+    const char *p = context != NULL ? com_right(context->et_list, code) : NULL;
     if(p == NULL)
 	p = strerror(code);
     return p;

>Release-Note:
>Audit-Trail:
>Unformatted: