This makes it harder to make mistakes while editing the code. Since the
sizeof's can be autocalculated, let the machine do that. It also
reduces the cognitive load while reading the code.
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
#include <stdio.h>
#include "getdef.h"
#include "prototypes.h"
+#include "strlcpy.h"
#ident "$Id$"
if (*cons != '/') {
char *pbuf;
- strlcpy (buf, cons, sizeof (buf));
+ STRLCPY(buf, cons);
pbuf = &buf[0];
while ((s = strtok (pbuf, ":")) != NULL) {
if (strcmp (s, tty) == 0) {
#include "alloc.h"
#include "sizeof.h"
+#include "strlcpy.h"
#include "zustr2stp.h"
#ident "$Id$"
if ('\0' == tmptty[0]) {
const char *tname = ttyname (STDIN_FILENO);
if (NULL != tname)
- (void) strlcpy (tmptty, tname, sizeof(tmptty));
+ STRLCPY(tmptty, tname);
}
if ('\0' == tmptty[0]) {
sizeof (loginprompt),
_("%s login: "), hostn);
} else {
- strlcpy (loginprompt, _("login: "),
- sizeof (loginprompt));
+ STRLCPY(loginprompt, _("login: "));
}
retcode = pam_set_item (pamh, PAM_USER_PROMPT, loginprompt);
SYSLOG ((LOG_INFO,
"Change user from '%s' to '%s' as requested by PAM",
name, tmp_name));
- if (strlcpy (name, tmp_name, sizeof(name)) >= sizeof(name)) {
+ if (STRLCPY(name, tmp_name) == -1) {
fprintf (stderr, _("Overlong user name '%s'\n"),
tmp_name);
SYSLOG ((LOG_NOTICE, "Overlong user name '%s'",