diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2013-11-19 14:18:44 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2013-11-20 10:52:04 +0000 |
commit | 0f65b1fe153b343e28b617a8553b6e978cbd37d4 (patch) | |
tree | 88658b44a3d96f42531410b57f5282055f21f92b | |
parent | a5f0998028283c5933f147dabae1dc7e65170bcd (diff) | |
download | pam-0f65b1fe153b343e28b617a8553b6e978cbd37d4.tar.gz pam-0f65b1fe153b343e28b617a8553b6e978cbd37d4.tar.bz2 pam-0f65b1fe153b343e28b617a8553b6e978cbd37d4.zip |
pam_securetty: check return value of fgets
Checking return value of fgets not only silences the warning from glibc
but also leads to a cleaner code.
* modules/pam_securetty/pam_securetty.c (securetty_perform_check):
Check return value of fgets.
-rw-r--r-- | modules/pam_securetty/pam_securetty.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/modules/pam_securetty/pam_securetty.c b/modules/pam_securetty/pam_securetty.c index 5f2d1bec..04741309 100644 --- a/modules/pam_securetty/pam_securetty.c +++ b/modules/pam_securetty/pam_securetty.c @@ -159,11 +159,10 @@ securetty_perform_check (pam_handle_t *pamh, int ctrl, if (cmdlinefile != NULL) { char line[LINE_MAX], *p; - line[0] = 0; - fgets(line, sizeof(line), cmdlinefile); + p = fgets(line, sizeof(line), cmdlinefile); fclose(cmdlinefile); - for (p = line; p; p = strstr(p+1, "console=")) { + for (; p; p = strstr(p+1, "console=")) { char *e; /* Test whether this is a beginning of a word? */ |