From 39b6994d97d2bb729629428516806283432c454d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20P=C3=B6chtrager?= Date: Sun, 19 Jul 2015 23:19:31 +0200 Subject: [PATCH] minor fixes --- patches/cctools-ld64-epath.patch | 12 ++++++------ tools/get_cpu_count.sh | 4 ++-- wrapper/tools.cpp | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/patches/cctools-ld64-epath.patch b/patches/cctools-ld64-epath.patch index 38a7189..7b26b23 100644 --- a/patches/cctools-ld64-epath.patch +++ b/patches/cctools-ld64-epath.patch @@ -1,5 +1,5 @@ diff --git cctools/ld64/src/3rd/helper.c cctools/ld64/src/3rd/helper.c -index ef33219..6983e52 100644 +index ef33219..540e009 100644 --- cctools/ld64/src/3rd/helper.c +++ cctools/ld64/src/3rd/helper.c @@ -17,11 +17,17 @@ const char ldVersionString[] = "134.9\n"; @@ -70,7 +70,7 @@ index ef33219..6983e52 100644 + if (*comm == '/' || *comm == '.') { + char *rpath; + if ((rpath = realpath(comm, NULL))) { -+ snprintf(epath, *size, "%s", rpath); ++ strlcpy(epath, rpath, *size); + free(rpath); + ok = 1; + } @@ -112,7 +112,7 @@ index ef33219..6983e52 100644 } else diff --git cctools/libstuff/emulated.c cctools/libstuff/emulated.c -index 1aa355c..b8c52e4 100644 +index 1aa355c..633c9dc 100644 --- cctools/libstuff/emulated.c +++ cctools/libstuff/emulated.c @@ -14,46 +14,88 @@ @@ -185,7 +185,7 @@ index 1aa355c..b8c52e4 100644 + if (*comm == '/' || *comm == '.') { + char *rpath; + if ((rpath = realpath(comm, NULL))) { -+ snprintf(epath, *size, "%s", rpath); ++ strlcpy(epath, rpath, *size); + free(rpath); + ok = 1; + } @@ -236,7 +236,7 @@ index 1aa355c..b8c52e4 100644 #endif } diff --git usage_examples/ios_toolchain/wrapper.c usage_examples/ios_toolchain/wrapper.c -index ed536b2..438032f 100644 +index ed536b2..2ebd188 100644 --- usage_examples/ios_toolchain/wrapper.c +++ usage_examples/ios_toolchain/wrapper.c @@ -19,30 +19,79 @@ @@ -293,7 +293,7 @@ index ed536b2..438032f 100644 + if (*comm == '/' || *comm == '.') { + char *rpath; + if ((rpath = realpath(comm, NULL))) { -+ snprintf(epath, buflen, "%s", rpath); ++ strlcpy(epath, rpath, buflen); + free(rpath); + ok = 1; + } diff --git a/tools/get_cpu_count.sh b/tools/get_cpu_count.sh index 19307dd..e406d78 100755 --- a/tools/get_cpu_count.sh +++ b/tools/get_cpu_count.sh @@ -9,10 +9,10 @@ prog="cpucount" pushd "${0%/*}" >/dev/null 2>&1 case "$(uname -s)" in - *NT*) + *NT* | CYGWIN*) prog="${prog}.exe" ;; esac -test ! -f $prog && cc cpucount.c -o cpucount &>/dev/null +[ ! -f $prog ] && cc cpucount.c -o cpucount &>/dev/null eval "./${prog}" diff --git a/wrapper/tools.cpp b/wrapper/tools.cpp index 6706667..7daeb82 100644 --- a/wrapper/tools.cpp +++ b/wrapper/tools.cpp @@ -114,8 +114,12 @@ char *getExecutablePath(char *buf, size_t len) { abort(); comm = argv[0]; if (*comm == '/' || *comm == '.') { - if (realpath(comm, buf)) + char *rpath; + if ((rpath = realpath(comm, NULL))) { + strlcpy(buf, rpath, len); + free(rpath); ok = 1; + } } else { char *sp; char *xpath = strdup(getenv("PATH"));