bin/116766: mtree should probably use getcwd()

Giorgos Keramidas keramida at FreeBSD.org
Sun Sep 30 08:00:05 PDT 2007


>Number:         116766
>Category:       bin
>Synopsis:       mtree should probably use getcwd()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 30 15:00:04 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Giorgos Keramidas
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD kobe 7.0-CURRENT FreeBSD 7.0-CURRENT #0:
Fri Sep 21 19:09:58 EEST 2007 build at kobe:/home/build/obj/home/build/src/sys/KOBE i386

>Description:

While integrating mtree-like functionality in an autoconf-based
program, the following warning was issued by autoscan(1):

% janus:/k/mtree> autoscan
% src/mtree.c:167: warning: getwd is deprecated, use getcwd instead
% janus:/k/mtree>

>How-To-Repeat:
>Fix:

This is easy to fix, by using getcwd():

%%%
--- old/usr.sbin/mtree/mtree.c	Fri Sep 21 17:07:41 2007 +0300
+++ new/usr.sbin/mtree/mtree.c	Sun Sep 30 00:46:55 2007 +0300
@@ -164,7 +164,7 @@ main(int argc, char *argv[])
 	if (dir && chdir(dir))
 		err(1, "%s", dir);
 
-	if ((cflag || sflag) && !getwd(fullpath))
+	if ((cflag || sflag) && !getcwd(fullpath, sizeof(fullpath)))
 		errx(1, "%s", fullpath);
 
 	if (cflag) {
%%%

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


More information about the freebsd-bugs mailing list