summaryrefslogtreecommitdiffstats
path: root/lib/console.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/console.c (renamed from libmisc/console.c)9
1 files changed, 5 insertions, 4 deletions
diff --git a/libmisc/console.c b/lib/console.c
index c475aa2..92065d9 100644
--- a/libmisc/console.c
+++ b/lib/console.c
@@ -13,6 +13,7 @@
#include <stdio.h>
#include "getdef.h"
#include "prototypes.h"
+#include "string/strtcpy.h"
#ident "$Id$"
@@ -44,8 +45,7 @@ static bool is_listed (const char *cfgin, const char *tty, bool def)
if (*cons != '/') {
char *pbuf;
- strncpy (buf, cons, sizeof (buf));
- buf[sizeof (buf) - 1] = '\0';
+ STRTCPY(buf, cons);
pbuf = &buf[0];
while ((s = strtok (pbuf, ":")) != NULL) {
if (strcmp (s, tty) == 0) {
@@ -71,8 +71,9 @@ static bool is_listed (const char *cfgin, const char *tty, bool def)
* See if this tty is listed in the console file.
*/
- while (fgets (buf, (int) sizeof (buf), fp) != NULL) {
- buf[strlen (buf) - 1] = '\0';
+ while (fgets (buf, sizeof (buf), fp) != NULL) {
+ /* Remove optional trailing '\n'. */
+ buf[strcspn (buf, "\n")] = '\0';
if (strcmp (buf, tty) == 0) {
(void) fclose (fp);
return true;