Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Apr 2002 11:14:45 -0800 (PST)
From:      sjg@juniper.net
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/36626: login_cap(3) incorrectly claims that all resources freed.
Message-ID:  <200204011914.g31JEje89443@ran.juniper.net>

next in thread | raw e-mail | index | archive | help

>Number:         36626
>Category:       bin
>Synopsis:       login_cap(3) incorrectly claims that all resources freed.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 01 11:20:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Juniper Networks
>Environment:
System: FreeBSD ran.juniper.net 5.0-CURRENT FreeBSD 5.0-CURRENT #5: Thu Nov 16 10:40:43 PST 2000 root@cacophony2.juniper.net:/usr/src/sys/compile/Juniper i386


	
>Description:
	
login_cap(3) states:

     Note that with all functions in this group, you should not call free(3)
     on any pointers returned.  Memory allocated during retrieval or process-
     ing of capability tags is automatically reused by subsequent calls to
     functions in this group, or deallocated on calling login_close().

this is incorrect.  Functions like login_getcapstr() simply return
either the default passed to them or the string malloc'd by cgetstr().
No book keeping is done to ensure that that string is free()'d when needed.

Actually implementing the above promise is probably a tall order.
It might be better to document which functions do indeed need free() called 
and with the warning that one should use variables for default values
so that one can later tell if free is needed or not.

Alternatively login_getcapstr() could strdup(def), so that free() is always 
needed.

>How-To-Repeat:
	
>Fix:

	
>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?200204011914.g31JEje89443>