summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-09-05 11:55:55 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-09-12 12:05:02 +0200
commit2f912c05dbebabb0446cf54e605d5d0f1bdc512c (patch)
tree4a183b47804112e5a758f2146947005f8bac5f8a /lib
parent20e241c70b7ad92c7b7a65d82157c0d10684745f (diff)
downloadbarebox-2f912c05dbebabb0446cf54e605d5d0f1bdc512c.tar.gz
barebox-2f912c05dbebabb0446cf54e605d5d0f1bdc512c.tar.xz
lib: parse_area_spec: guard against NULL pointer dereference
If mem_parse_options is called with an optstr containing x, but with swab == NULL, we will end up doing a NULL pointer dereference. Add a check that avoids this from happening. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905095557.596891-31-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/misc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/misc.c b/lib/misc.c
index 532f0bfc1e..2d5f7c1985 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -159,6 +159,8 @@ int mem_parse_options(int argc, char *argv[], char *optstr, int *mode,
*destfile = optarg;
break;
case 'x':
+ if (!swab)
+ return -EINVAL;
*swab = 1;
break;
default: