From bff8694051bde4af01b5285fa44651d187f9d880 Mon Sep 17 00:00:00 2001
From: Koen Zandberg <koen@bergzand.net>
Date: Wed, 18 Jul 2018 15:19:47 +0200
Subject: [PATCH] sock_util: check path length in urlsplit

Add a length check to the path to ensure that it fits in the supplied
buffer in the urlsplit function
---
 sys/net/sock/sock_util.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/net/sock/sock_util.c b/sys/net/sock/sock_util.c
index 428de24820..e60c972fa4 100644
--- a/sys/net/sock/sock_util.c
+++ b/sys/net/sock/sock_util.c
@@ -137,6 +137,9 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath)
 
     size_t pathlen = strlen(pathstart);
     if (pathlen) {
+        if (pathlen > SOCK_URLPATH_MAXLEN - 1) {
+            return -EOVERFLOW;
+        }
         memcpy(urlpath, pathstart, pathlen);
     }
     *(urlpath + pathlen) = '\0';
-- 
GitLab