diff options
| -rw-r--r-- | service/do.sh | 6 | ||||
| -rw-r--r-- | service/src/stlfile.c | 14 | ||||
| -rw-r--r-- | service/src/util.h | 2 | ||||
| -rw-r--r-- | service/tests/test.sh | 32 |
4 files changed, 48 insertions, 6 deletions
diff --git a/service/do.sh b/service/do.sh index fd3b8b0..d0ac5ed 100644 --- a/service/do.sh +++ b/service/do.sh @@ -55,16 +55,17 @@ elif [ "$1" == "test" ]; then SRCDIR="$PWD/src" DATADIR="$PWD/container/data" bash "tests/test.sh" ${@:2} elif [ "$1" == "make" ]; then # build a normal version - cd src + pushd src if [ -e ".safebuild" ]; then make clean rm ".safebuild" fi make + popd elif [ "$1" == "make-safe" ]; then # build a 'safe' version with flagstore patches - cd src + pushd src make clean touch ".safebuild" @@ -78,6 +79,7 @@ elif [ "$1" == "make-safe" ]; then PREFIX="safe_" make rm safe_* + popd else echo "USAGE: do.sh (compose) [args..]" echo "EXAMPLES:" diff --git a/service/src/stlfile.c b/service/src/stlfile.c index 4dda8ee..88fc430 100644 --- a/service/src/stlfile.c +++ b/service/src/stlfile.c @@ -248,7 +248,7 @@ parse_file_bin(struct parseinfo *info, char *buf, size_t len) bp += 12; for (k = 0; k < 3; k++, bp += 12) { for (m = 0; m < 3; m++) { - v = le32toh(*(float *)(bp + 4 * m)); + v = fle32toh(*(float*)(bp + 4 * m)); info->bbmin[m] = MIN(info->bbmin[m], v); info->bbmax[m] = MAX(info->bbmax[m], v); } @@ -401,3 +401,15 @@ free_info(struct parseinfo *info) NULLFREE(info->solidname); info->valid = 0; } + +float fle32toh(float v) +{ + union { + uint32_t u; + float f; + } conv; + + conv.f = v; + conv.u = le32toh(conv.u); + return conv.f; +} diff --git a/service/src/util.h b/service/src/util.h index eaef14f..c0e9064 100644 --- a/service/src/util.h +++ b/service/src/util.h @@ -31,6 +31,8 @@ const char* ask(const char *fmtstr, ...); void dump(const char *filepath); int strpfcmp(const char *prefix, const char *str); +float fle32toh(float v); + extern int echo; #endif /* UTIL_H */ diff --git a/service/tests/test.sh b/service/tests/test.sh index 19d23ff..a4b1884 100644 --- a/service/tests/test.sh +++ b/service/tests/test.sh @@ -13,7 +13,11 @@ export ECHO_INPUT=1 SCRIPTPATH="$(dirname $(readlink -f "$0"))" TESTDATA="$SCRIPTPATH/data" -cd "$SRCDIR" +shopt -s expand_aliases +alias pushd="pushd &>/dev/null" +alias popd="popd &>/dev/null" + +pushd "$SRCDIR" announce() { count=$(echo "$1" | wc -c) @@ -52,7 +56,7 @@ cleanuploads() { mkdir -p "$RESULTDIR" } -if [ "$1" == "stl" ]; then +if [ "$1" == "stl-leaks" ]; then cleanuploads announce "Testing ASCII STL Parsing" @@ -73,6 +77,26 @@ if [ "$1" == "stl" ]; then echo "BIN-testname" ) | checkleaks +elif [ "$1" == "stl-upload" ]; then + cleanuploads + + popd + file="$(realpath $2)" + if [ ! -e "$file" ]; then + echo "Supply a file to upload" + exit 1 + fi + pushd "$SRCDIR" + + name="${3:-samplefile}" + ( + echo "echo" + echo "upload" + cat "$file" | wc -c + cat "$file" + echo "$name" + ) | checkleaks + elif [ "$1" == "vuln1" ]; then cleanuploads @@ -149,7 +173,7 @@ elif [ "$1" == "vuln2" ]; then echo "exit" ) | connect -elif [ "$1" == "authupload" ]; then +elif [ "$1" == "auth-upload" ]; then cleanuploads ( @@ -172,3 +196,5 @@ elif [ "$1" == "authupload" ]; then else connect fi + +popd |
