diff --git a/release/src-rt-6.x.4708/router/wanuptime/wanuptime.c b/release/src-rt-6.x.4708/router/wanuptime/wanuptime.c index 355bf04748..63190ac253 100644 --- a/release/src-rt-6.x.4708/router/wanuptime/wanuptime.c +++ b/release/src-rt-6.x.4708/router/wanuptime/wanuptime.c @@ -13,23 +13,20 @@ int main(int argc, char *argv[]) char prefix[] = "wanXX"; if (argc > 1) - strcpy(prefix, argv[1]); + strlcpy(prefix, argv[0], sizeof(prefix)); else - strcpy(prefix, "wan"); + strlcpy(prefix, "wan", sizeof(prefix)); memset(wantime_file, 0, sizeof(wantime_file)); - sprintf(wantime_file, "/var/lib/misc/%s_time", prefix); + snprintf(wantime_file, sizeof(wantime_file), "/var/lib/misc/%s_time", prefix); - if (sysinfo(&si) == -1) { + if (sysinfo(&si) == -1) return 1; - } - if (check_wanup(prefix) && f_read(wantime_file, &uptime, sizeof(time_t)) == sizeof(uptime)) { + if (check_wanup(prefix) && f_read(wantime_file, &uptime, sizeof(time_t)) == sizeof(uptime)) printf("%ld\n", si.uptime - uptime); - } - else { + else printf("0\n"); - } return 0; }