summaryrefslogtreecommitdiffhomepage
path: root/wireless.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-12-01 10:53:13 +0100
committerFelix Fietkau <nbd@openwrt.org>2013-12-01 10:53:13 +0100
commit5c2cc14f85df74d971979b45265173f067f1e971 (patch)
treee44725fda9c6681dd00381cf910cf47f22766890 /wireless.c
parentfba9c88b995957b8109889f4747c7fe942fd5812 (diff)
wireless: add input validation for processes
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'wireless.c')
-rw-r--r--wireless.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/wireless.c b/wireless.c
index 7cc832d..273d54b 100644
--- a/wireless.c
+++ b/wireless.c
@@ -709,6 +709,7 @@ wireless_device_add_process(struct wireless_device *wdev, struct blob_attr *data
struct blob_attr *tb[__PROC_ATTR_MAX];
struct wireless_process *proc;
char *name;
+ int pid;
if (!data)
return UBUS_STATUS_INVALID_ARGUMENT;
@@ -717,10 +718,14 @@ wireless_device_add_process(struct wireless_device *wdev, struct blob_attr *data
if (!tb[PROC_ATTR_PID] || !tb[PROC_ATTR_EXE])
return UBUS_STATUS_INVALID_ARGUMENT;
+ pid = blobmsg_get_u32(tb[PROC_ATTR_PID]);
+ if (pid < 2)
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
proc = calloc_a(sizeof(*proc),
&name, strlen(blobmsg_data(tb[PROC_ATTR_EXE])) + 1);
- proc->pid = blobmsg_get_u32(tb[PROC_ATTR_PID]);
+ proc->pid = pid;
proc->exe = strcpy(name, blobmsg_data(tb[PROC_ATTR_EXE]));
if (tb[PROC_ATTR_REQUIRED])