Commit 3bfa73ff authored by Stephen Hemminger's avatar Stephen Hemminger

rtnl fd check

Prevent accidental damage from rtnl library if fd is uninitialized.
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
parent 77219712
......@@ -36,7 +36,7 @@ int timestamp = 0;
char * _SL_ = NULL;
char *batch_file = NULL;
int force = 0;
struct rtnl_handle rth;
struct rtnl_handle rth = { .fd = -1 };
static void usage(void) __attribute__((noreturn));
......
......@@ -27,7 +27,10 @@
void rtnl_close(struct rtnl_handle *rth)
{
close(rth->fd);
if (rth->fd >= 0) {
close(rth->fd);
rth->fd = -1;
}
}
int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment