From 8d599dc2cce6844ed00ee5262a67f9f24184cc64 Mon Sep 17 00:00:00 2001 From: Wilhansen Li Date: Mon, 26 Dec 2016 21:19:46 +0800 Subject: [PATCH] Make tool robust to nonexistence of trailing slash at input path. --- dtbTool.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dtbTool.c b/dtbTool.c index 665ef78..38c2c0b 100644 --- a/dtbTool.c +++ b/dtbTool.c @@ -119,8 +119,18 @@ int parse_commandline(int argc, char *const argv[]) != -1) { switch (c) { case 1: - if (!input_dir) + if (!input_dir) { input_dir = optarg; + { + int len = strlen(input_dir); + if ( len > 0 && input_dir[len - 2] != '/' ) { + input_dir = malloc(len + 2); + strcpy(input_dir, optarg); + input_dir[len] = '/'; + input_dir[len + 1] = 0; + } + } + } break; case 'o': output_file = optarg; -- 2.20.1