aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuediger Meier <ruediger.meier@ga-group.nl>2016-12-01 09:52:08 +0100
committerKarel Zak <kzak@redhat.com>2016-12-07 12:35:24 +0100
commita924b4004c154d6f75afd9e172e2595194cb60cc (patch)
treea558ca17729364bfc864ae70ddbe8ba9861fd32a
parentf718c2fc7f7f144c3a41baabf1ebdbcd3f074e4d (diff)
downloadutil-linux-a924b4004c154d6f75afd9e172e2595194cb60cc.tar.gz
login-utils: avoid using the defined utmp sizes.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
-rw-r--r--login-utils/last.c18
-rw-r--r--term-utils/write.c2
2 files changed, 10 insertions, 10 deletions
diff --git a/login-utils/last.c b/login-utils/last.c
index 42fb914d8f..da7ed36c8e 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -383,7 +383,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t logout_ti
char logouttime[LAST_TIMESTAMP_LEN];
char length[LAST_TIMESTAMP_LEN];
char final[512];
- char utline[UT_LINESIZE+1];
+ char utline[sizeof(p->ut_line) + 1];
char domain[256];
char *s;
int mins, hours, days;
@@ -394,7 +394,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t logout_ti
* uucp and ftp have special-type entries
*/
utline[0] = 0;
- strncat(utline, p->ut_line, UT_LINESIZE);
+ strncat(utline, p->ut_line, sizeof(p->ut_line));
if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3]))
utline[3] = 0;
if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4]))
@@ -406,7 +406,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t logout_ti
if (ctl->show) {
char **walk;
for (walk = ctl->show; *walk; walk++) {
- if (strncmp(p->ut_user, *walk, UT_NAMESIZE) == 0 ||
+ if (strncmp(p->ut_user, *walk, sizeof(p->ut_user)) == 0 ||
strcmp(utline, *walk) == 0 ||
(strncmp(utline, "tty", 3) == 0 &&
strcmp(utline + 3, *walk) == 0)) break;
@@ -504,7 +504,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t logout_ti
if (ctl->usedns || ctl->useip)
r = dns_lookup(domain, sizeof(domain), ctl->useip, p->ut_addr_v6);
if (r < 0) {
- len = UT_HOSTSIZE;
+ len = sizeof(p->ut_host);
if (len >= (int)sizeof(domain)) len = sizeof(domain) - 1;
domain[0] = 0;
strncat(domain, p->ut_host, len);
@@ -798,7 +798,7 @@ static void process_wtmp_file(const struct last_control *ctl,
for (p = ulist; p; p = next) {
next = p->next;
if (strncmp(p->ut.ut_line, ut.ut_line,
- UT_LINESIZE) == 0) {
+ sizeof(ut.ut_line)) == 0) {
/* Show it */
if (c == 0) {
quit = list(ctl, &ut, p->ut.ut_tv.tv_sec, R_NORMAL);
@@ -987,10 +987,10 @@ int main(int argc, char **argv)
ctl.until = (time_t) (p / 1000000);
break;
case 'w':
- if (ctl.name_len < UT_NAMESIZE)
- ctl.name_len = UT_NAMESIZE;
- if (ctl.domain_len < UT_HOSTSIZE)
- ctl.domain_len = UT_HOSTSIZE;
+ if (ctl.name_len < sizeof(((struct utmp *) 0)->ut_user))
+ ctl.name_len = sizeof(((struct utmp *) 0)->ut_user);
+ if (ctl.domain_len < sizeof(((struct utmp *) 0)->ut_host))
+ ctl.domain_len = sizeof(((struct utmp *) 0)->ut_host);
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
diff --git a/term-utils/write.c b/term-utils/write.c
index e39b848eae..4f8f21eb57 100644
--- a/term-utils/write.c
+++ b/term-utils/write.c
@@ -164,7 +164,7 @@ static void search_utmp(struct write_control *ctl)
struct utmp *u;
time_t best_atime = 0, tty_atime;
int num_ttys = 0, valid_ttys = 0, tty_writeable = 0, user_is_me = 0;
- char path[UT_LINESIZE + 6];
+ char path[sizeof(u->ut_line) + 6];
utmpname(_PATH_UTMP);
setutent();