[spp] [PATCH 1/5] shared: add error handling for invalid res UID

ogawa.yasufumi at lab.ntt.co.jp ogawa.yasufumi at lab.ntt.co.jp
Tue Oct 9 12:52:03 CEST 2018


From: Yasufumi Ogawa <ogawa.yasufumi at lab.ntt.co.jp>

There is no checking for the format of resource UID. It is caused
segmentation fault if invalid resouce UID is given to
parse_resource_uid(). This update is to add the validation and error
handling.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi at lab.ntt.co.jp>
---
 src/shared/common.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/shared/common.c b/src/shared/common.c
index c78ee7b..bf776ee 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -228,6 +228,13 @@ parse_resource_uid(char *str, char **port_type, int *port_id)
 	char delim[] = ":";
 	char *endp;
 
+	RTE_LOG(DEBUG, APP, "Parsing resource UID: '%s\n'", str);
+	if (strstr(str, delim) == NULL) {
+		RTE_LOG(ERR, APP, "Invalid resource UID: '%s'\n", str);
+		return -1;
+	}
+	RTE_LOG(DEBUG, APP, "Delimiter %s is included\n", delim);
+
 	*port_type = strtok(str, delim);
 
 	token = strtok(NULL, delim);
-- 
2.7.4



More information about the spp mailing list