Fixed validation of full (absolute) filename (#910)

* Fixed validation of full (absolute) filename

* Added missing CR/LF in rasctl output
This commit is contained in:
Uwe Seimet 2022-10-12 22:10:56 +02:00 committed by GitHub
parent 5a679509a1
commit 0c8d54f055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View File

@ -114,11 +114,11 @@ Localizer::Localizer()
Add(LocalizationKey::ERROR_SHUTDOWN_PERMISSION, "sv", "Saknar root-rättigheter för att kunna stänga av eller starta om systemet");
Add(LocalizationKey::ERROR_SHUTDOWN_PERMISSION, "fr", "Permissions root manquantes pour extinction ou redémarrage");
Add(LocalizationKey::ERROR_SHUTDOWN_PERMISSION, "es", "Falta el permiso de root para el apagado o el reinicio");
Add(LocalizationKey::ERROR_FILE_OPEN, "en", "Invalid or non-existing file '%1': %2");
Add(LocalizationKey::ERROR_FILE_OPEN, "de", "Ungültige oder fehlende Datei '%1': %2");
Add(LocalizationKey::ERROR_FILE_OPEN, "sv", "Ogiltig eller saknad fil '%1': %2");
Add(LocalizationKey::ERROR_FILE_OPEN, "fr", "Fichier invalide ou non-existant '%1': %2");
Add(LocalizationKey::ERROR_FILE_OPEN, "es", "Archivo inválido o inexistente '%1': %2");
Add(LocalizationKey::ERROR_FILE_OPEN, "en", "Invalid or non-existing file '%1'");
Add(LocalizationKey::ERROR_FILE_OPEN, "de", "Ungültige oder fehlende Datei '%1'");
Add(LocalizationKey::ERROR_FILE_OPEN, "sv", "Ogiltig eller saknad fil '%1'");
Add(LocalizationKey::ERROR_FILE_OPEN, "fr", "Fichier invalide ou non-existant '%1'");
Add(LocalizationKey::ERROR_FILE_OPEN, "es", "Archivo inválido o inexistente '%1'");
Add(LocalizationKey::ERROR_BLOCK_SIZE, "en", "Invalid block size %1 bytes");
Add(LocalizationKey::ERROR_BLOCK_SIZE, "de", "Ungültige Blockgröße %1 Bytes");
Add(LocalizationKey::ERROR_BLOCK_SIZE, "sv", "Ogiltig blockstorlek: %1 byte");

View File

@ -580,11 +580,13 @@ bool RascsiExecutor::ValidateImageFile(const CommandContext& context, shared_ptr
to_string(id), to_string(lun));
}
disk->Open(filepath);
if (!disk->FileExists(filepath)) {
return context.ReturnLocalizedError(LocalizationKey::ERROR_FILE_OPEN, initial_filename);
}
}
}
catch(const io_exception& e) {
return context.ReturnLocalizedError(LocalizationKey::ERROR_FILE_OPEN, initial_filename, e.get_msg());
return context.ReturnLocalizedError(LocalizationKey::ERROR_FILE_OPEN, initial_filename);
}
full_path = filepath.GetPath();

View File

@ -164,6 +164,8 @@ string RasctlDisplay::DisplayDeviceTypesInfo(const PbDeviceTypesInfo& device_typ
DisplayBlockSizes(s, properties);
}
s << '\n';
return s.str();
}