NetBSD Problem Report #39422

From "kretschm.ttypd.Aug.28.10:23"@cs.uni-bonn.de  Thu Aug 28 09:57:12 2008
Return-Path: <"kretschm.ttypd.Aug.28.10:23"@cs.uni-bonn.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 4D62663B8A9
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 28 Aug 2008 09:57:12 +0000 (UTC)
Message-Id: <1219912692.428358.22564.nullmailer@tiger.cs.uni-bonn.de>
Date: Thu, 28 Aug 2008 10:38:12 +0200
From: kretschm@cs.uni-bonn.de
Reply-To: kretschm@cs.uni-bonn.de
To: gnats-bugs@gnats.NetBSD.org
Subject: missing guards for wcslcat(), wcslcpy(), wcswidth() & wcwidth()
X-Send-Pr-Version: 3.95

>Number:         39422
>Category:       standards
>Synopsis:       missing guards for wcslcat(), wcslcpy(), wcswidth() & wcwidth()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    standards-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 28 10:00:01 +0000 2008
>Closed-Date:    Fri Dec 28 13:12:22 +0000 2018
>Last-Modified:  Fri Dec 28 13:15:00 +0000 2018
>Originator:     kretschm@cs.uni-bonn.de
>Release:        NetBSD 4.0
>Organization:
>Environment:


System: NetBSD tiger 4.0 NetBSD 4.0 (GENERIC) #1: Thu Dec 27 15:39:36 CET 2007 ignatios@random85.cs.uni-bonn.de:/var/itch/sources/4.0/oi/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
If _ISOC99_SOURCE macro is defined the definition of wcslcpy(),
wcslcat(), wcswidth() and wcwidth() is visible.  Thus it is unhandy
to use such definitions for basic portability checks.

More appropriate would be a behaviour that is given by other include
files where _NETBSD_SOURCE or the corresponding _POSIX_C_SOURCE macro
definitions have to be given to include wcslcpy()/wcslcat() resp.
wcswidth()/wcwidth().

The included fix should correct this.
>How-To-Repeat:
The following code should compile fine, but doesn't because wcslcpy()'s
definition is visible.

#define _ISOC99_SOURCE
#include <wchar.h>

static
void
wcslcpy(void)
{
    /* foo */
}

>Fix:
--- wchar.h.orig        2008-08-28 10:16:03.000000000 +0200
+++ wchar.h     2008-08-28 10:22:44.000000000 +0200
@@ -132,11 +132,15 @@
 wchar_t        *wmemmove(wchar_t *, const wchar_t *, size_t);
 wchar_t        *wmemset(wchar_t *, wchar_t, size_t);

+#if defined(_NETBSD_SOURCE)
 size_t wcslcat(wchar_t *, const wchar_t *, size_t);
 size_t wcslcpy(wchar_t *, const wchar_t *, size_t);
+#endif
+#if defined(_NETBSD_SOURCE) || (_POSIX_C_SOURCE - 0 >= 200112L)
 int    wcswidth(const wchar_t *, size_t);
-int    wctob(wint_t);
 int    wcwidth(wchar_t);
+#endif
+int    wctob(wint_t);

 unsigned long int wcstoul(const wchar_t * __restrict,
        wchar_t ** __restrict, int);

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Fri, 28 Dec 2018 13:12:22 +0000
State-Changed-Why:
Applied, thanks for the patch!


From: "Maya Rashish" <maya@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39422 CVS commit: src/include
Date: Fri, 28 Dec 2018 13:11:46 +0000

 Module Name:	src
 Committed By:	maya
 Date:		Fri Dec 28 13:11:46 UTC 2018

 Modified Files:
 	src/include: wchar.h

 Log Message:
 Limit wcslcat, wcslcpy visibility to _NETBSD_SOURCE
 wcswidth, wcwidth to POSIX.1-2001 or _NETBSD_SOURCE

 Updated patch from kretschm in PR standards/39422


 To generate a diff of this commit:
 cvs rdiff -u -r1.42 -r1.43 src/include/wchar.h

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

>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.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.