mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-24 12:30:20 +00:00
Add client side image size validation (#322)
This commit is contained in:
parent
e34529fa2c
commit
e58f96318a
@ -336,8 +336,15 @@ def attach():
|
||||
|
||||
kwargs = {"unit": int(un), "image": file_name}
|
||||
|
||||
# The most common block size is 512 bytes
|
||||
expected_block_size = 512
|
||||
|
||||
if device_type != "":
|
||||
kwargs["device_type"] = device_type
|
||||
if device_type == "SCCD":
|
||||
expected_block_size = 2048
|
||||
elif device_type == "SAHD":
|
||||
expected_block_size = 256
|
||||
|
||||
# Attempt to load the device properties file:
|
||||
# same base path but PROPERTIES_SUFFIX instead of the original suffix.
|
||||
@ -356,10 +363,15 @@ def attach():
|
||||
kwargs["product"] = conf["product"]
|
||||
kwargs["revision"] = conf["revision"]
|
||||
kwargs["block_size"] = conf["block_size"]
|
||||
expected_block_size = conf["block_size"]
|
||||
|
||||
process = attach_image(scsi_id, **kwargs)
|
||||
if process["status"] == True:
|
||||
flash(f"Attached {file_name} to SCSI ID {scsi_id} LUN {un}!")
|
||||
if int(file_size) % int(expected_block_size):
|
||||
flash(f"The image file size {file_size} bytes is not a multiple of \
|
||||
{expected_block_size}. The image may be corrupted \
|
||||
so proceed with caution.", "error")
|
||||
return redirect(url_for("index"))
|
||||
else:
|
||||
flash(f"Failed to attach {file_name} to SCSI ID {scsi_id} LUN {un}!", "error")
|
||||
|
Loading…
Reference in New Issue
Block a user