From 4f17e7a6e9f7d1db9fed2c9e01feed490a9f0303 Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 25 Feb 2016 21:57:30 +0000 Subject: [PATCH] dyld-360.19.tar.gz --- src/dyld.cpp | 16 +++++++++------- .../DYLD_VERSIONED_FRAMEWORK_PATH-basic/Makefile | 11 +++++++---- .../DYLD_VERSIONED_FRAMEWORK_PATH-basic/bar.c | 5 +++++ .../DYLD_VERSIONED_LIBRARY_PATH-basic/Makefile | 8 +++++--- .../DYLD_VERSIONED_LIBRARY_PATH-basic/bar.c | 5 +++++ 5 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/bar.c create mode 100644 unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/bar.c diff --git a/src/dyld.cpp b/src/dyld.cpp index 19166c5..ef45c27 100644 --- a/src/dyld.cpp +++ b/src/dyld.cpp @@ -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 ) diff --git a/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/Makefile b/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/Makefile index 72ca37b..67ef91c 100644 --- a/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/Makefile +++ b/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/Makefile @@ -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 index 0000000..4684921 --- /dev/null +++ b/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/bar.c @@ -0,0 +1,5 @@ + +int bar() +{ + return 0; +} diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/Makefile b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/Makefile index 788e74a..4206cb7 100644 --- a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/Makefile +++ b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/Makefile @@ -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 index 0000000..c57608f --- /dev/null +++ b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/bar.c @@ -0,0 +1,5 @@ + +int bar() +{ + return RESULT; +} -- 2.45.2