Skip to content

Commit

Permalink
Fix crash when meta information is split across two subsequent http b…
Browse files Browse the repository at this point in the history
…uffers.
  • Loading branch information
Fishpond committed May 13, 2017
1 parent 71f9192 commit ee7931d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ V_MAJOR = 0
V_MIDDLE = 0
V_MINOR = 3
V_VARIETY = B_APPV_DEVELOPMENT
V_BUILD = 12
V_BUILD = 13

TARGET_DIR := ./dist
PACKAGE = $(TARGET_DIR)/$(NAME)_$(VERSION)-$(ARCH).hpkg
Expand Down
8 changes: 2 additions & 6 deletions StreamIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ StreamIO::DataWithMetaReceived(BUrlRequest* request, const char* data, off_t pos
if (fUntilMetaEnd <= size) {
memcpy(fMetaBuffer + fMetaSize, (void*)data, fUntilMetaEnd);
data += fUntilMetaEnd;
position += fUntilMetaEnd;
size -= fUntilMetaEnd;
fMetaSize += fUntilMetaEnd;
fMetaBuffer[fMetaSize] = 0;
Expand All @@ -214,9 +213,8 @@ StreamIO::DataWithMetaReceived(BUrlRequest* request, const char* data, off_t pos
memcpy(fMetaBuffer + fMetaSize, (void*)data, size);
fMetaSize += size;
data += size;
size = 0;
position += size;
fUntilMetaEnd -= size;
size = 0;
}
} else {
DataFunc nextFunc = fDataFuncs.Item(next);
Expand All @@ -235,15 +233,13 @@ StreamIO::DataWithMetaReceived(BUrlRequest* request, const char* data, off_t pos
fUntilMetaStart = fMetaInt;
TRACE("Meta: Empty\n");
} else if (fUntilMetaEnd > 512) {
TRACE("Meta: Size of %" B_PRIdOFF " too large\n", fUntilMetaEnd);
fUntilMetaStart = fMetaInt;
fUntilMetaEnd = 0;
TRACE("Meta: Size of " B_PRIdOFF " too large\n");
data--;
position--;
size++;
}
data++;
position++;
size--;
}
}
Expand Down

0 comments on commit ee7931d

Please sign in to comment.