lib/failure.c: Replace strncpy(3) call by STRTCPY()
This call was way too clever. It relied on the last byte of fail_line being 0 due to it being in a static structure and never writing to it. Write an explicit terminating null byte, by using STRTCPY(). Cc: Matthew House <mattlloydhouse@gmail.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
8a1a097afa
commit
09957c6d27
+2
-1
@@ -19,6 +19,7 @@
|
||||
#include "failure.h"
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
#include "strtcpy.h"
|
||||
|
||||
|
||||
#define YEAR (365L*DAY)
|
||||
@@ -78,7 +79,7 @@ void failure (uid_t uid, const char *tty, struct faillog *fl)
|
||||
fl->fail_cnt++;
|
||||
}
|
||||
|
||||
strncpy (fl->fail_line, tty, sizeof (fl->fail_line) - 1);
|
||||
STRTCPY(fl->fail_line, tty);
|
||||
(void) time (&fl->fail_time);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user