NetBSD Problem Report #156
From gnats Sat Mar 5 19:56:59 1994
Received: from forte (forte.mathematik.uni-Bremen.de [134.102.232.1]) by sun-lamp.cs.berkeley.edu (8.6.5/8.6.5) with ESMTP id TAA03847 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Sat, 5 Mar 1994 19:56:57 -0800
Message-Id: <199403060356.EAA26395@forte>
Date: Sun, 6 Mar 1994 04:56:45 +0100
From: thomas@mathematik.uni-Bremen.de
Reply-To: thomas@mathematik.uni-Bremen.de
To: gnats-bugs@sun-lamp.cs.berkeley.edu
Subject: cgetent does access free'd memory
X-Send-Pr-Version: 3.2
>Number: 156
>Category: lib
>Synopsis: cgetent does access free'd memory
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: gnats-admin
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Mar 05 20:05:01 +0000 1994
>Closed-Date: Sun Mar 06 07:54:40 +0000 1994
>Last-Modified:
>Originator: Thomas Eberhardt
>Release:
>Organization:
CeVis, University of Bremen, Germany
>Environment:
System: NetBSD ed209 0.9a ED209#0 i386
Machine: i386
>Description:
After rebuilding XFree86-2.0 using the GNU malloc library, xterm
just dumped core. A little investigation showed that the getent
routine that is called by cgetent that is called by tgetent in
the termcap library accesses a record returned by the db library
AFTER closing the database which is apparently a no-no since
closing the database closing releases all internal database buffers.
>How-To-Repeat:
>Fix:
*** libc/gen/getcap.c- Tue Jan 4 12:02:32 1994
--- libc/gen/getcap.c Sun Mar 6 04:36:46 1994
***************
*** 195,202 ****
DB *capdbp;
DBT key, data;
register char *r_end, *rp, **db_p;
! int myfd, eof, foundit, retval;
! char *record;
int tc_not_resolved;
char pbuf[_POSIX_PATH_MAX];
--- 195,202 ----
DB *capdbp;
DBT key, data;
register char *r_end, *rp, **db_p;
! int myfd, eof, foundit, retval, clen;
! char *record, *cbuf;
int tc_not_resolved;
char pbuf[_POSIX_PATH_MAX];
***************
*** 251,261 ****
!= NULL) {
free(record);
retval = cdbget(capdbp, &record, name);
! if (capdbp->close(capdbp) < 0)
return (-2);
! *len = strlen(record);
! *cap = malloc(*len + 1);
! memmove(*cap, record, *len + 1);
return (retval);
} else {
fd = open(*db_p, O_RDONLY, 0);
--- 251,265 ----
!= NULL) {
free(record);
retval = cdbget(capdbp, &record, name);
! clen = strlen(record);
! cbuf = malloc(clen + 1);
! memmove(cbuf, record, clen + 1);
! if (capdbp->close(capdbp) < 0) {
! free(cbuf);
return (-2);
! }
! *len = clen;
! *cap = cbuf;
return (retval);
} else {
fd = open(*db_p, O_RDONLY, 0);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: cgd
State-Changed-When: Sat Mar 5 23:54:40 PST 1994
State-Changed-Why:
fixed fix applied.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.