You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/05/28 12:04:37 UTC

[incubator-nuttx-apps] branch master updated (a455f13 -> a49f951)

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

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


    from a455f13  webclient: Check the return value of netlib_parseurl correctly
     new 585d63b  netlib_parseurl: Fix pathlen check
     new a49f951  netlib_parsehttpurl: Fix pathlen check

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 netutils/netlib/netlib_parsehttpurl.c | 15 +++++++++++++--
 netutils/netlib/netlib_parseurl.c     | 15 +++++++++++++--
 2 files changed, 26 insertions(+), 4 deletions(-)


[incubator-nuttx-apps] 01/02: netlib_parseurl: Fix pathlen check

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 585d63b30d378dcf4277eac888d8c498a084b519
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu May 28 17:22:37 2020 +0900

    netlib_parseurl: Fix pathlen check
---
 netutils/netlib/netlib_parseurl.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/netutils/netlib/netlib_parseurl.c b/netutils/netlib/netlib_parseurl.c
index ee3299a..28a83d4 100644
--- a/netutils/netlib/netlib_parseurl.c
+++ b/netutils/netlib/netlib_parseurl.c
@@ -76,6 +76,7 @@ int netlib_parseurl(FAR const char *str, FAR struct url_s *url)
   FAR char *dest;
   int bytesleft;
   int ret = OK;
+  size_t pathlen;
 
   /* extract the protocol field, a set of a-z letters */
 
@@ -193,7 +194,17 @@ int netlib_parseurl(FAR const char *str, FAR struct url_s *url)
 
   /* The copy the rest of the file name to the user buffer */
 
-  strncpy(dest, src, bytesleft);
-  url->path[bytesleft - 1] = '\0';
+  pathlen = strlen(src);
+  if (bytesleft >= pathlen + 1)
+    {
+      memcpy(dest, src, pathlen);
+      dest[pathlen] = '\0';
+    }
+  else
+    {
+      dest[0] = '\0';
+      ret = -E2BIG;
+    }
+
   return ret;
 }


[incubator-nuttx-apps] 02/02: netlib_parsehttpurl: Fix pathlen check

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a49f951c8607ba30b779e5f10a1f27d3f03450a7
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu May 28 17:24:54 2020 +0900

    netlib_parsehttpurl: Fix pathlen check
---
 netutils/netlib/netlib_parsehttpurl.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/netutils/netlib/netlib_parsehttpurl.c b/netutils/netlib/netlib_parsehttpurl.c
index f3235de..06039ac 100644
--- a/netutils/netlib/netlib_parsehttpurl.c
+++ b/netutils/netlib/netlib_parsehttpurl.c
@@ -68,6 +68,7 @@ int netlib_parsehttpurl(FAR const char *url, FAR uint16_t *port,
   FAR char *dest;
   int bytesleft;
   int ret = OK;
+  size_t pathlen;
 
   /* A valid HTTP URL must begin with http:// if it does not, we will assume
    * that it is a file name only, but still return an error.  wget() depends
@@ -154,7 +155,17 @@ int netlib_parsehttpurl(FAR const char *url, FAR uint16_t *port,
 
   /* The copy the rest of the file name to the user buffer */
 
-  strncpy(dest, src, bytesleft);
-  filename[namelen-1] = '\0';
+  pathlen = strlen(src);
+  if (bytesleft >= pathlen + 1)
+    {
+      memcpy(dest, src, pathlen);
+      dest[pathlen] = '\0';
+    }
+  else
+    {
+      dest[0] = '\0';
+      ret = -E2BIG;
+    }
+
   return ret;
 }