Subject: bin/36006: makefs(8) create cd9660 file system with wrong time stamp
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <taca@back-street.net>
List: netbsd-bugs
Date: 03/14/2007 11:40:00
>Number:         36006
>Category:       bin
>Synopsis:       makefs(8) create cd9660 file system with wrong time stamp
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 14 11:40:00 +0000 2007
>Originator:     Takahiro Kambe
>Release:        NetBSD 4.0_BETA2
>Organization:
	
>Environment:
	
	
System: NetBSD calm.i.SmartField.co.jp 4.0_BETA2 NetBSD 4.0_BETA2 (CALM) #7: Mon Mar 12 20:10:54 JST 2007 sisbic-info@kyoto.jone-system.com:/work/NetBSD-4/i386.obj/sys/arch/i386/compile/CALM i386
Architecture: i386
Machine: i386
>Description:
	When creating cd9660 file system with makefs(8), files in created
	file system have wrong time stamp.  This problem occurs in area
	whose timezone isn't zero.
>How-To-Repeat:
	Create cd9660 file system with makefs(8).
>Fix:
	cd9660_compute_gm_offset() expect localtime(3) and gmtime(3)
	returns different result.  But they share storage for struct tm,
	cd9660_compute_gm_offset() returns always 0.

	Here is a quick fix for this problem.  Another way is using
	localtime_r(3) and gmtime_r(3).

	This problem seems to exist current, too.

Index: usr.sbin/makefs/cd9660/cd9660_conversion.c
===================================================================
RCS file: /cvs/src-4/usr.sbin/makefs/cd9660/cd9660_conversion.c,v
retrieving revision 1.1.1.1
diff -u -p -d -d -u -p -r1.1.1.1 cd9660_conversion.c
--- usr.sbin/makefs/cd9660/cd9660_conversion.c	7 Feb 2007 01:52:06 -0000	1.1.1.1
+++ usr.sbin/makefs/cd9660/cd9660_conversion.c	14 Mar 2007 10:20:45 -0000
@@ -152,8 +152,11 @@ cd9660_compute_gm_offset(time_t tim)
 {
 	struct tm* t;
 	struct tm* gm;
+	struct tm t0;
 
 	t = localtime(&tim);
+	t0 = *t;
+	t = &t0;
 	gm = gmtime(&tim);
 	gm->tm_year -= t->tm_year;
 	gm->tm_yday -= t->tm_yday;

>Unformatted: