Skip to content

Commit

Permalink
- Prevent File Service Protocol from being used as configuration device.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Dec 14, 2019
1 parent c21854a commit 922337a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cube/swiss/source/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool config_set_device() {
DEVICEHANDLER_INTERFACE *configDevice = getDeviceByUniqueId(swissSettings.configDeviceId);
devices[DEVICE_CONFIG] = NULL;
if(configDevice != NULL) {
if((configDevice->features & FEAT_WRITE) && (configDevice->test())) {
if(configDevice->test()) {
deviceHandler_setDeviceAvailable(configDevice, true);
devices[DEVICE_CONFIG] = configDevice;
}
Expand Down
6 changes: 3 additions & 3 deletions cube/swiss/source/gui/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void refreshSRAM(SwissSettings *settings) {
__SYS_UnlockSram(0);
sramex = __SYS_LockSramEx();
settings->configDeviceId = sramex->__padding0;
if(settings->configDeviceId > DEVICE_ID_MAX || !(getDeviceByUniqueId(settings->configDeviceId)->features & FEAT_WRITE)) {
if(settings->configDeviceId > DEVICE_ID_MAX || (getDeviceByUniqueId(settings->configDeviceId)->features & (FEAT_WRITE|FEAT_BOOT_DEVICE)) != (FEAT_WRITE|FEAT_BOOT_DEVICE)) {
settings->configDeviceId = DEVICE_ID_UNK;
}
__SYS_UnlockSramEx(0);
Expand Down Expand Up @@ -327,7 +327,7 @@ void settings_toggle(int page, int option, int direction, file_handle *file, Con
// Set it to the first writable device available
if(swissSettings.configDeviceId == DEVICE_ID_UNK) {
for(int i = 0; i < MAX_DEVICES; i++) {
if(allDevices[i] != NULL && (allDevices[i]->features & FEAT_WRITE)) {
if(allDevices[i] != NULL && (allDevices[i]->features & (FEAT_WRITE|FEAT_BOOT_DEVICE)) == (FEAT_WRITE|FEAT_BOOT_DEVICE)) {
swissSettings.configDeviceId = allDevices[i]->deviceUniqueId;
return;
}
Expand All @@ -350,7 +350,7 @@ void settings_toggle(int page, int option, int direction, file_handle *file, Con
curDevicePos = curDevicePos > 0 ? curDevicePos-1 : 0;
}
// Go to next writable device
while((allDevices[curDevicePos] == NULL) || !(allDevices[curDevicePos]->features & FEAT_WRITE)) {
while((allDevices[curDevicePos] == NULL) || (allDevices[curDevicePos]->features & (FEAT_WRITE|FEAT_BOOT_DEVICE)) != (FEAT_WRITE|FEAT_BOOT_DEVICE)) {
curDevicePos += direction;
if((curDevicePos < 0) || (curDevicePos >= MAX_DEVICES)){
curDevicePos = direction > 0 ? 0 : MAX_DEVICES-1;
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ int main ()
// If there's no default config device, set it to the first writable device available
if(swissSettings.configDeviceId == DEVICE_ID_UNK) {
for(int i = 0; i < MAX_DEVICES; i++) {
if(allDevices[i] != NULL && (allDevices[i]->features & FEAT_WRITE) && deviceHandler_getDeviceAvailable(allDevices[i])) {
if(allDevices[i] != NULL && (allDevices[i]->features & (FEAT_WRITE|FEAT_BOOT_DEVICE)) == (FEAT_WRITE|FEAT_BOOT_DEVICE) && deviceHandler_getDeviceAvailable(allDevices[i])) {
swissSettings.configDeviceId = allDevices[i]->deviceUniqueId;
print_gecko("No default config device found, using [%s]\r\n", allDevices[i]->deviceName);
syssramex* sramex = __SYS_LockSramEx();
Expand Down

0 comments on commit 922337a

Please sign in to comment.