FormatMagickTime not safe
Posted: 2008-12-14T14:14:40-07:00
Hello,
The FormatMagickTime (string.c) function is not safe and some crashes might occurs on it, particularly if the provided time is not correct. It occurs on some of my files. Here is the current code:
This would be better like this:
What do you think of this suggestion ?
Manuel
The FormatMagickTime (string.c) function is not safe and some crashes might occurs on it, particularly if the provided time is not correct. It occurs on some of my files. Here is the current code:
Code: Select all
local_time=(*localtime(&time)); // Not secure because localtime can return NULL if time is invalid.
utc_time=(*gmtime(&time)); // idem
Code: Select all
struct tm
local_time,
utc_time, *tmptime;
strcpy(timestamp, "");
tmptime=localtime(&time);
if (!tmptime)
return 0;
local_time = *tmptime ;
tmptime=gmtime(&time);
if (!tmptime)
return 0;
utc_time = *tmptime ;
...
Manuel