summaryrefslogtreecommitdiff
path: root/src/udev/net/link-config.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-10-29 16:20:22 +0100
committerTom Gundersen <teg@jklm.no>2013-10-29 16:21:57 +0100
commitf1ac700248f231b7bdac2aafe8c35650efddb89f (patch)
treef949d07bb1f5aa72d5d433e0babdf6a0c5d3d2ca /src/udev/net/link-config.c
parent2a7e74e002d0df6d7021240d3310220bd19aa3fe (diff)
udev: link-config - use safe_atou instead of strtoul
Diffstat (limited to 'src/udev/net/link-config.c')
-rw-r--r--src/udev/net/link-config.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 985fc7d47a..a86c74d5f7 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -322,12 +322,15 @@ static bool enable_name_policy(void) {
static bool mac_is_random(struct udev_device *device) {
const char *s;
- int type;
+ unsigned type;
+ int r;
s = udev_device_get_sysattr_value(device, "addr_assign_type");
if (!s)
- return -EINVAL;
- type = strtoul(s, NULL, 0);
+ return false; /* if we don't know, assume it is not random */
+ r = safe_atou(s, &type);
+ if (r < 0)
+ return false;
/* check for NET_ADDR_RANDOM */
return type == 1;
@@ -335,12 +338,15 @@ static bool mac_is_random(struct udev_device *device) {
static bool mac_is_permanent(struct udev_device *device) {
const char *s;
- int type;
+ unsigned type;
+ int r;
s = udev_device_get_sysattr_value(device, "addr_assign_type");
if (!s)
- return -EINVAL;
- type = strtoul(s, NULL, 0);
+ return true; /* if we don't know, assume it is permanent */
+ r = safe_atou(s, &type);
+ if (r < 0)
+ return true;
/* check for NET_ADDR_PERM */
return type == 0;