NetBSD Problem Report #48195

From www@NetBSD.org  Mon Sep  9 03:29:13 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id BCD677157F
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  9 Sep 2013 03:29:13 +0000 (UTC)
Message-Id: <20130909032912.26A4671580@mollari.NetBSD.org>
Date: Mon,  9 Sep 2013 03:29:12 +0000 (UTC)
From: hsuenaga@iij.ad.jp
Reply-To: hsuenaga@iij.ad.jp
To: gnats-bugs@NetBSD.org
Subject: wrong position of __MKTEMP_OK__ in src/usr.bin/xinstall.c
X-Send-Pr-Version: www-1.0

>Number:         48195
>Category:       bin
>Synopsis:       wrong position of __MKTEMP_OK__ in src/usr.bin/xinstall.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pgoyette
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 09 03:30:00 +0000 2013
>Closed-Date:    Tue May 31 07:01:09 +0000 2016
>Last-Modified:  Tue May 31 07:01:09 +0000 2016
>Originator:     SUENAGA Hiroki
>Release:        6.0_STABLE
>Organization:
Internet Initiative Japan Inc.
>Environment:
NetBSD sue-seil6.tokyo.iiji.jp 6.0_STABLE NetBSD 6.0_STABLE (SEIL6) #0: Mon Jan  7 10:25:38 JST 2013  hsuenaga@sue-seil6.tokyo.iiji.jp:/usr/src/sys/arch/i386/compile/SEIL6 i386
>Description:
__MKTEMP_OK__ should be defined before include "nbtool_config.h." otherwise tools-compiler print warning message of "mktemp() possibly used unsafely, use mkstemp() or mkdtemp()." for the reason that nbtool_config.h declares mktemp() in stdlib.h. (at least x86)

src/usr.bin/xinstall/xinstall.c:33 #include "nbtool_config.h"
src/tools/compat/obj/nbtool_config.h:643 #incldue "compat_defs.h" (generated)
src/tools/compat/compat_defs.h:45 #include <stdlib.h> (__MKTEMP_OK__ is not defined here)

>How-To-Repeat:
build release set using tools and look for warning carefully.

# /usr/src
# ./build.sh tools
# ./build.sh release

>Fix:
attached patch can suppress the warning.
I don't know about tools/compat should be modified or not.

diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index 2dfcc0a..896136b 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -29,6 +29,7 @@
  * SUCH DAMAGE.
  */

+#define __MKTEMP_OK__  /* All uses of mktemp have been checked */
 #if HAVE_NBTOOL_CONFIG_H
 #include "nbtool_config.h"
 #else
@@ -50,7 +51,6 @@ __RCSID("$NetBSD: xinstall.c,v 1.115 2011/09/06 18:50:32 joerg
 Exp $");
 #endif
 #endif /* not lint */

-#define __MKTEMP_OK__  /* All uses of mktemp have been checked */
 #include <sys/param.h>
 #include <sys/mman.h>
 #include <sys/stat.h>

>Release-Note:

>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48195: wrong position of __MKTEMP_OK__ in
 src/usr.bin/xinstall.c
Date: Sun, 6 Oct 2013 09:23:05 +0000

 On Mon, Sep 09, 2013 at 03:30:00AM +0000, hsuenaga@iij.ad.jp wrote:
  > __MKTEMP_OK__ should be defined before include "nbtool_config.h."
  > otherwise tools-compiler print warning message of "mktemp()
  > possibly used unsafely, use mkstemp() or mkdtemp()." for the reason
  > that nbtool_config.h declares mktemp() in stdlib.h. (at least x86)

 Maybe it would be better to fix xinstall to not use mktemp; eventually
 we'll need a (different) version of the __MKTEMP_OK__ workaround for
 every build host OS.

 -- 
 David A. Holland
 dholland@netbsd.org

From: "Paul Goyette" <pgoyette@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48195 CVS commit: src/usr.bin/xinstall
Date: Tue, 31 May 2016 06:55:02 +0000

 Module Name:	src
 Committed By:	pgoyette
 Date:		Tue May 31 06:55:02 UTC 2016

 Modified Files:
 	src/usr.bin/xinstall: xinstall.c

 Log Message:
 Move __MKTEMP_OK up earlier so it has an actual impact.  Reduces the
 number of warnings during build.

 XXX There are still some other warnings remaining to be resolved.

 Fixes PR bin/48195 although we really should go back someday and fix
 this correctly (by replacing all uses of mktemp(3)!)


 To generate a diff of this commit:
 cvs rdiff -u -r1.124 -r1.125 src/usr.bin/xinstall/xinstall.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: bin-bug-people->pgoyette
Responsible-Changed-By: pgoyette@NetBSD.org
Responsible-Changed-When: Tue, 31 May 2016 07:01:09 +0000
Responsible-Changed-Why:
I handled it.


State-Changed-From-To: open->closed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Tue, 31 May 2016 07:01:09 +0000
State-Changed-Why:
I committed the requested change.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.