/*********************************************************************************
* busybox microcom Segmentation fault
* 说明:
* 调试硬件的时候想用microcom来测试一下串口,结果发现段错误,其他busybox命令正常,
* 觉得有点奇怪,查看microcom的patch之后发现这个问题已经修复了。
*
* 2017-10-17 深圳 南山平山村 曾剑锋
********************************************************************************/

一、参考文档:
1. [PATCH] miscutils/microcom: Fixed segfault
http://lists.busybox.net/pipermail/busybox/2017-August/085720.html

二、解决办法:
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 14b9f3baf..38f6425c1 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -78,6 +78,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);