aboutsummaryrefslogtreecommitdiffstats
path: root/package/swconfig
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2011-01-08 17:30:33 +0000
committerGabor Juhos <juhosg@openwrt.org>2011-01-08 17:30:33 +0000
commitca574cb5173760bee624bceb403d8b181728041a (patch)
treeedcb5313987862ad66de258111cf9e43a962193c /package/swconfig
parent23a3294744e96739d49b6fe75b270af2377abd21 (diff)
downloadmaster-187ad058-ca574cb5173760bee624bceb403d8b181728041a.tar.gz
master-187ad058-ca574cb5173760bee624bceb403d8b181728041a.tar.bz2
master-187ad058-ca574cb5173760bee624bceb403d8b181728041a.zip
package/swconfig: add sanity checks to prevent a segfault
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@24932 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/swconfig')
-rw-r--r--package/swconfig/Makefile2
-rw-r--r--package/swconfig/src/swlib.c15
2 files changed, 16 insertions, 1 deletions
diff --git a/package/swconfig/Makefile b/package/swconfig/Makefile
index 24ebaee456..363b3a01fd 100644
--- a/package/swconfig/Makefile
+++ b/package/swconfig/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=swconfig
-PKG_RELEASE:=6
+PKG_RELEASE:=7
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
diff --git a/package/swconfig/src/swlib.c b/package/swconfig/src/swlib.c
index 59456a33d9..c2316d0686 100644
--- a/package/swconfig/src/swlib.c
+++ b/package/swconfig/src/swlib.c
@@ -368,11 +368,26 @@ int swlib_set_attr_string(struct switch_dev *dev, struct switch_attr *a, int por
ptr = (char *)str;
while(ptr && *ptr)
{
+ while(*ptr && isspace(*ptr))
+ ptr++;
+
+ if (!*ptr)
+ break;
+
+ if (!isdigit(*ptr))
+ return -1;
+
+ if (val.len >= dev->ports)
+ return -1;
+
ports[val.len].flags = 0;
ports[val.len].id = strtoul(ptr, &ptr, 10);
while(*ptr && !isspace(*ptr)) {
if (*ptr == 't')
ports[val.len].flags |= SWLIB_PORT_FLAG_TAGGED;
+ else
+ return -1;
+
ptr++;
}
if (*ptr)