diff --git a/libexec/getty/chat.c b/libexec/getty/chat.c --- a/libexec/getty/chat.c +++ b/libexec/getty/chat.c @@ -59,10 +59,10 @@ static void chat_alrm(int); static int chat_unalarm(void); -static int getdigit(unsigned char **, int, int); +static int getdigit(char **, int, int); static char **read_chat(char **); static char *cleanchr(char **, unsigned char); -static const char *cleanstr(const unsigned char *, int); +static const char *cleanstr(const char *, int); static const char *result(int); static int chat_expect(const char *); static int chat_send(char const *); @@ -104,7 +104,7 @@ */ static int -getdigit(unsigned char **ptr, int base, int max) +getdigit(char **ptr, int base, int max) { int i, val = 0; char * q; @@ -149,10 +149,10 @@ p != NULL; p = strtok(NULL, ws)) { - unsigned char *q, *r; + char *q, *r; /* Read escapes */ - for (q = r = (unsigned char *)p; *r; ++q) + for (q = r = p; *r; ++q) { if (*q == '\\') { @@ -271,9 +271,9 @@ */ static const char * -cleanstr(const unsigned char *s, int l) +cleanstr(const char *s, int l) { - static unsigned char * tmp = NULL; + static char * tmp = NULL; static int tmplen = 0; if (tmplen < l * 4 + 1) diff --git a/libexec/getty/extern.h b/libexec/getty/extern.h --- a/libexec/getty/extern.h +++ b/libexec/getty/extern.h @@ -48,7 +48,7 @@ int delaybits(void); void edithost(const char *); void gendefaults(void); -void gettable(const char *, char *); +void gettable(const char *); void makeenv(char *[]); const char *portselector(void); void set_ttydefaults(int); diff --git a/libexec/getty/init.c b/libexec/getty/init.c --- a/libexec/getty/init.c +++ b/libexec/getty/init.c @@ -53,7 +53,7 @@ static char loginprg[] = _PATH_LOGIN; static char datefmt[] = "%+"; -#define M(a) (&omode.c_cc[a]) +#define M(a) (char *)(&omode.c_cc[a]) struct gettystrs gettystrs[] = { { "nx", NULL, NULL }, /* next table */ diff --git a/libexec/getty/main.c b/libexec/getty/main.c --- a/libexec/getty/main.c +++ b/libexec/getty/main.c @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -100,10 +101,7 @@ static char ttyn[32]; #define OBUFSIZ 128 -#define TABBUFSIZ 512 -static char defent[TABBUFSIZ]; -static char tabent[TABBUFSIZ]; static const char *tname; static char *env[128]; @@ -191,7 +189,7 @@ gethostname(hostname, sizeof(hostname) - 1); hostname[sizeof(hostname) - 1] = '\0'; if (hostname[0] == '\0') - strcpy(hostname, "Amnesiac"); + snprintf(hostname, sizeof(hostname), "Amnesiac"); /* * Limit running time to deal with broken or dead lines. @@ -201,7 +199,7 @@ limit.rlim_cur = GETTY_TIMEOUT; (void)setrlimit(RLIMIT_CPU, &limit); - gettable("default", defent); + gettable("default"); gendefaults(); tname = "default"; if (argc > 1) @@ -215,10 +213,9 @@ * J. Gettys - MIT Project Athena. */ if (argc <= 2 || strcmp(argv[2], "-") == 0) - strcpy(ttyn, ttyname(STDIN_FILENO)); + snprintf(ttyn, sizeof(ttyn), "%s", ttyname(STDIN_FILENO)); else { - strcpy(ttyn, _PATH_DEV); - strlcat(ttyn, argv[2], sizeof(ttyn)); + snprintf(ttyn, sizeof(ttyn), "%s%s", _PATH_DEV, argv[2]); if (strcmp(argv[0], "+") != 0) { chown(ttyn, 0, 0); chmod(ttyn, 0600); @@ -762,7 +759,7 @@ puts(editedhost); break; - case 'd': { + case 'd': t = (time_t)0; (void)time(&t); if (Lo) @@ -786,7 +783,6 @@ case 'v': puts(kerninfo.version); break; - } case '%': putchr('%'); @@ -804,7 +800,7 @@ { /* Read the database entry. */ - gettable(tname, tabent); + gettable(tname); /* * Avoid inheriting the parity values from the default entry diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c --- a/libexec/getty/subr.c +++ b/libexec/getty/subr.c @@ -60,8 +60,9 @@ * Get a table entry. */ void -gettable(const char *name, char *buf) +gettable(const char *name) { + char *buf = NULL; struct gettystrs *sp; struct gettynums *np; struct gettyflags *fp; @@ -155,6 +156,7 @@ fp->value = 1 ^ fp->invrt; } } + free(buf); } void @@ -202,13 +204,15 @@ &SU, &DS, &RP, &FL, &WE, &LN, 0 }; +#define CV(a) (char *)(&tmode.c_cc[a]) + static char * charvars[] = { - &tmode.c_cc[VERASE], &tmode.c_cc[VKILL], &tmode.c_cc[VINTR], - &tmode.c_cc[VQUIT], &tmode.c_cc[VSTART], &tmode.c_cc[VSTOP], - &tmode.c_cc[VEOF], &tmode.c_cc[VEOL], &tmode.c_cc[VSUSP], - &tmode.c_cc[VDSUSP], &tmode.c_cc[VREPRINT], &tmode.c_cc[VDISCARD], - &tmode.c_cc[VWERASE], &tmode.c_cc[VLNEXT], 0 + CV(VERASE), CV(VKILL), CV(VINTR), + CV(VQUIT), CV(VSTART), CV(VSTOP), + CV(VEOF), CV(VEOL), CV(VSUSP), + CV(VDSUSP), CV(VREPRINT), CV(VDISCARD), + CV(VWERASE), CV(VLNEXT), 0 }; void