Fix NX, add constant time compare

This commit is contained in:
2026-10-25 17:48:20 -05:00
parent fae86d2eb5
commit d99001d6eb
7 changed files with 16 additions and 89 deletions
+1 -1
View File
@@ -377,7 +377,7 @@ bool RandomBytes(std::vector<uint8_t> &output, std::string personal_str) {
#endif
return false;
}
bool ConstantEquals(const TF_Span<uint8_t> left, const TF_Span<uint8_t> right)
bool ConstantEquals(const std::vector<uint8_t>& left, const std::vector<uint8_t>& right)
{
if (left.size() != right.size()) return false;
if (left.empty()) return true;
+12 -2
View File
@@ -282,13 +282,23 @@ FIFOCreationResult LocalFilesystem::CreateFIFO(VFSPath path, uint32_t mod) {
void LocalFilesystem::Lock(VFSPath path) {
auto p2 = VFSPathToSystem(path);
const char *fopenPath = p2.c_str();
while (true) {
for (int i = 0; i < 10; i++) {
FILE *fp = fopen(fopenPath, "wx");
if (fp) {
fclose(fp);
break;
return;
}
if (errno != EEXIST) {
std::string error_msg("Failed to acquire lock on ");
error_msg += p2;
error_msg += ": ";
error_msg += strerror(errno);
throw std::runtime_error(error_msg);
}
TF_Sleep(100);
}
throw std::runtime_error("Lock acquisition timed out for " + p2);
}
void LocalFilesystem::Unlock(VFSPath path) {
std::error_code error;