From d3dcde2585cd26642aa236ed94442c838b8b7471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80=D0=B3=20?= =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=BA=20=28=D0=BD=D0=BE=D1=83=D1=82=D0=B1?= =?UTF-8?q?=D1=83=D0=BA=20=D0=B4=D0=BE=D0=BC=D0=B0=29?= Date: Fri, 8 Jun 2012 00:58:14 +0600 Subject: [PATCH] rtnl_netem_set_delay_distribution: fix possible segfault fix counting of elements in array. Just typo, as I think. --- lib/route/qdisc/netem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/route/qdisc/netem.c b/lib/route/qdisc/netem.c index 997a31f..5f26096 100644 --- a/lib/route/qdisc/netem.c +++ b/lib/route/qdisc/netem.c @@ -826,7 +826,7 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist if (!(netem = rtnl_tc_data(TC_CAST(qdisc)))) BUG(); - FILE *f = NULL; + FILE *f; int i, n = 0; size_t len = 2048; char *line; @@ -841,9 +841,10 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist /* Check several locations for the dist file */ char *test_path[] = { "", "./", "/usr/lib/tc/", "/usr/local/lib/tc/" }; - for (i = 0; i < sizeof(test_path) && f == NULL; i++) { + for (i = 0; i < sizeof(test_path)/sizeof(test_path[0]); i++) { snprintf(name, NAME_MAX, "%s%s%s", test_path[i], dist_type, dist_suffix); - f = fopen(name, "r"); + if ((f = fopen(name, "r"))) + break; } if ( f == NULL )