Fix config bug

This commit is contained in:
mintsuki 2020-07-02 16:14:09 +02:00
parent 21490a84d3
commit 78d1b8a8fc
2 changed files with 7 additions and 4 deletions

Binary file not shown.

View File

@ -18,19 +18,22 @@ int init_config(int drive, int part) {
}
config_addr = balloc(f.size + 1);
memset(config_addr, 0, f.size + 1);
fread(&f, config_addr, 0, f.size);
size_t config_size = f.size;
// remove windows carriage returns, if any
for (size_t i = 0; i < f.size; i++) {
for (size_t i = 0; i < config_size; i++) {
if (config_addr[i] == '\r') {
for (size_t j = i; j < f.size - 1; j++)
for (size_t j = i; j < config_size - 1; j++)
config_addr[j] = config_addr[j+1];
f.size--;
config_size--;
}
}
config_addr[config_size-1] = 0;
return 0;
}