diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-02-25 17:11:18 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-02-25 17:11:18 +0100 |
commit | b2d79920255fc405b972e4c900e47f4a1046e044 (patch) | |
tree | b0ee1c462368b365880b6adb2fb8ea6b64b5336f /sys/src/9/port/devloopback.c | |
parent | d3f4786a1fcfb3cf8eba0cad2457622c6487e0e9 (diff) |
kernel: properly handle bad attach specifiers
- only accept decimal for numeric device id's
- exclude negative device id's
- device id's out of range yield Enodev
Diffstat (limited to 'sys/src/9/port/devloopback.c')
-rw-r--r-- | sys/src/9/port/devloopback.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/src/9/port/devloopback.c b/sys/src/9/port/devloopback.c index 76f37890a..c251387a3 100644 --- a/sys/src/9/port/devloopback.c +++ b/sys/src/9/port/devloopback.c @@ -121,14 +121,11 @@ loopbackattach(char *spec) Queue *q; Chan *c; int chan; - int dev; + ulong dev; - dev = 0; - if(spec != nil){ - dev = atoi(spec); - if(dev >= Nloopbacks) - error(Ebadspec); - } + dev = strtoul(spec, nil, 10); + if(dev >= Nloopbacks) + error(Enodev); c = devattach('X', spec); if(waserror()){ |