more buffer overflow avoiding through using snprintf()
This commit is contained in:
@ -204,7 +204,7 @@ void Universe::add_world(char *str)
|
||||
|
||||
if (!valid) {
|
||||
char msg[128];
|
||||
sprintf(msg,"Invalid partition string '%s'",str);
|
||||
snprintf(msg,128,"Invalid partition string '%s'",str);
|
||||
error->universe_all(FLERR,msg);
|
||||
}
|
||||
} else nper = nprocs;
|
||||
@ -269,7 +269,7 @@ char *date2num(const char *version)
|
||||
year = atoi(version);
|
||||
}
|
||||
|
||||
char *ver = new char[10];
|
||||
char *ver = new char[64];
|
||||
sprintf(ver,"%04d%02d%02d", year % 10000, month, day % 100);
|
||||
|
||||
return ver;
|
||||
|
||||
Reference in New Issue
Block a user