diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-01-26 16:48:09 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-01-26 16:48:09 +0100 |
commit | ff183e701599e6ca44f5fa78b60948f87a08a133 (patch) | |
tree | 08d0bc17bf38227aae71eb991696ecd1c2d20f08 /src | |
parent | da31c063de92d725bf706bb8ed7a79f9e03f8755 (diff) | |
download | fastd-ff183e701599e6ca44f5fa78b60948f87a08a133.tar fastd-ff183e701599e6ca44f5fa78b60948f87a08a133.zip |
Don't use atoi for interface indexes
Diffstat (limited to 'src')
-rw-r--r-- | src/socket.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/socket.c b/src/socket.c index a9e6f33..744945e 100644 --- a/src/socket.c +++ b/src/socket.c @@ -108,9 +108,10 @@ static int bind_socket(fastd_context_t *ctx, const fastd_bind_address_t *addr, b fastd_peer_address_t bind_address = addr->addr; if (fastd_peer_address_is_v6_ll(&addr->addr) && addr->bindtodev) { - bind_address.in6.sin6_scope_id = atoi(addr->bindtodev); + char *end; + bind_address.in6.sin6_scope_id = strtoul(addr->bindtodev, &end, 10); - if (!bind_address.in6.sin6_scope_id) + if (*end) bind_address.in6.sin6_scope_id = if_nametoindex(addr->bindtodev); if (!bind_address.in6.sin6_scope_id) { |