From daf7bd5c73aa3b7c91d83abf500c8749bec6e6d5 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 23 Aug 2010 09:13:05 -0700 Subject: [PATCH] Use correct rt_link_statistics In recent kernels, net_device_stats is not exposed and the code shoulf have used rt_link_statistics. Also, fix use of sprintf with user supplied value. --- misc/ifstat.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/misc/ifstat.c b/misc/ifstat.c index 0ce8c928..5cf2e010 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -29,7 +29,8 @@ #include #include -#include +#include +#include #include @@ -48,7 +49,7 @@ int npatterns; char info_source[128]; int source_mismatch; -#define MAXS (sizeof(struct net_device_stats)/sizeof(unsigned long)) +#define MAXS (sizeof(struct rtnl_link_stats)/sizeof(unsigned long)) struct ifstat_ent { @@ -677,9 +678,11 @@ int main(int argc, char *argv[]) npatterns = argc; if (getenv("IFSTAT_HISTORY")) - snprintf(hist_name, sizeof(hist_name), getenv("IFSTAT_HISTORY")); + snprintf(hist_name, sizeof(hist_name), + "%s", getenv("IFSTAT_HISTORY")); else - sprintf(hist_name, "%s/.ifstat.u%d", P_tmpdir, getuid()); + snprintf(hist_name, sizeof(hist_name), + "%s/.ifstat.u%d", P_tmpdir, getuid()); if (reset_history) unlink(hist_name);