Bugs item #1358718, was opened at 2005-11-16 22:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1358718&group_id=8032
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Runtime System
Group: 6.4.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: undefined behavior in time_str (RtsUtils.c)
Initial Comment:
code looks like this:
char *
time_str(void)
{
static time_t now = 0;
static char nowstr[26];
if (now == 0) {
time(&now);
strcpy(nowstr, ctime(&now));
strcpy(nowstr+16,nowstr+19); /* this is undefined
behavior as buffers overlap, probably
will show undesired effects if compiler utilise
copy optimisations */
nowstr[21] = '\0';
}
return nowstr;
}
corrected should look like this:
char *
time_str(void)
{
static time_t now = 0;
static char nowstr[26];
if (now == 0) {
time(&now);
/* ctime_r(&now,nowstr); this is better if available */
strcpy(nowstr,ctime(&now));
memmove(nowstr+16,nowstr+19,7);
}
return nowstr;
}
--
[EMAIL PROTECTED] , Branimir Maksimovic
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1358718&group_id=8032
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs