mirror of https://git.48k.eu/ogclient
live: add disk index bounds check
Add disk index bounds checks for setup() and image_create(). Prevent backtrace logging when an invalid disk index is used.master v1.3.2-16
parent
f2a2f53074
commit
6704abc620
|
@ -413,7 +413,7 @@ class OgLiveOperations:
|
|||
|
||||
def setup(self, request, ogRest):
|
||||
table_type = request.getType()
|
||||
disk = request.getDisk()
|
||||
disk = int(request.getDisk())
|
||||
cache = request.getCache()
|
||||
cache_size = request.getCacheSize()
|
||||
partlist = request.getPartitionSetup()
|
||||
|
@ -424,7 +424,10 @@ class OgLiveOperations:
|
|||
umount_all()
|
||||
umount_cache()
|
||||
|
||||
diskname = get_disks()[int(disk)-1]
|
||||
if disk < 0 or disk > len(get_disks()):
|
||||
raise OgError(f'Invalid disk number {disk}, {len(get_disks())} disks available.')
|
||||
|
||||
diskname = get_disks()[disk-1]
|
||||
cxt = fdisk.Context(f'/dev/{diskname}',
|
||||
details=True)
|
||||
|
||||
|
@ -469,9 +472,9 @@ class OgLiveOperations:
|
|||
|
||||
partition = int(part["partition"])
|
||||
if fs == 'cache':
|
||||
err = mkfs('ext4', int(disk), partition, label='CACHE')
|
||||
err = mkfs('ext4', disk, partition, label='CACHE')
|
||||
else:
|
||||
err = mkfs(fs, int(disk), partition)
|
||||
err = mkfs(fs, disk, partition)
|
||||
|
||||
if err == -1:
|
||||
raise OgError(f'Failed to format {part["partition"]} with filesystem {part["filesystem"]}')
|
||||
|
@ -554,6 +557,9 @@ class OgLiveOperations:
|
|||
if ogRest.terminated:
|
||||
return
|
||||
|
||||
if disk < 0 or disk > len(get_disks()):
|
||||
raise OgError(f'Invalid disk number {disk}, {len(get_disks())} disks available.')
|
||||
|
||||
diskname = get_disks()[disk-1]
|
||||
cxt = fdisk.Context(f'/dev/{diskname}', details=True)
|
||||
pa = None
|
||||
|
|
Loading…
Reference in New Issue