mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-22 15:22:39 +00:00
osdep/linux/getroot: Add missing strdup() failure checks
If strdup() fails, it returns NULL and passing NULL further down to the code can lead to segmentation fault or an undefined behavior. Signed-off-by: Avnish Chouhan <avnish@linux.ibm.com> Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
f8c48cbedc
commit
72b4c99376
1 file changed
+10
@@ -991,6 +991,8 @@ grub_util_get_raid_grub_dev (const char *os_dev)
|
|||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
|
||||||
p = strdup (os_dev + sizeof ("/dev/md_d") - 1);
|
p = strdup (os_dev + sizeof ("/dev/md_d") - 1);
|
||||||
|
if (p == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
q = strchr (p, 'p');
|
q = strchr (p, 'p');
|
||||||
if (q)
|
if (q)
|
||||||
@@ -1006,6 +1008,8 @@ grub_util_get_raid_grub_dev (const char *os_dev)
|
|||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
|
||||||
p = strdup (os_dev + sizeof ("/dev/md/d") - 1);
|
p = strdup (os_dev + sizeof ("/dev/md/d") - 1);
|
||||||
|
if (p == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
q = strchr (p, 'p');
|
q = strchr (p, 'p');
|
||||||
if (q)
|
if (q)
|
||||||
@@ -1019,6 +1023,8 @@ grub_util_get_raid_grub_dev (const char *os_dev)
|
|||||||
char *p , *q;
|
char *p , *q;
|
||||||
|
|
||||||
p = strdup (os_dev + sizeof ("/dev/md") - 1);
|
p = strdup (os_dev + sizeof ("/dev/md") - 1);
|
||||||
|
if (p == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
q = strchr (p, 'p');
|
q = strchr (p, 'p');
|
||||||
if (q)
|
if (q)
|
||||||
@@ -1032,6 +1038,8 @@ grub_util_get_raid_grub_dev (const char *os_dev)
|
|||||||
char *p , *q;
|
char *p , *q;
|
||||||
|
|
||||||
p = strdup (os_dev + sizeof ("/dev/md/") - 1);
|
p = strdup (os_dev + sizeof ("/dev/md/") - 1);
|
||||||
|
if (p == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
q = strchr (p, 'p');
|
q = strchr (p, 'p');
|
||||||
if (q)
|
if (q)
|
||||||
@@ -1046,6 +1054,8 @@ grub_util_get_raid_grub_dev (const char *os_dev)
|
|||||||
char *p , *q;
|
char *p , *q;
|
||||||
|
|
||||||
p = strdup (os_dev + sizeof ("/dev/md/") - 1);
|
p = strdup (os_dev + sizeof ("/dev/md/") - 1);
|
||||||
|
if (p == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
q = strchr (p, 'p');
|
q = strchr (p, 'p');
|
||||||
if (q)
|
if (q)
|
||||||
|
|||||||
Reference in new issue
Block a user