netutils/ftpc: ftpc_getfile: Fixed permission check and resume offset.

This commit is contained in:
Atsunori Saito 2021-06-27 15:38:52 +09:00 committed by Xiang Xiao
parent 7fdd751b7a
commit 5b1a4a3832

View File

@ -255,6 +255,8 @@ int ftpc_getfile(SESSION handle, FAR const char *rname,
goto errout; goto errout;
} }
offset = 0;
/* Get information about the local file */ /* Get information about the local file */
ret = stat(abslpath, &statbuf); 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); nwarn("WARNING: '%s' is a directory\n", abslpath);
goto errout_with_abspath; goto errout_with_abspath;
} }
}
/* Is it write-able? */ /* Is it write-able? */
#ifdef S_IWRITE #ifdef S_IWRITE
if (!(statbuf.st_mode & S_IWRITE)) if (!(statbuf.st_mode & S_IWRITE))
{ {
nwarn("WARNING: '%s' permission denied\n", abslpath); nwarn("WARNING: '%s' permission denied\n", abslpath);
goto errout_with_abspath; goto errout_with_abspath;
} }
#endif #endif
/* Are we resuming the transfers? Is so then the starting offset is the /* Are we resuming the transfers? Is so then the starting offset is
* size of the existing, partial file. * the size of the existing, partial file.
*/ */
if (how == FTPC_GET_RESUME) if (how == FTPC_GET_RESUME)
{ {
offset = statbuf.st_size; offset = statbuf.st_size;
} }
else
{
offset = 0;
} }
/* Setup to receive the file */ /* Setup to receive the file */