aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/0014-miscutils-microcom-Fixed-segfault.patch
blob: 85fb12f6660568019086a8314ef3e4c27dbd9ea4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 33c5d20fd0703b678f3c097c628026002b1fd0e3 Mon Sep 17 00:00:00 2001
From: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
Date: Wed, 2 Aug 2017 23:36:08 +0200
Subject: [PATCH] miscutils/microcom: Fixed segfault

microcom did not check if required parameter TTY is present. Thus,
bb_basename() was called with a NULL pointer if TTY was missing.
This commit adds the missing check.
---
 miscutils/microcom.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/miscutils/microcom.c b/miscutils/microcom.c
index fa090057e..96ea02b16 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -76,6 +76,11 @@ int microcom_main(int argc UNUSED_PARAM, char **argv)
 //	argc -= optind;
 	argv += optind;
 
+	if (*argv == NULL){
+		bb_show_usage();
+		return EXIT_FAILURE;
+	}
+
 	// try to create lock file in /var/lock
 	device_lock_file = (char *)bb_basename(argv[0]);
 	device_lock_file = xasprintf("/var/lock/LCK..%s", device_lock_file);