Skip to content

Commit

Permalink
TQueue: return error in get, when from_id is clearly invalid
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 597c7d1928bc4bcfcdfbd87d3b898329047e74bd
  • Loading branch information
arseny30 committed Aug 7, 2019
1 parent 3976bbb commit 734a7e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tddb/td/db/TQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ class TQueueImpl : public TQueue {
return 0;
}
auto &q = it->second;
//TODO: sanity check for from_id
// Some sanity checks
if (from_id.value() > q.tail_id.value() + 10) {
return Status::Error("from_id is in future");
}
if (from_id.value() < q.tail_id.value() - narrow_cast<int32>(MAX_QUEUE_EVENTS) * 2) {
return Status::Error("from_id is in past");
}
confirm_read(q, from_id);
if (q.events.empty()) {
return 0;
Expand Down

0 comments on commit 734a7e0

Please sign in to comment.