NetBSD Problem Report #48025

From www@NetBSD.org  Sat Jul  6 13:56:59 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 75990718B2
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  6 Jul 2013 13:56:59 +0000 (UTC)
Message-Id: <20130706135658.07F69718B6@mollari.NetBSD.org>
Date: Sat,  6 Jul 2013 13:56:58 +0000 (UTC)
From: henning.petersen@t-online.de
Reply-To: henning.petersen@t-online.de
To: gnats-bugs@NetBSD.org
Subject: Uninitializied variable in citrus_utf1632.c
X-Send-Pr-Version: www-1.0

>Number:         48025
>Category:       lib
>Synopsis:       Uninitializied variable in citrus_utf1632.c
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 06 14:00:00 +0000 2013
>Last-Modified:  Sun Jul 07 08:40:00 +0000 2013
>Originator:     Henning Petersen
>Release:        NetBSD-current
>Organization:
>Environment:
>Description:
Uninitializied variable wc in citrus_utf1632.c .
>How-To-Repeat:

>Fix:
diff -u -p -r1.12 citrus_utf1632.c
--- lib/libc/citrus/modules/citrus_utf1632.c	12 Feb 2012 13:51:29 -0000	1.12
+++ lib/libc/citrus/modules/citrus_utf1632.c	6 Jul 2013 12:27:19 -0000
@@ -93,7 +93,7 @@ _citrus_UTF1632_mbrtowc_priv(_UTF1632Enc
 			     size_t *nresult)
 {
 	int chlenbak, endian, needlen;
-	wchar_t wc;
+	wchar_t wc = L'\0';
 	size_t result;
 	const char *s0;


>Audit-Trail:
From: Brett Lymn <blymn@internode.on.net>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: lib/48025: Uninitializied variable in citrus_utf1632.c
Date: Sun, 7 Jul 2013 12:43:13 +0930

 On Sat, Jul 06, 2013 at 02:00:00PM +0000, henning.petersen@t-online.de wrote:
 > 
 > >Fix:
 > diff -u -p -r1.12 citrus_utf1632.c
 > --- lib/libc/citrus/modules/citrus_utf1632.c	12 Feb 2012 13:51:29 -0000	1.12
 > +++ lib/libc/citrus/modules/citrus_utf1632.c	6 Jul 2013 12:27:19 -0000
 > @@ -93,7 +93,7 @@ _citrus_UTF1632_mbrtowc_priv(_UTF1632Enc
 >  			     size_t *nresult)
 >  {
 >  	int chlenbak, endian, needlen;
 > -	wchar_t wc;
 > +	wchar_t wc = L'\0';
 >  	size_t result;
 >  	const char *s0;
 >  

 For what it is worth, the coding standard says that you shouldn't assign
 values in the declaration of the variable.  This is quite often ignored
 though.

 -- 
 Brett Lymn
 Staple Guns: because duct tape doesn't make that KerCHUNK sound - xkcd.com

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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.