diff --git a/src/wolfsftp.c b/src/wolfsftp.c index 2e4d00f1e..ddd9137ca 100644 --- a/src/wolfsftp.c +++ b/src/wolfsftp.c @@ -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) @@ -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 @@ -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