mirror of
https://git.tesses.org/tesses50/tessesframework.git
synced 2026-11-29 09:11:54 +00:00
Fix NX, add constant time compare
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user