summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorКоренберг Марк (ноутбук дома) <socketpair@gmail.com>2012-06-07 18:58:14 (GMT)
committerКоренберг Марк (ноутбук дома) <socketpair@gmail.com>2012-06-07 19:38:53 (GMT)
commitd3dcde2585cd26642aa236ed94442c838b8b7471 (patch)
treec9f41d84ec292d31a1a16a14d9a7311b3cb19aec /lib
parent2275bb0aaaf40bcf617fbf4bfd47ea5ae2d00fe6 (diff)
downloadlibnl-d3dcde2585cd26642aa236ed94442c838b8b7471.zip
libnl-d3dcde2585cd26642aa236ed94442c838b8b7471.tar.gz
libnl-d3dcde2585cd26642aa236ed94442c838b8b7471.tar.bz2
rtnl_netem_set_delay_distribution: fix possible segfault
fix counting of elements in array. Just typo, as I think.
Diffstat (limited to 'lib')
-rw-r--r--lib/route/qdisc/netem.c7
1 files 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 )