Make tool robust to nonexistence of trailing slash at input path.
authorWilhansen Li <wil@byimplication.com>
Mon, 26 Dec 2016 13:19:46 +0000 (21:19 +0800)
committerWilhansen Li <wil@byimplication.com>
Mon, 26 Dec 2016 13:19:46 +0000 (21:19 +0800)
dtbTool.c

index 665ef786a36a10b45a933b0ec4b8d4dd762e188f..38c2c0b281bf48b3e9a997c16d65cd4383c045e7 100644 (file)
--- 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;