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

Unsigned integer overflow in DiskOverflow.d #115

Open
iain-buclaw-sociomantic opened this issue Jun 17, 2020 · 0 comments
Open

Unsigned integer overflow in DiskOverflow.d #115

iain-buclaw-sociomantic opened this issue Jun 17, 2020 · 0 comments
Labels

Comments

@iain-buclaw-sociomantic
Copy link
Contributor

iain-buclaw-sociomantic commented Jun 17, 2020

/*
* Pushing a record means appending it to the data file. The file
* position is always at the end.
* If there is no record in the file then the file should be empty so we
* have to write the data file ID string before appending the first
* record to the file. We're also going to need the file position where
* we append the record.
*/
off_t pos = this.data.seek(0, SEEK_CUR, "Unable to seek to tell the file size");
if (this.records)
{
this.data.enforce(pos >= Constants.datafile_id.length, "File size less than length of ID string");
}
else
{
this.data.enforce(!pos, "File expected to be empty");
this.data.write(Constants.datafile_id, "Unable to write the data file ID");
pos = Constants.datafile_id.length;
}

The records field is an unsigned 32-bit integer, it can happen that it overflows back to zero if the overflow.dat file exceeds 4 billion records. This causes the DMQ to go into a stuck state (the logs are flooded with File expected to be empty messages), which has a knock-on effect of halting all connected clients, not just those that have overflowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant