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 2021/07/01 14:22:46 UTC

[incubator-nuttx-apps] branch master updated: netutils/ftpc: ftpc_getfile: Fixed permission check and resume offset.

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


The following commit(s) were added to refs/heads/master by this push:
     new 5b1a4a3  netutils/ftpc: ftpc_getfile: Fixed permission check and resume offset.
5b1a4a3 is described below

commit 5b1a4a3832a24f8e01a06108b75501b903ab8074
Author: Atsunori Saito <sa...@yedo.com>
AuthorDate: Sun Jun 27 15:38:52 2021 +0900

    netutils/ftpc: ftpc_getfile: Fixed permission check and resume offset.
---
 netutils/ftpc/ftpc_getfile.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/netutils/ftpc/ftpc_getfile.c b/netutils/ftpc/ftpc_getfile.c
index fb1b3ef..968ff62 100644
--- a/netutils/ftpc/ftpc_getfile.c
+++ b/netutils/ftpc/ftpc_getfile.c
@@ -255,6 +255,8 @@ int ftpc_getfile(SESSION handle, FAR const char *rname,
       goto errout;
     }
 
+  offset = 0;
+
   /* Get information about the local file */
 
   ret = stat(abslpath, &statbuf);
@@ -267,29 +269,25 @@ int ftpc_getfile(SESSION handle, FAR const char *rname,
           nwarn("WARNING: '%s' is a directory\n", abslpath);
           goto errout_with_abspath;
         }
-    }
 
-  /* Is it write-able? */
+      /* Is it write-able? */
 
 #ifdef S_IWRITE
-  if (!(statbuf.st_mode & S_IWRITE))
-    {
-      nwarn("WARNING: '%s' permission denied\n", abslpath);
-      goto errout_with_abspath;
-    }
+      if (!(statbuf.st_mode & S_IWRITE))
+        {
+          nwarn("WARNING: '%s' permission denied\n", abslpath);
+          goto errout_with_abspath;
+        }
 #endif
 
-  /* Are we resuming the transfers?  Is so then the starting offset is the
-   * size of the existing, partial file.
-   */
+      /* Are we resuming the transfers?  Is so then the starting offset is
+       * the size of the existing, partial file.
+       */
 
-  if (how == FTPC_GET_RESUME)
-    {
-      offset = statbuf.st_size;
-    }
-  else
-    {
-      offset = 0;
+      if (how == FTPC_GET_RESUME)
+        {
+          offset = statbuf.st_size;
+        }
     }
 
   /* Setup to receive the file */