diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-11 12:19:14 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-11 12:19:14 +0000 |
commit | dee8587d9208e4ea5ba8f8bb73b555007529372e (patch) | |
tree | 303d21aeec9e3922e296ecc9041598a87a79b554 /miscutils | |
parent | f941306199d7cb00be68483169f202432a9a9a7d (diff) | |
download | busybox-w32-dee8587d9208e4ea5ba8f8bb73b555007529372e.tar.gz busybox-w32-dee8587d9208e4ea5ba8f8bb73b555007529372e.tar.bz2 busybox-w32-dee8587d9208e4ea5ba8f8bb73b555007529372e.zip |
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 612f50488..da353fbb1 100644 --- a/miscutils/last.c +++ b/miscutils/last.c | |||
@@ -117,6 +117,8 @@ int last_main(int argc, char **argv ATTRIBUTE_UNUSED) | |||
117 | strcpy(ut.ut_line, "system boot"); | 117 | strcpy(ut.ut_line, "system boot"); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | /* manpages say ut_tv.tv_sec *is* time_t, | ||
121 | * but some systems have it wrong */ | ||
120 | t_tmp = (time_t)ut.ut_tv.tv_sec; | 122 | t_tmp = (time_t)ut.ut_tv.tv_sec; |
121 | printf("%-10s %-14s %-18s %-12.12s\n", | 123 | printf("%-10s %-14s %-18s %-12.12s\n", |
122 | ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4); | 124 | 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 2b7fee6e5..d4d35b19a 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) | |||
48 | char logout_time[8]; | 48 | char logout_time[8]; |
49 | const char *logout_str; | 49 | const char *logout_str; |
50 | const char *duration_str; | 50 | const char *duration_str; |
51 | time_t tmp; | ||
51 | 52 | ||
52 | safe_strncpy(login_time, ctime(&(ut->ut_tv.tv_sec)), 17); | 53 | /* manpages say ut_tv.tv_sec *is* time_t, |
54 | * but some systems have it wrong */ | ||
55 | tmp = ut->ut_tv.tv_sec; | ||
56 | safe_strncpy(login_time, ctime(&tmp), 17); | ||
53 | snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11); | 57 | snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11); |
54 | 58 | ||
55 | dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0); | 59 | 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 278e5a336..dc8fa449d 100644 --- a/miscutils/man.c +++ b/miscutils/man.c | |||
@@ -73,7 +73,7 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
73 | char *sec_list; | 73 | char *sec_list; |
74 | char *cur_path, *cur_sect; | 74 | char *cur_path, *cur_sect; |
75 | char *line, *value; | 75 | char *line, *value; |
76 | int count_mp, alloc_mp, cur_mp; | 76 | int count_mp, cur_mp; |
77 | int opt; | 77 | int opt; |
78 | 78 | ||
79 | opt_complementary = "-1"; /* at least one argument */ | 79 | opt_complementary = "-1"; /* at least one argument */ |
@@ -81,8 +81,8 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
81 | argv += optind; | 81 | argv += optind; |
82 | 82 | ||
83 | sec_list = xstrdup("1:2:3:4:5:6:7:8:9"); | 83 | sec_list = xstrdup("1:2:3:4:5:6:7:8:9"); |
84 | alloc_mp = 10; | 84 | /* Last valid man_path_list[] is [0x10] */ |
85 | man_path_list = xmalloc(10 * sizeof(man_path_list[0])); | 85 | man_path_list = xzalloc(0x11 * sizeof(man_path_list[0])); |
86 | count_mp = 0; | 86 | count_mp = 0; |
87 | man_path_list[0] = xstrdup(getenv("MANPATH")); | 87 | man_path_list[0] = xstrdup(getenv("MANPATH")); |
88 | if (man_path_list[0]) | 88 | if (man_path_list[0]) |
@@ -107,11 +107,13 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
107 | if (strcmp("MANPATH", line) == 0) { | 107 | if (strcmp("MANPATH", line) == 0) { |
108 | man_path_list[count_mp] = xstrdup(value); | 108 | man_path_list[count_mp] = xstrdup(value); |
109 | count_mp++; | 109 | count_mp++; |
110 | if (alloc_mp == count_mp) { | 110 | /* man_path_list is NULL terminated */ |
111 | alloc_mp += 10; | 111 | man_path_list[count_mp] = NULL; |
112 | man_path_list = xrealloc(man_path_list, alloc_mp * sizeof(man_path_list[0])); | 112 | if (!(count_mp & 0xf)) { /* 0x10, 0x20 etc */ |
113 | /* so that last valid man_path_list[] is [count_mp + 0x10] */ | ||
114 | man_path_list = xrealloc(man_path_list, | ||
115 | (count_mp + 0x11) * sizeof(man_path_list[0])); | ||
113 | } | 116 | } |
114 | /* thus man_path_list is always NULL terminated */ | ||
115 | } | 117 | } |
116 | if (strcmp("MANSECT", line) == 0) { | 118 | if (strcmp("MANSECT", line) == 0) { |
117 | free(sec_list); | 119 | free(sec_list); |