Skip to content

Commit 7a77676

Browse files
committed
Merge pull request #11 from langholz/OverflowOnReadFailure
Fix for buffer overflow on read failure
2 parents a9755bf + eecf813 commit 7a77676

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/linux/BTSerialPortBinding.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ void BTSerialPortBinding::EIO_Read(uv_work_t *req) {
166166
baton->size = 0;
167167
}
168168

169-
memcpy(baton->result, buf, baton->size);
169+
// determine if we read anything that we can copy.
170+
if (baton->size > 0) {
171+
memcpy(baton->result, buf, baton->size);
172+
}
170173
}
171174
}
172175

0 commit comments

Comments
 (0)