]> git.saurik.com Git - apple/dyld.git/commitdiff
dyld-360.19.tar.gz os-x-10113 v360.19
authorApple <opensource@apple.com>
Thu, 25 Feb 2016 21:57:30 +0000 (21:57 +0000)
committerApple <opensource@apple.com>
Thu, 25 Feb 2016 21:57:30 +0000 (21:57 +0000)
src/dyld.cpp
unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/Makefile
unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/bar.c [new file with mode: 0644]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/Makefile
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/bar.c [new file with mode: 0644]

index 19166c515e22fa2129aca9b06a0d5f858b8c979d..ef45c272a33a66b7459568e4f72eda298c08d134 100644 (file)
@@ -1190,7 +1190,8 @@ static void checkDylibOverridesInDir(const char* dirPath)
 {
        //dyld::log("checkDylibOverridesInDir('%s')\n", dirPath);
        char dylibPath[PATH_MAX];
-       if ( strlcpy(dylibPath, dirPath, PATH_MAX) >= PATH_MAX )
+       int dirPathLen = strlcpy(dylibPath, dirPath, PATH_MAX-1);
+       if ( dirPathLen >= PATH_MAX )
                return;
        DIR* dirp = opendir(dirPath);
        if ( dirp != NULL) {
@@ -1201,8 +1202,8 @@ static void checkDylibOverridesInDir(const char* dirPath)
                                break;
                        if ( entp->d_type != DT_REG ) 
                                continue;
-                       if ( strlcat(dylibPath, "/", PATH_MAX) >= PATH_MAX )
-                               continue;
+                       dylibPath[dirPathLen] = '/';
+                       dylibPath[dirPathLen+1] = '\0';
                        if ( strlcat(dylibPath, entp->d_name, PATH_MAX) >= PATH_MAX )
                                continue;
                        checkDylibOverride(dylibPath);
@@ -1216,7 +1217,8 @@ static void checkFrameworkOverridesInDir(const char* dirPath)
 {
        //dyld::log("checkFrameworkOverridesInDir('%s')\n", dirPath);
        char frameworkPath[PATH_MAX];
-       if ( strlcpy(frameworkPath, dirPath, PATH_MAX) >= PATH_MAX )
+       int dirPathLen = strlcpy(frameworkPath, dirPath, PATH_MAX-1);
+       if ( dirPathLen >= PATH_MAX )
                return;
        DIR* dirp = opendir(dirPath);
        if ( dirp != NULL) {
@@ -1227,9 +1229,9 @@ static void checkFrameworkOverridesInDir(const char* dirPath)
                                break;
                        if ( entp->d_type != DT_DIR ) 
                                continue;
-                       if ( strlcat(frameworkPath, "/", PATH_MAX) >= PATH_MAX )
-                               continue;
-                       int dirNameLen = strlen(entp->d_name);
+                       frameworkPath[dirPathLen] = '/';
+                       frameworkPath[dirPathLen+1] = '\0';
+                       int dirNameLen = (int)strlen(entp->d_name);
                        if ( dirNameLen < 11 )
                                continue;
                        if ( strcmp(&entp->d_name[dirNameLen-10], ".framework") != 0 )
index 72ca37ba91953ce70e0c577a210285fc002bff71..67ef91c5eba771dc61af38cbcbe21441ba88e1e7 100644 (file)
@@ -47,15 +47,18 @@ check-macosx:
        export DYLD_VERSIONED_FRAMEWORK_PATH="${PWD}/alt11:${PWD}/alt12" && ./main 12
 
 all: 
-       mkdir -p Foo.framework alt11/Foo.framework/Versions/A alt9/Foo.framework alt12/Foo.framework
+       mkdir -p Foo.framework alt11/Foo.framework/Versions/A alt9/Foo.framework alt12/Foo.framework Bar.framework alt11/Bar.framework/Versions/A/
+       ${CC} ${CCFLAGS} -dynamiclib bar.c -DRESULT=10 -current_version 10 -install_name "${PWD}/Bar.framework/Bar" -o Bar.framework/Bar
        ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=10 -current_version 10 -install_name "${PWD}/Foo.framework/Foo" -o Foo.framework/Foo
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main main.c Foo.framework/Foo 
+       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main main.c Bar.framework/Bar Foo.framework/Foo
        ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=11 -current_version 11 -install_name "${PWD}/Foo.framework/Foo" -o alt11/Foo.framework/Versions/A/Foo
+       ${CC} ${CCFLAGS} -dynamiclib bar.c -DRESULT=11 -current_version 11 -install_name "${PWD}/Bar.framework/Foo" -o alt11/Bar.framework/Versions/A/Bar
        cd alt11/Foo.framework && ln -sf Versions/A/Foo
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=9  -current_version 9  -install_name "${PWD}/Foo.framework/Foo" -o alt9/Foo.framework/Foo  
+       cd alt11/Bar.framework && ln -sf Versions/A/Bar
+       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=9  -current_version 9  -install_name "${PWD}/Foo.framework/Foo" -o alt9/Foo.framework/Foo
        ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=12 -current_version 12 -install_name "${PWD}/Foo.framework/Foo" -o alt12/Foo.framework/Foo  
 
 
 clean:
-       ${RM} -rf main Foo.framework alt9 alt11 alt12
+       ${RM} -rf main Foo.framework Bar.framework alt9 alt11 alt12
 
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/bar.c b/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/bar.c
new file mode 100644 (file)
index 0000000..4684921
--- /dev/null
@@ -0,0 +1,5 @@
+
+int bar()
+{
+       return 0;
+}
index 788e74af44df5e610f57dc2a0360d32d94fb00e7..4206cb7a8d9a5560b3777467c5607f4aecbbbc74 100644 (file)
@@ -48,12 +48,14 @@ check-macosx:
 all: 
        mkdir -p alt11 alt9 alt12
        ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=10 -current_version 10 -o "${PWD}/libfoo.dylib"
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main main.c libfoo.dylib 
+       ${CC} ${CCFLAGS} -dynamiclib bar.c -DRESULT=10 -current_version 10 -o "${PWD}/libbar.dylib"
+       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main main.c libbar.dylib libfoo.dylib
        ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=11 -current_version 11 -install_name "${PWD}/libfoo.dylib" -o alt11/libfoo.dylib  
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=9  -current_version 9  -install_name "${PWD}/libfoo.dylib" -o alt9/libfoo.dylib  
+       ${CC} ${CCFLAGS} -dynamiclib bar.c -DRESULT=11 -current_version 11 -install_name "${PWD}/libbar.dylib" -o alt11/libbar.dylib
+       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=9  -current_version 9  -install_name "${PWD}/libfoo.dylib" -o alt9/libfoo.dylib
        ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=12 -current_version 12 -install_name "${PWD}/libfoo.dylib" -o alt12/libfoo.dylib  
 
 
 clean:
-       ${RM} -rf main libfoo.dylib alt9 alt11 alt12
+       ${RM} -rf main libfoo.dylib libbar.dylib alt9 alt11 alt12
 
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/bar.c b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/bar.c
new file mode 100644 (file)
index 0000000..c57608f
--- /dev/null
@@ -0,0 +1,5 @@
+
+int bar()
+{
+       return RESULT;
+}