Make sure logintime string can never overflow (Coverity CID 1164485).
This commit is contained in:
parent
ae7c73ec7f
commit
7d6e3683b0
@ -396,7 +396,8 @@ int list(struct utmp *p, time_t t, int what)
|
|||||||
* Calculate times
|
* Calculate times
|
||||||
*/
|
*/
|
||||||
tmp = (time_t)p->ut_time;
|
tmp = (time_t)p->ut_time;
|
||||||
strcpy(logintime, ctime(&tmp));
|
strncpy(logintime, ctime(&tmp), sizeof(logintime));
|
||||||
|
logintime[sizeof(logintime)-1] = 0; /* enforce null termination */
|
||||||
if (fulltime)
|
if (fulltime)
|
||||||
sprintf(logouttime, "- %s", ctime(&t));
|
sprintf(logouttime, "- %s", ctime(&t));
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user