From eb45bb90d41d4414def8c30d4902b3132628a1b9 Mon Sep 17 00:00:00 2001 From: "Alexandros C. Couloumbis" Date: Thu, 18 Nov 2010 14:58:37 +0000 Subject: toolchain/uClibc: push some upstream patches for uClibc-0.9.31. should resolve isses of #8269 SVN-Revision: 24029 --- .../patches-0.9.31/000-upstream-ctime_fix.patch | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 toolchain/uClibc/patches-0.9.31/000-upstream-ctime_fix.patch (limited to 'toolchain/uClibc/patches-0.9.31/000-upstream-ctime_fix.patch') diff --git a/toolchain/uClibc/patches-0.9.31/000-upstream-ctime_fix.patch b/toolchain/uClibc/patches-0.9.31/000-upstream-ctime_fix.patch new file mode 100644 index 0000000000..668662c347 --- /dev/null +++ b/toolchain/uClibc/patches-0.9.31/000-upstream-ctime_fix.patch @@ -0,0 +1,86 @@ +From f6651fa449e1d4bbbb466b091f34e6752f6506f9 Mon Sep 17 00:00:00 2001 +From: David A Ramos +Date: Tue, 27 Jul 2010 11:10:15 +0000 +Subject: Fix ctime() standard compliance bug + +fixes issue2209: +ctime() was updated in 0.9.31 to call localtime_r() instead of +localtime() to +avoid using a static buffer. Unfortunately, this change replaces the +static +buffer (which is zeroed out on initialization) with an uninitialized +local +buffer. + +In the common case, this has no effect. However, with a sufficiently +large +time_t value, the value returned differs from that returned by +asctime(localtime(t)), and thus violates the ANSI/ISO standard. + +An example input is (on a 64-bit machine): +time_t t = 0x7ffffffffff6c600; + +Signed-off-by: Bernhard Reutner-Fischer +--- +diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c +index dfa8c0d..0d12bf3 100644 +--- a/libc/misc/time/time.c ++++ b/libc/misc/time/time.c +@@ -479,6 +479,7 @@ char *ctime(const time_t *t) + * localtime's static buffer: + */ + struct tm xtm; ++ memset(&xtm, 0, sizeof(xtm)); + + return asctime(localtime_r(t, &xtm)); + } +diff --git a/test/time/tst-ctime.c b/test/time/tst-ctime.c +new file mode 100644 +index 0000000..91d827a +--- a/dev/null ++++ b/test/time/tst-ctime.c +@@ -0,0 +1,44 @@ ++/* vi: set sw=4 ts=4: */ ++/* testcase for ctime(3) with large time ++ * Copyright (C) 2010 David A Ramos ++ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#define MAX_POSITIVE(type) (~0 & ~((type) 1 << (sizeof(type)*8 - 1))) ++ ++int do_test(int argc, char **argv) { ++ char *correct = 0, *s; ++ int status; ++ ++ /* need a very high positive number (e.g., max - 1024) */ ++ time_t test = MAX_POSITIVE(time_t) - 1024; ++ ++ s = asctime(localtime(&test)); ++ ++ if (s) { ++ // copy static buffer to heap ++ correct = malloc(strlen(s)+1); ++ strcpy(correct, s); ++ } ++ ++ s = ctime(&test); ++ ++ printf("ANSI:\t%suClibc:\t%s", correct, s); ++ ++ if (s != correct && strcmp(correct, s)) ++ status = EXIT_FAILURE; ++ else ++ status = EXIT_SUCCESS; ++ ++ if (correct) ++ free(correct); ++ ++ return status; ++} ++ ++#include -- cgit v1.2.3