[PATCH 30/32] lib: parse_area_spec: guard against NULL pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 lib/misc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/misc.c b/lib/misc.c
index 532f0bfc1eb5..2d5f7c198586 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:
-- 
2.30.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux