Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Mar 2001 17:38:40 -0800 (PST)
From:      Bill Fenner <fenner@research.att.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/25886: cgetset(3) doesn't get cleared when switching databases
Message-ID:  <200103180138.f2I1cel91374@stash.attlabs.att.com>

next in thread | raw e-mail | index | archive | help
>Number:         25886
>Category:       bin
>Synopsis:       cgetset(3) doesn't get cleared when switching databases
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 17 17:50:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Bill Fenner
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
AT&T Labs - Research
>Environment:
System: FreeBSD stash.attlabs.att.com 5.0-CURRENT FreeBSD 5.0-CURRENT #2: Tue Feb 27 18:26:16 PST 2001 root@stash.attlabs.att.com:/usr/obj/usr/src/sys/GENERIC i386

The bug is also present in 4.2-RELEASE and 4.3-BETA.

>Description:

The getcap(3) library provides the ability, using cgetset(), to
prepend an entry to a capabilities database.  This is used, e.g.,
by libtermcap when the $TERMCAP environment variable is set.

However, if an application using libtermcap also uses getcap(3)
itself, the value prepended by libtermcap is also prepended to
the application's database.

This is noted in the getcap(3) BUGS section, so I suppose this is
vaugely an lpc bug.

>How-To-Repeat:

% eval `tset -s`
% lpc
lpc> stat all

Notice the extra printer named after your terminal type.
% echo "$TERMCAP"

aha, that's where it came from.

>Fix:

	
Workaround: call cgetset(NULL) right before the first cgetfirst()
in any getcap(3) consumer (e.g. usr.sbin/lpr/common_source/printcap.c),
particularly those that link with -ltermcap (but who knows what other
library function might use cgetset(), so better safe than sorry).

Fix: Change the getcap(3) API?  Make cgetfirst() notice that it's being
called with a different db_array without a cgetset() call in between
and call cgetset(NULL)?  (eeew)  Make cgetclose() call cgetset(NULL)
if gottoprec == 1?  (subtle API change but less eeew)

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

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103180138.f2I1cel91374>