Skip to content

Commit

Permalink
Merge remote-tracking branch 'ssvine/fix-ftp-crash'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellukashov committed Mar 22, 2024
2 parents 1202141 + 27e2a4f commit f4413d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/FtpFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ void TFTPFileSystem::ReadCurrentDirectory()
// and immediately after call to CWD,
// later our current directory may be not synchronized with FZAPI current
// directory anyway, see comments in EnsureLocation
if (FReadCurrentDirectory || DebugAlwaysFalse(FCurrentDirectory.IsEmpty()))
if (FReadCurrentDirectory || FCurrentDirectory.IsEmpty())
{
const UnicodeString Command = "PWD";
SendCommand(Command);
Expand Down
8 changes: 4 additions & 4 deletions src/filezilla/AsyncProxySocketLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void CAsyncProxySocketLayer::OnReceive(int nErrorCode)
int32_t sz = nb::safe_strlen(tmp) + nb::safe_strlen(buffer);
m_pStrBuffer = nb::chcalloc(sz + 1);
strncpy_s(m_pStrBuffer, sz + 1, tmp, nb::safe_strlen(tmp));
strncpy_s(m_pStrBuffer + nb::safe_strlen(tmp), sz - nb::safe_strlen(buffer), buffer, nb::safe_strlen(buffer));
strncpy_s(m_pStrBuffer + nb::safe_strlen(tmp), sz - nb::safe_strlen(tmp) + 1, buffer, nb::safe_strlen(buffer));
nb_free(tmp);
}
memset(buffer, 0, 9);
Expand Down Expand Up @@ -510,7 +510,7 @@ void CAsyncProxySocketLayer::OnReceive(int nErrorCode)
{
char *tmp = nb::chcalloc(pos-m_pStrBuffer + 1);
tmp[pos-m_pStrBuffer] = 0;
strncpy_s(tmp, pos-m_pStrBuffer, m_pStrBuffer, nb::safe_strlen(m_pStrBuffer));
strncpy_s(tmp, pos-m_pStrBuffer + 1, m_pStrBuffer, nb::safe_strlen(m_pStrBuffer));
ConnectionFailed(WSAECONNABORTED, tmp);
return;
}
Expand Down Expand Up @@ -615,7 +615,7 @@ BOOL CAsyncProxySocketLayer::Connect( LPCTSTR lpszHostAddress, UINT nHostPort )
{
nb_free(m_pProxyPeerHost);
m_pProxyPeerHost = nb::chcalloc(nb::safe_strlen(T2CA(lpszHostAddress))+1);
strncpy_s(m_pProxyPeerHost, nb::safe_strlen(T2CA(lpszHostAddress)), T2CA(lpszHostAddress), nb::safe_strlen(lpszHostAddress));
strncpy_s(m_pProxyPeerHost, nb::safe_strlen(T2CA(lpszHostAddress))+1, T2CA(lpszHostAddress), nb::safe_strlen(lpszHostAddress));
}
return res;

Expand Down Expand Up @@ -708,7 +708,7 @@ void CAsyncProxySocketLayer::OnConnect(int nErrorCode)
command[6]=0;
command[7]=1;
//Add host as URL
strncpy_s(&command[9], nb::safe_strlen(lpszAscii), lpszAscii, nb::safe_strlen(lpszAscii));
strncpy_s(&command[9], nb::safe_strlen(lpszAscii)+1, lpszAscii, nb::safe_strlen(lpszAscii));
len+=(int)nb::safe_strlen(lpszAscii)+1;
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/filezilla/FtpListResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ bool CFtpListResult::ParseShortDate(const char *str, int len, t_directory::t_dir
if (!numeric)
{
char *tmpstr = nb::chcalloc(i + 1);
strncpy_s(tmpstr, i, str, i);
strncpy_s(tmpstr, i + 1, str, i);
tmpstr[i] = 0;
strlwr(tmpstr);

Expand Down Expand Up @@ -1334,7 +1334,7 @@ BOOL CFtpListResult::parseAsUnix(const char *line, const int linelen, t_director
//Maybe the server has left no space between the group and the size
//because of stupid alignment
char *tmpstr = nb::chcalloc(tokenlen + 1);
strncpy_s(tmpstr, tokenlen, str, tokenlen);
strncpy_s(tmpstr, tokenlen + 1, str, tokenlen);
tmpstr[tokenlen] = 0;
strlwr(tmpstr);

Expand Down

0 comments on commit f4413d5

Please sign in to comment.