|
[ ghc-Bugs-1358718 ] undefined behavior in time_str (RtsUtils.c): msg#00026lang.haskell.glasgow.bugs
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; } -- bmaxa@xxxxxxxx , Branimir Maksimovic ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1358718&group_id=8032
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | runProcess+removeFile, Windows, possibly finaliser not running, Esa Ilari Vuokko |
|---|---|
| Next by Date: | RE: runProcess+removeFile, Windows, possibly finaliser not running, Simon Marlow |
| Previous by Thread: | runProcess+removeFile, Windows, possibly finaliser not running, Esa Ilari Vuokko |
| Next by Thread: | newtype and existentials, Ralf Hinze |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |