Skip to content

Commit

Permalink
Make sure logintime string can never overflow (Coverity CID 1164485).
Browse files Browse the repository at this point in the history
  • Loading branch information
petterreinholdtsen committed Jan 26, 2014
1 parent ae7c73e commit 7d6e368
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/last.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ int list(struct utmp *p, time_t t, int what)
* Calculate times
*/
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)
sprintf(logouttime, "- %s", ctime(&t));
else {
Expand Down

0 comments on commit 7d6e368

Please sign in to comment.