From: Wilhansen Li Date: Mon, 26 Dec 2016 13:19:46 +0000 (+0800) Subject: Make tool robust to nonexistence of trailing slash at input path. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8d599dc2cce6844ed00ee5262a67f9f24184cc64;p=GitHub%2FLineageOS%2FG12%2Fandroid_hardware_amlogic_tools_dtbtool.git Make tool robust to nonexistence of trailing slash at input path. --- 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;