Skip to content

Commit

Permalink
Merge pull request #563 from JacobBarthelmeh/sftp-win
Browse files Browse the repository at this point in the history
fix file offest on Windows and change offset increment
  • Loading branch information
dgarske authored Aug 7, 2023
2 parents 825b33d + f018455 commit e089f2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -13220,9 +13220,13 @@ int wolfSSH_oct2dec(WOLFSSH* ssh, byte* oct, word32 octSz)
/* addend1 += addend2 */
void AddAssign64(word32* addend1, word32 addend2)
{
word32 tmp = addend1[0];
if ((addend1[0] += addend2) < tmp)
if (addend1[0] > (WOLFSSL_MAX_32BIT - addend2)) {
addend1[1]++;
addend1[0] = addend2 - (WOLFSSL_MAX_32BIT- addend1[0]);
}
else {
addend1[0] += addend2;
}
}

#endif /* WOLFSSH_SFTP */
4 changes: 2 additions & 2 deletions src/wolfsftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -8378,7 +8378,7 @@ int wolfSSH_SFTP_Put(WOLFSSH* ssh, char* from, char* to, byte resume,
}
if (resume) {
WMEMSET(&state->offset, 0, sizeof(OVERLAPPED));
state->offset.OffsetHigh = 0;
state->offset.OffsetHigh = state->pOfst[1];
state->offset.Offset = state->pOfst[0];
}
#endif /* USE_WINDOWS_API */
Expand Down Expand Up @@ -8434,7 +8434,7 @@ int wolfSSH_SFTP_Put(WOLFSSH* ssh, char* from, char* to, byte resume,
else {
AddAssign64(state->pOfst, sz);
#ifdef USE_WINDOWS_API
state->offset.OffsetHigh = 0;
state->offset.OffsetHigh = state->pOfst[1];
state->offset.Offset = state->pOfst[0];
#endif /* USE_WINDOWS_API */
state->rSz -= sz;
Expand Down

0 comments on commit e089f2d

Please sign in to comment.