Browse Source

fix dotdot case for real

Chia-Che Tsai 7 years ago
parent
commit
079fbbac59
2 changed files with 8 additions and 4 deletions
  1. 6 2
      Pal/lib/graphene/path.c
  2. 2 2
      Pal/regression/Makefile

+ 6 - 2
Pal/lib/graphene/path.c

@@ -54,9 +54,14 @@ int get_norm_path (const char * path, char * buf, int offset, int size)
                     continue;
                 if (c1 == '.') {    /* must be dot-dot */
                     c1 = *(++p);
-                    if (c1 != 0 && c1 != '/')   /* Paths can start with a dot
+                    if (c1 != 0 && c1 != '/') { /* Paths can start with a dot
                                                  * dot: ..xyz is ok */
+                        if (offset >= size - 2)
+                            return -PAL_ERROR_TOOLONG;
+                        buf[offset++] = '.';
+                        buf[offset++] = '.';
                         continue;
+                    }
                     if (offset > head) {    /* remove the last token */
                         while (offset > head && buf[--offset] != '/');
                     } else {
@@ -112,7 +117,6 @@ int get_base_name (const char * path, char * buf, int size)
                     p += 2;
                     continue;
                 }
-                return -PAL_ERROR_INVAL;
             }
         }
 

+ 2 - 2
Pal/regression/Makefile

@@ -19,8 +19,8 @@ include ../src/Makefile.Test
 
 RUNTIME_DIR = $(CURDIR)/../../Runtime
 
-export PAL_LOADER = $(RUNTIME_DIR)/pal-$(OS)
-export PAL_SEC = $(RUNTIME_DIR)/pal_sec-$(OS)
+export PAL_LOADER = $(RUNTIME_DIR)/pal-$(PAL_HOST)
+export PAL_SEC = $(RUNTIME_DIR)/pal_sec-$(PAL_HOST)
 
 all: $(call expand_target,$(target)) $(preloads)