41 lines
1.4 KiB
Diff
41 lines
1.4 KiB
Diff
|
From 483ff037f1036f5f604e085cf76097a87e2be348 Mon Sep 17 00:00:00 2001
|
||
|
From: Anna Sztukowska <anna.sztukowska@intel.com>
|
||
|
Date: Wed, 24 Jul 2024 11:46:57 +0200
|
||
|
Subject: [PATCH 152/157] super-gpt.c: Fix check_return issue in load_gpt()
|
||
|
|
||
|
Fix check_return issue in load_gpt() reported by SAST analysis in
|
||
|
super-gpt.c.
|
||
|
|
||
|
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
|
||
|
---
|
||
|
super-gpt.c | 6 ++++--
|
||
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/super-gpt.c b/super-gpt.c
|
||
|
index a1e9aa9d..ec3cf53f 100644
|
||
|
--- a/super-gpt.c
|
||
|
+++ b/super-gpt.c
|
||
|
@@ -105,7 +105,8 @@ static int load_gpt(struct supertype *st, int fd, char *devname)
|
||
|
return 1;
|
||
|
}
|
||
|
/* Set offset to second block (GPT header) */
|
||
|
- lseek(fd, sector_size, SEEK_SET);
|
||
|
+ if (lseek(fd, sector_size, SEEK_SET) == -1L)
|
||
|
+ goto no_read;
|
||
|
/* Seem to have GPT, load the header */
|
||
|
gpt_head = (struct GPT*)(super+1);
|
||
|
if (read(fd, gpt_head, sizeof(*gpt_head)) != sizeof(*gpt_head))
|
||
|
@@ -118,7 +119,8 @@ static int load_gpt(struct supertype *st, int fd, char *devname)
|
||
|
to_read = __le32_to_cpu(gpt_head->part_cnt) * sizeof(struct GPT_part_entry);
|
||
|
to_read = ((to_read+511)/512) * 512;
|
||
|
/* Set offset to third block (GPT entries) */
|
||
|
- lseek(fd, sector_size*2, SEEK_SET);
|
||
|
+ if (lseek(fd, sector_size * 2, SEEK_SET) == -1L)
|
||
|
+ goto no_read;
|
||
|
if (read(fd, gpt_head+1, to_read) != to_read)
|
||
|
goto no_read;
|
||
|
|
||
|
--
|
||
|
2.41.0
|
||
|
|