提交 dafef346 编写于 作者: G ganlan

update test script and rename fortity macro

Signed-off-by: Nganlan <tony.gan@huawei.com>
上级 f451e8a1
...@@ -12,13 +12,15 @@ ...@@ -12,13 +12,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include <errno.h> #include <errno.h>
#include <limits.h>
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "fortify_test.h" #include "fortify_test.h"
#include "test.h" #include "test.h"
#define SIZE_1 1 #define SIZE_1 1
#define SIZE_5 5 #define SIZE_5 5
...@@ -556,7 +558,7 @@ static void test_strlcpy_0020() ...@@ -556,7 +558,7 @@ static void test_strlcpy_0020()
}; };
sigaction(SIGABRT, &sigabrt, NULL); sigaction(SIGABRT, &sigabrt, NULL);
char src[SIZE_15]; char src[SIZE_15];
char dst[SIZE_10]; char dst[SIZE_10];
strcpy(src, STRLEN_14); strcpy(src, STRLEN_14);
...@@ -781,7 +783,7 @@ static void test_memcpy_0020() ...@@ -781,7 +783,7 @@ static void test_memcpy_0020()
}; };
sigaction(SIGABRT, &sigabrt, NULL); sigaction(SIGABRT, &sigabrt, NULL);
int status; int status;
char dst[SIZE_10]; char dst[SIZE_10];
int pid = fork(); int pid = fork();
...@@ -827,7 +829,7 @@ static void test_memset_0020() ...@@ -827,7 +829,7 @@ static void test_memset_0020()
.sa_handler = SignalHandler, .sa_handler = SignalHandler,
}; };
sigaction(SIGABRT, &sigabrt, NULL); sigaction(SIGABRT, &sigabrt, NULL);
char buf[SIZE_10]; char buf[SIZE_10];
size_t n = atoi(EQ_11); size_t n = atoi(EQ_11);
int status; int status;
...@@ -856,7 +858,7 @@ static void test_strlen_0010() ...@@ -856,7 +858,7 @@ static void test_strlen_0010()
.sa_handler = SignalHandler, .sa_handler = SignalHandler,
}; };
sigaction(SIGABRT, &sigabrt, NULL); sigaction(SIGABRT, &sigabrt, NULL);
char buf[SIZE_10]; char buf[SIZE_10];
memcpy(buf, STRLEN_10, sizeof(buf)); memcpy(buf, STRLEN_10, sizeof(buf));
int status; int status;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
#include <fcntl.h> #include <fcntl.h>
#include <limits.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <string.h> #include <string.h>
......
...@@ -125,7 +125,10 @@ template("test_unittest") { ...@@ -125,7 +125,10 @@ template("test_unittest") {
} }
if (target_dir == "functionalext/fortify") { if (target_dir == "functionalext/fortify") {
defines = [ "MUSL_FORTIFY_SOURCE=2" ] if (!defined(defines)) {
defines = []
}
defines += [ "MUSL_FORTIFY_SOURCE=2" ]
} }
if (target_dir == "functionalext/ldso_randomization") { if (target_dir == "functionalext/ldso_randomization") {
......
...@@ -39,22 +39,22 @@ extern "C" { ...@@ -39,22 +39,22 @@ extern "C" {
#endif #endif
#if defined(__LP64__) #if defined(__LP64__)
#ifndef LONG_MAX #ifndef FORTIFY_LONG_MAX
#define LONG_MAX 0x7fffffffffffffffL #define FORTIFY_LONG_MAX 0x7fffffffffffffffL
#endif #endif
#ifndef SSIZE_MAX #ifndef FORTIFY_SSIZE_MAX
#define SSIZE_MAX LONG_MAX #define FORTIFY_SSIZE_MAX FORTIFY_LONG_MAX
#endif #endif
#else #else
#ifndef LONG_MAX #ifndef FORTIFY_LONG_MAX
#define LONG_MAX 0x7fffffffL #define FORTIFY_LONG_MAX 0x7fffffffL
#endif #endif
#ifndef SSIZE_MAX #ifndef FORTIFY_SSIZE_MAX
#define SSIZE_MAX LONG_MAX #define FORTIFY_SSIZE_MAX FORTIFY_LONG_MAX
#endif #endif
#endif #endif
#ifndef PATH_MAX #ifndef FORTIFY_PATH_MAX
#define PATH_MAX 4096 #define FORTIFY_PATH_MAX 4096
#endif #endif
#define __DIAGNOSE_ALWAYS_INLINE __attribute__((__always_inline__)) #define __DIAGNOSE_ALWAYS_INLINE __attribute__((__always_inline__))
...@@ -122,7 +122,7 @@ extern "C" { ...@@ -122,7 +122,7 @@ extern "C" {
#define CALLED_WITH_STRING_BIGGER_BUFFER "called with string bigger than buffer" #define CALLED_WITH_STRING_BIGGER_BUFFER "called with string bigger than buffer"
#define FD_COUNT_LARGE_GIVEN_BUFFER "fd_count is larger than the given buffer" #define FD_COUNT_LARGE_GIVEN_BUFFER "fd_count is larger than the given buffer"
#define CALLED_WITH_SIZE_BIGGER_BUFFER "called with size bigger than buffer" #define CALLED_WITH_SIZE_BIGGER_BUFFER "called with size bigger than buffer"
#define OUTPUT_PARAMETER_BYTES "output parameter must be NULL or a pointer to a buffer with >= PATH_MAX bytes" #define OUTPUT_PARAMETER_BYTES "output parameter must be NULL or a pointer to a buffer with >= FORTIFY_PATH_MAX bytes"
#define SIZE_LARGER_THEN_DESTINATION_BUFFER "size is larger than the destination buffer" #define SIZE_LARGER_THEN_DESTINATION_BUFFER "size is larger than the destination buffer"
void __fortify_error(const char* info, ...); void __fortify_error(const char* info, ...);
......
...@@ -26,7 +26,7 @@ extern "C" { ...@@ -26,7 +26,7 @@ extern "C" {
#if defined(_GNU_SOURCE) && defined(__FORTIFY_COMPILATION) #if defined(_GNU_SOURCE) && defined(__FORTIFY_COMPILATION)
char* realpath(const char* path, char* resolved) char* realpath(const char* path, char* resolved)
__DIAGNOSE_ERROR_IF(!path, "'realpath': NULL path is never correct; flipped arguments?") __DIAGNOSE_ERROR_IF(!path, "'realpath': NULL path is never correct; flipped arguments?")
__DIAGNOSE_ERROR_IF(__DIAGNOSE_UNEVALUATED_LT(__DIAGNOSE_BOS(resolved), PATH_MAX), __DIAGNOSE_ERROR_IF(__DIAGNOSE_UNEVALUATED_LT(__DIAGNOSE_BOS(resolved), FORTIFY_PATH_MAX),
"'realpath' " OUTPUT_PARAMETER_BYTES); "'realpath' " OUTPUT_PARAMETER_BYTES);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -26,15 +26,15 @@ extern "C" { ...@@ -26,15 +26,15 @@ extern "C" {
#if defined(__FORTIFY_COMPILATION) #if defined(__FORTIFY_COMPILATION)
#define __DIAGNOSE_ERROR_IF_OVERFLOWS_SSIZET(what, fn) \ #define __DIAGNOSE_ERROR_IF_OVERFLOWS_SSIZET(what, fn) \
__DIAGNOSE_ERROR_IF((what) > SSIZE_MAX, "in call to '" #fn "', '" #what "' must be <= SSIZE_MAX") __DIAGNOSE_ERROR_IF((what) > FORTIFY_SSIZE_MAX, "in call to '" #fn "', '" #what "' must be <= FORTIFY_SSIZE_MAX")
#define __DIAGNOSE_ERROR_IF_OVERFLOWS_OBJECTSIZE(what, objsize, fn) \ #define __DIAGNOSE_ERROR_IF_OVERFLOWS_OBJECTSIZE(what, objsize, fn) \
__DIAGNOSE_ERROR_IF(__DIAGNOSE_UNEVALUATED_LT((objsize), (what)), \ __DIAGNOSE_ERROR_IF(__DIAGNOSE_UNEVALUATED_LT((objsize), (what)), \
"in call to '" #fn "', '" #what "' bytes overflows the given object") "in call to '" #fn "', '" #what "' bytes overflows the given object")
#define __DIAGNOSE_BOS_TRIVIALLY_GE_NO_OVERFLOW(bos_val, index) \ #define __DIAGNOSE_BOS_TRIVIALLY_GE_NO_OVERFLOW(bos_val, index) \
((__DIAGNOSE_BOS_DYNAMIC_CHECK_IMPL_AND((bos_val), >=, (index), (bos_val) <= (SSIZE_MAX)) && \ ((__DIAGNOSE_BOS_DYNAMIC_CHECK_IMPL_AND((bos_val), >=, (index), (bos_val) <= (FORTIFY_SSIZE_MAX)) && \
__builtin_constant_p(index) && (index) <= (SSIZE_MAX))) __builtin_constant_p(index) && (index) <= (FORTIFY_SSIZE_MAX)))
char* __getcwd_chk(char*, size_t, size_t) ; char* __getcwd_chk(char*, size_t, size_t) ;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <fortify/fortify.h> #include <fortify/fortify.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h>
#include <poll.h> #include <poll.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
......
...@@ -22,6 +22,8 @@ do ...@@ -22,6 +22,8 @@ do
do do
if [ "$(FileSuffix ${file})" = "so" ] \ if [ "$(FileSuffix ${file})" = "so" ] \
|| [ "$file" = "trace_stresstest" ] \ || [ "$file" = "trace_stresstest" ] \
|| [ "$file" = "fatal_message" ] \
|| [ "$file" = "tgkill" ] \
|| [ -d ./$subdir/$file ] || [ -d ./$subdir/$file ]
then then
continue continue
......
...@@ -105,7 +105,7 @@ hdc shell cp %REMOTEFEXT%/dlns/libdlopen_ns_dso.so %REMOTEFEXT%/dlns/inherit_030 ...@@ -105,7 +105,7 @@ hdc shell cp %REMOTEFEXT%/dlns/libdlopen_ns_dso.so %REMOTEFEXT%/dlns/inherit_030
hdc shell cp %REMOTEFEXT%/dlns/libdlopen_ns_dso.so %REMOTEFEXT%/dlns/inherit_0700.so hdc shell cp %REMOTEFEXT%/dlns/libdlopen_ns_dso.so %REMOTEFEXT%/dlns/inherit_0700.so
hdc shell cp %REMOTEFEXT%/dlns/libdlopen_ns_dso.so %REMOTEFEXT%/dlns/inherit_0800.so hdc shell cp %REMOTEFEXT%/dlns/libdlopen_ns_dso.so %REMOTEFEXT%/dlns/inherit_0800.so
hdc shell cp %REMOTEFEXT%/dlns/libdlopen_ns_dso.so %REMOTEFEXT%/dlns/inherit_1100.so hdc shell cp %REMOTEFEXT%/dlns/libdlopen_ns_dso.so %REMOTEFEXT%/dlns/inherit_1100.so
hdc shell mv /etc/ld-musl-namespace-arm.ini /etc/ld-musl-namespace-arm-temp.ini hdc shell cp /etc/ld-musl-namespace-arm.ini /etc/ld-musl-namespace-arm-temp.ini
hdc shell mv /etc/ld-musl-namespace-arm-test.ini /etc/ld-musl-namespace-arm.ini hdc shell mv /etc/ld-musl-namespace-arm-test.ini /etc/ld-musl-namespace-arm.ini
...@@ -136,9 +136,9 @@ echo The test cases have been executed. ...@@ -136,9 +136,9 @@ echo The test cases have been executed.
@REM 恢复现场 @REM 恢复现场
echo Start restore the scene echo Start restore the scene
echo hdc shell mv /etc/ld-musl-namespace-arm.ini /etc/ld-musl-namespace-arm-test.inherit_0300 echo hdc shell mv /etc/ld-musl-namespace-arm.ini /etc/ld-musl-namespace-arm-test.ini
echo ... echo ...
hdc shell mv /etc/ld-musl-namespace-arm.ini /etc/ld-musl-namespace-arm-test.ini hdc shell cp /etc/ld-musl-namespace-arm.ini /etc/ld-musl-namespace-arm-test.ini
hdc shell mv /etc/ld-musl-namespace-arm-temp.ini /etc/ld-musl-namespace-arm.ini hdc shell mv /etc/ld-musl-namespace-arm-temp.ini /etc/ld-musl-namespace-arm.ini
hdc shell rm %REMOTEFEXT%/dlns/sharedlibtest.so -rf hdc shell rm %REMOTEFEXT%/dlns/sharedlibtest.so -rf
hdc shell rm %REMOTEFEXT%/dlns/B/libB.so -rf hdc shell rm %REMOTEFEXT%/dlns/B/libB.so -rf
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册