You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/06/07 12:09:19 UTC

[incubator-nuttx-apps] 02/05: netlib_parseurl: Make the buffer size assumption explicit

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit f7b3eb5b44cda746ad8b91fa1ea70c3f970e3f1c
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Mon Jun 6 16:12:09 2022 +0900

    netlib_parseurl: Make the buffer size assumption explicit
---
 netutils/netlib/netlib_parseurl.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/netutils/netlib/netlib_parseurl.c b/netutils/netlib/netlib_parseurl.c
index ddb84a65a..775f2f189 100644
--- a/netutils/netlib/netlib_parseurl.c
+++ b/netutils/netlib/netlib_parseurl.c
@@ -63,6 +63,15 @@ int netlib_parseurl(FAR const char *str, FAR struct url_s *url)
   int ret = OK;
   size_t pathlen;
 
+  /* Each fields should have at least 1 byte to store
+   * the terminating NUL.
+   */
+
+  if (url->schemelen == 0 || url->hostlen == 0 || url->pathlen == 0)
+    {
+      return -EINVAL;
+    }
+
   /* extract the protocol field, a set of a-z letters */
 
   dest      = url->scheme;