mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 04:30:10 +00:00
Fixed a buffer overflow (report from Christian Groessler).
git-svn-id: svn://svn.cc65.org/cc65/trunk@1464 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
277e5ff77d
commit
49fd7134e5
@ -39,6 +39,7 @@
|
|||||||
/* common */
|
/* common */
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
#include "xsprintf.h"
|
||||||
|
|
||||||
/* cc65 */
|
/* cc65 */
|
||||||
#include "asmlabel.h"
|
#include "asmlabel.h"
|
||||||
@ -257,10 +258,20 @@ static void Parse (void)
|
|||||||
void Compile (const char* FileName)
|
void Compile (const char* FileName)
|
||||||
/* Top level compile routine. Will setup things and call the parser. */
|
/* Top level compile routine. Will setup things and call the parser. */
|
||||||
{
|
{
|
||||||
char* Path;
|
char* Path;
|
||||||
char Buf[16];
|
char Buf[20];
|
||||||
time_t Time;
|
char DateStr[20];
|
||||||
char* TimeStr;
|
char TimeStr[20];
|
||||||
|
time_t Time;
|
||||||
|
struct tm* TM;
|
||||||
|
|
||||||
|
/* Since strftime is locale dependent, we need the abbreviated month names
|
||||||
|
* in english.
|
||||||
|
*/
|
||||||
|
static const char MonthNames[12][4] = {
|
||||||
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||||
|
};
|
||||||
|
|
||||||
/* Add some standard paths to the include search path */
|
/* Add some standard paths to the include search path */
|
||||||
AddIncludePath ("", INC_USER); /* Current directory */
|
AddIncludePath ("", INC_USER); /* Current directory */
|
||||||
@ -299,11 +310,12 @@ void Compile (const char* FileName)
|
|||||||
|
|
||||||
/* __TIME__ and __DATE__ macros */
|
/* __TIME__ and __DATE__ macros */
|
||||||
Time = time (0);
|
Time = time (0);
|
||||||
TimeStr = ctime (&Time);
|
TM = localtime (&Time);
|
||||||
sprintf (Buf, "\"%.10s\"", TimeStr);
|
strftime (Buf, sizeof (Buf), "%e %Y", TM);
|
||||||
DefineTextMacro ("__DATE__", Buf);
|
xsprintf (DateStr, sizeof (DateStr), "\"%s %s\"", MonthNames[TM->tm_mon], Buf);
|
||||||
sprintf (Buf, "\"%.15s\"", TimeStr+11);
|
strftime (TimeStr, sizeof (TimeStr), "\"%H:%M:%S\"", TM);
|
||||||
DefineTextMacro ("__TIME__", Buf);
|
DefineTextMacro ("__DATE__", DateStr);
|
||||||
|
DefineTextMacro ("__TIME__", TimeStr);
|
||||||
|
|
||||||
/* Initialize the literal pool */
|
/* Initialize the literal pool */
|
||||||
InitLiteralPool ();
|
InitLiteralPool ();
|
||||||
|
Loading…
Reference in New Issue
Block a user