Skip to content

Commit

Permalink
Fix security bugs: remotely caused buffer overflows (#1382).
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed Apr 24, 2024
1 parent f86ce7c commit 6ce15d4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions OT/BaseOT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void BaseOT::exec_base(bool new_receiver_inputs)
if (ot_role & RECEIVER)
{
// Receive A
len = sizeof(receiver.S_pack);
os[1].get_bytes((octet*) receiver.S_pack, len);
if (len != HASHBYTES)
{
Expand Down Expand Up @@ -208,6 +209,7 @@ void BaseOT::exec_base(bool new_receiver_inputs)
if (ot_role & SENDER)
{
// Receive B
len = sizeof(Rs_pack[1]);
os[1].get_bytes((octet*) Rs_pack[1], len);
if (len != sizeof(Rs_pack[1]))
{
Expand Down
2 changes: 1 addition & 1 deletion OT/OTExtensionWithMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void OTExtensionWithMatrix::extend(int nOTs_requested, const BitVector& newRecei
channel->send("hello", 6);
char buf[6];
channel->recv(buf, 6);
assert(buf == string("hello"));
assert(string(buf, 5) == string("hello"));
#endif
}

Expand Down
4 changes: 3 additions & 1 deletion Tools/octetStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ void octetStream::store_bytes(octet* x, const size_t l)

void octetStream::get_bytes(octet* ans, size_t& length)
{
length = get_int(4);
auto rec_length = get_int(4);
if (rec_length != length)
throw runtime_error("unexpected length");
memcpy(ans, consume(length), length * sizeof(octet));
}

Expand Down
2 changes: 1 addition & 1 deletion deps/libOTe

0 comments on commit 6ce15d4

Please sign in to comment.