[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#401749: marked as done (mktime() does not return -1 for some BROKENTIME it should)



Your message dated Mon, 23 Apr 2007 08:23:37 +0200
with message-id <20070423062336.GA9244@volta.aurel32.net>
and subject line mktime() does not return -1 for some BROKENTIME it should
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: libc6
Version: 2.3.6.ds1-8
Severity: normal

When tm_isdst is negtive (which means "information is not available"
according to info), mktime() does not return -1 for some broken-down
time that cannot be represented as a time_t (int32 in my box) calendar
time. Instead mktime() return a closest tv (MIN_TIME_T or MAX_TIME_T), 
and normalize it's argument, and set tm_isdst to 0. While according to
doc and to POSIX it should just return (time_t)-1.

Here is a test program I use to reproduce the bug:
{{{
#include <time.h>
#include <stdio.h>


int main(int argc, char *argv[])
{
	struct tm ts;
	time_t tv;

	ts.tm_year = 1898 - 1900;
	ts.tm_mon = 12 - 1;
	ts.tm_mday = 28;
	ts.tm_hour = 0;
	ts.tm_min = 0;
	ts.tm_sec = 0;
	ts.tm_isdst = -1;
	tv = mktime(&ts);
	fprintf(stderr, "test one, year 1898, tv should be -1\n");
	fprintf(stderr,
		"tv = %d, y = %d, m = %u, d = %u, h = %u, m = %u, sec = %u, dst = %d\n",
		tv, ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour,
		ts.tm_min, ts.tm_sec, ts.tm_isdst);

	ts.tm_isdst = -1;

	ts.tm_year = 2046 - 1900;
	ts.tm_mon = 12 - 1;
	ts.tm_mday = 28;
	ts.tm_hour = 0;
	ts.tm_min = 0;
	ts.tm_sec = 0;
	tv = mktime(&ts);
	fprintf(stderr, "test two, year 2046, tv should be -1\n");
	fprintf(stderr,
		"tv = %d, y = %d, m = %u, d = %u, h = %u, m = %u, sec = %u, dst = %d\n",
		tv, ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour,
		ts.tm_min, ts.tm_sec, ts.tm_isdst);
}
}}}

my gcc version: gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)


-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-3-686
Locale: LANG=zh_CN.UTF-8, LC_CTYPE=zh_CN.UTF-8 (charmap=UTF-8)

Versions of packages libc6 depends on:
ii  tzdata                        2006p-1    Time Zone and Daylight Saving Time

libc6 recommends no packages.

-- no debconf information


--- End Message ---
--- Begin Message ---
Version: 2.5-1

On Wed, Dec 06, 2006 at 12:57:50AM +0800, xxlu wrote:
> Package: libc6
> Version: 2.3.6.ds1-8
> Severity: normal
> 
> When tm_isdst is negtive (which means "information is not available"
> according to info), mktime() does not return -1 for some broken-down
> time that cannot be represented as a time_t (int32 in my box) calendar
> time. Instead mktime() return a closest tv (MIN_TIME_T or MAX_TIME_T), 
> and normalize it's argument, and set tm_isdst to 0. While according to
> doc and to POSIX it should just return (time_t)-1.
> 
> Here is a test program I use to reproduce the bug:
> {{{
> #include <time.h>
> #include <stdio.h>
> 
> 
> int main(int argc, char *argv[])
> {
> 	struct tm ts;
> 	time_t tv;
> 
> 	ts.tm_year = 1898 - 1900;
> 	ts.tm_mon = 12 - 1;
> 	ts.tm_mday = 28;
> 	ts.tm_hour = 0;
> 	ts.tm_min = 0;
> 	ts.tm_sec = 0;
> 	ts.tm_isdst = -1;
> 	tv = mktime(&ts);
> 	fprintf(stderr, "test one, year 1898, tv should be -1\n");
> 	fprintf(stderr,
> 		"tv = %d, y = %d, m = %u, d = %u, h = %u, m = %u, sec = %u, dst = %d\n",
> 		tv, ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour,
> 		ts.tm_min, ts.tm_sec, ts.tm_isdst);
> 
> 	ts.tm_isdst = -1;
> 
> 	ts.tm_year = 2046 - 1900;
> 	ts.tm_mon = 12 - 1;
> 	ts.tm_mday = 28;
> 	ts.tm_hour = 0;
> 	ts.tm_min = 0;
> 	ts.tm_sec = 0;
> 	tv = mktime(&ts);
> 	fprintf(stderr, "test two, year 2046, tv should be -1\n");
> 	fprintf(stderr,
> 		"tv = %d, y = %d, m = %u, d = %u, h = %u, m = %u, sec = %u, dst = %d\n",
> 		tv, ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour,
> 		ts.tm_min, ts.tm_sec, ts.tm_isdst);
> }
> }}}
> 
> my gcc version: gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)
> 

I am able to reproduce this bug with glibc 2.3.6, but not with glibc
2.5, so I guess this bug is fixed.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

--- End Message ---

Reply to: