Skip to content

Commit

Permalink
Merge pull request #548 from falemagn/pull-reqs/48833f4_Support_large…
Browse files Browse the repository at this point in the history
…_file_sizes_in_long_file_names

Support large file sizes in long file names.
  • Loading branch information
SparkiDev authored Aug 22, 2023
2 parents 601682c + efa7188 commit 6ff7022
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/wolfsftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,7 @@ static void getDate(char* buf, int len, struct tm* t)
* return WS_SUCCESS on success */
static int SFTP_CreateLongName(WS_SFTPNAME* name)
{
char sizeStr[32];
char perm[11];
int linkCount = 1; /* @TODO set to correct value */
#if defined(XGMTIME) && defined(XSNPRINTF)
Expand Down Expand Up @@ -2553,7 +2554,9 @@ static int SFTP_CreateLongName(WS_SFTPNAME* name)

totalSz += name->fSz; /* size of file name */
totalSz += 7; /* for all ' ' spaces */
totalSz += 3 + 8 + 8 + 8; /* linkCount + uid + gid + size */
totalSz += 3 + 8 + 8; /* linkCount + uid + gid */
WSNPRINTF(sizeStr, sizeof(sizeStr) - 1, "%8lld", ((long long int)atr->sz[1] << 32) + (long long int)(atr->sz[0]));
totalSz += WSTRLEN(sizeStr);
#else
totalSz = name->fSz;
#endif
Expand All @@ -2567,8 +2570,8 @@ static int SFTP_CreateLongName(WS_SFTPNAME* name)
name->lName[totalSz] = '\0';

#if defined(XGMTIME) && defined(XSNPRINTF)
WSNPRINTF(name->lName, totalSz, "%s %3d %8d %8d %8d %s %s",
perm, linkCount, atr->uid, atr->gid, atr->sz[0], date, name->fName);
WSNPRINTF(name->lName, totalSz, "%s %3d %8d %8d %s %s %s",
perm, linkCount, atr->uid, atr->gid, sizeStr, date, name->fName);
#else
WMEMCPY(name->lName, name->fName, totalSz);
#endif
Expand Down

0 comments on commit 6ff7022

Please sign in to comment.