Compare commits

..

2 Commits

12
otp.c
View File

@@ -767,7 +767,7 @@ int list_available_pads(void) {
chksum[64] = '\0'; chksum[64] = '\0';
// Get pad file size // Get pad file size
char full_path[300]; // Increased buffer size to accommodate longer paths char full_path[1024]; // Increased buffer size to accommodate longer paths
snprintf(full_path, sizeof(full_path), "%s/%s", current_pads_dir, entry->d_name); snprintf(full_path, sizeof(full_path), "%s/%s", current_pads_dir, entry->d_name);
struct stat st; struct stat st;
if (stat(full_path, &st) == 0) { if (stat(full_path, &st) == 0) {
@@ -2095,7 +2095,7 @@ int decrypt_ascii_file(const char* input_file, const char* output_file) {
} }
int read_state_offset(const char* pad_chksum, uint64_t* offset) { int read_state_offset(const char* pad_chksum, uint64_t* offset) {
char state_filename[MAX_HASH_LENGTH + 20]; char state_filename[1024];
snprintf(state_filename, sizeof(state_filename), "%s/%s.state", current_pads_dir, pad_chksum); snprintf(state_filename, sizeof(state_filename), "%s/%s.state", current_pads_dir, pad_chksum);
FILE* state_file = fopen(state_filename, "rb"); FILE* state_file = fopen(state_filename, "rb");
@@ -2115,7 +2115,7 @@ int read_state_offset(const char* pad_chksum, uint64_t* offset) {
} }
int write_state_offset(const char* pad_chksum, uint64_t offset) { int write_state_offset(const char* pad_chksum, uint64_t offset) {
char state_filename[MAX_HASH_LENGTH + 20]; char state_filename[1024];
snprintf(state_filename, sizeof(state_filename), "%s/%s.state", current_pads_dir, pad_chksum); snprintf(state_filename, sizeof(state_filename), "%s/%s.state", current_pads_dir, pad_chksum);
FILE* state_file = fopen(state_filename, "wb"); FILE* state_file = fopen(state_filename, "wb");
@@ -2289,8 +2289,8 @@ void get_default_file_path(const char* filename, char* result_path, size_t resul
} }
void get_pad_path(const char* chksum, char* pad_path, char* state_path) { void get_pad_path(const char* chksum, char* pad_path, char* state_path) {
snprintf(pad_path, MAX_HASH_LENGTH + 20, "%s/%s.pad", current_pads_dir, chksum); snprintf(pad_path, 1024, "%s/%s.pad", current_pads_dir, chksum);
snprintf(state_path, MAX_HASH_LENGTH + 20, "%s/%s.state", current_pads_dir, chksum); snprintf(state_path, 1024, "%s/%s.state", current_pads_dir, chksum);
} }
// OTP thumb drive detection function implementation // OTP thumb drive detection function implementation
@@ -3198,7 +3198,7 @@ void get_directory_display(const char* file_path, char* result, size_t result_si
} }
// Current working directory // Current working directory
if (strcmp(dir_path, ".") == 0 || strcmp(dir_path, PADS_DIR) == 0) { if (strcmp(dir_path, ".") == 0 || strcmp(dir_path, current_pads_dir) == 0) {
strncpy(result, "pads", result_size - 1); strncpy(result, "pads", result_size - 1);
result[result_size - 1] = '\0'; result[result_size - 1] = '\0';
return; return;