diff options
author | Denis Vlasenko | 2008-07-11 12:19:14 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-07-11 12:19:14 +0000 |
commit | dee8587d9208e4ea5ba8f8bb73b555007529372e (patch) | |
tree | 303d21aeec9e3922e296ecc9041598a87a79b554 /miscutils | |
parent | f941306199d7cb00be68483169f202432a9a9a7d (diff) | |
download | busybox-dee8587d9208e4ea5ba8f8bb73b555007529372e.zip busybox-dee8587d9208e4ea5ba8f8bb73b555007529372e.tar.gz |
Apply post-1.11.0 patches. Bump version to 1.11.1.
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/last.c | 2 | ||||
-rw-r--r-- | miscutils/last_fancy.c | 6 | ||||
-rw-r--r-- | miscutils/man.c | 16 |
3 files changed, 16 insertions, 8 deletions
diff --git a/miscutils/last.c b/miscutils/last.c index 612f504..da353fb 100644 --- a/miscutils/last.c +++ b/miscutils/last.c @@ -117,6 +117,8 @@ int last_main(int argc, char **argv ATTRIBUTE_UNUSED) strcpy(ut.ut_line, "system boot"); } } + /* manpages say ut_tv.tv_sec *is* time_t, + * but some systems have it wrong */ t_tmp = (time_t)ut.ut_tv.tv_sec; printf("%-10s %-14s %-18s %-12.12s\n", ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4); diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c index 2b7fee6..d4d35b1 100644 --- a/miscutils/last_fancy.c +++ b/miscutils/last_fancy.c @@ -48,8 +48,12 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs) char logout_time[8]; const char *logout_str; const char *duration_str; + time_t tmp; - safe_strncpy(login_time, ctime(&(ut->ut_tv.tv_sec)), 17); + /* manpages say ut_tv.tv_sec *is* time_t, + * but some systems have it wrong */ + tmp = ut->ut_tv.tv_sec; + safe_strncpy(login_time, ctime(&tmp), 17); snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11); dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0); diff --git a/miscutils/man.c b/miscutils/man.c index 278e5a3..dc8fa44 100644 --- a/miscutils/man.c +++ b/miscutils/man.c @@ -73,7 +73,7 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) char *sec_list; char *cur_path, *cur_sect; char *line, *value; - int count_mp, alloc_mp, cur_mp; + int count_mp, cur_mp; int opt; opt_complementary = "-1"; /* at least one argument */ @@ -81,8 +81,8 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) argv += optind; sec_list = xstrdup("1:2:3:4:5:6:7:8:9"); - alloc_mp = 10; - man_path_list = xmalloc(10 * sizeof(man_path_list[0])); + /* Last valid man_path_list[] is [0x10] */ + man_path_list = xzalloc(0x11 * sizeof(man_path_list[0])); count_mp = 0; man_path_list[0] = xstrdup(getenv("MANPATH")); if (man_path_list[0]) @@ -107,11 +107,13 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) if (strcmp("MANPATH", line) == 0) { man_path_list[count_mp] = xstrdup(value); count_mp++; - if (alloc_mp == count_mp) { - alloc_mp += 10; - man_path_list = xrealloc(man_path_list, alloc_mp * sizeof(man_path_list[0])); + /* man_path_list is NULL terminated */ + man_path_list[count_mp] = NULL; + if (!(count_mp & 0xf)) { /* 0x10, 0x20 etc */ + /* so that last valid man_path_list[] is [count_mp + 0x10] */ + man_path_list = xrealloc(man_path_list, + (count_mp + 0x11) * sizeof(man_path_list[0])); } - /* thus man_path_list is always NULL terminated */ } if (strcmp("MANSECT", line) == 0) { free(sec_list); |