Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RDir usage for 64 bit file sizes #24

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions ClientCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,23 @@ void CDir::sendRequest()
if (m_response.m_result == KErrNone)
{
char *name;
uint32_t size;
TInt64 size;
unsigned char *payload = m_responsePayload, *payloadEnd = m_responsePayload + m_response.m_size;

printf("payloadSize = %u\n", m_response.m_size);

/* Iterate through the file information in the payload and display its contents. Provided the payload */
/* is structured correctly, we could just check for it being ended by NULL terminator, but in the */
/* interest of safety, we'll also check that we haven't overrun the end */
while (payload < payloadEnd && *payload != '\0')
{
name = reinterpret_cast<char *>(payload);
printf("%s\n", name);
payload += strlen(name) + 1;
READ_INT(size, payload);
READ_INT_64(size, payload);
payload += sizeof(size);
printf("%s %d\n", name, size);
printf("%s %lld\n", name, size);
printf("%s %u %x\n", name, (uint32_t) size, (uint32_t) size);

ASSERTM((payload < payloadEnd), "CDir::sendRequest() => Payload contents do not match its size");
}
Expand Down
12 changes: 8 additions & 4 deletions ServerCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void CDir::execute()
if ((result = dir.read(entries, EDirSortNameAscending)) == KErrNone)
{
char *payload;
size_t offset = 0;
size_t nameLength, offset = 0;
uint32_t payloadSize = 1;

/* Iterate through the list of files and determine the amount of memory required to store the filenames */
Expand All @@ -81,15 +81,19 @@ void CDir::execute()
}

/* Allocate a buffer large enough to hold the response payload and fill it with the file information */
printf("payloadSize = %u\n", payloadSize);
payload = new char[payloadSize];

entry = entries->getHead();

while (entry != nullptr)
{
memcpy(payload + offset, entry->iName, strlen(entry->iName) + 1);
offset += strlen(entry->iName) + 1;
WRITE_INT((payload + offset), entry->iSize);
nameLength = strlen(entry->iName);
printf("Adding %s of length %lld\n", entry->iName, entry->iSize);
printf("Adding %s of length %u %x\n", entry->iName, (uint32_t) entry->iSize, (uint32_t) entry->iSize);
memcpy(payload + offset, entry->iName, nameLength + 1);
offset += nameLength + 1;
WRITE_INT_64((payload + offset), entry->iSize);
offset += sizeof(entry->iSize);

entry = entries->getSucc(entry);
Expand Down