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

MmsFileService: Don't use file size on read #526

Open
wants to merge 2 commits into
base: v1.6
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion hal/ethernet/linux/ethernet_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Ethernet_createSocket(const char* interfaceId, uint8_t* destAddress)

if (self)
{
self->rawSocket = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
self->rawSocket = socket(AF_PACKET, SOCK_RAW, 0);

if (self->rawSocket == -1)
{
Expand Down
14 changes: 3 additions & 11 deletions src/mms/iso_mms/server/mms_file_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,22 +826,14 @@ void
mmsMsg_createFileReadResponse(int maxPduSize, uint32_t invokeId,
ByteBuffer* response, MmsFileReadStateMachine* frsm)
{
/* determine remaining bytes in file */
uint32_t bytesLeft = frsm->fileSize - frsm->readPosition;

uint32_t fileChunkSize = 0;

uint32_t maxFileChunkSize = maxPduSize - 20;

uint32_t fileReadResponseSize = 1; /* for tag */

bool moreFollows = true;

if (bytesLeft > maxFileChunkSize) {
fileChunkSize = maxFileChunkSize;
}
else {
fileChunkSize = bytesLeft;
uint32_t fileChunkSize = FileSystem_readFile(frsm->fileHandle, response->buffer + 20, maxFileChunkSize);
if (fileChunkSize != maxFileChunkSize) {
moreFollows = false;
fileReadResponseSize += 3; /* for moreFollows */
}
Expand Down Expand Up @@ -869,7 +861,7 @@ mmsMsg_createFileReadResponse(int maxPduSize, uint32_t invokeId,
bufPos = BerEncoder_encodeTL(0x49, fileReadResponseSize, buffer, bufPos);

bufPos = BerEncoder_encodeTL(0x80, fileChunkSize, buffer, bufPos);
FileSystem_readFile(frsm->fileHandle, buffer + bufPos, fileChunkSize);
memmove(buffer + bufPos, buffer + 20, fileChunkSize);
bufPos += fileChunkSize;

if (!moreFollows)
Expand Down