aboutsummaryrefslogtreecommitdiffstats
path: root/service/src
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2021-05-19 00:53:18 +0200
committerLouis Burda <quent.burda@gmail.com>2021-05-19 00:53:18 +0200
commit64e9b2ad130c0cf28797c3530683fc1cc6b0e9d3 (patch)
tree764a267e5d7e07fcbf84aea4de93f4a5ca8d7d5e /service/src
parent452885a387b3a1613defa378cee79eb97e7b4fc8 (diff)
downloadenowars5-service-stldoctor-64e9b2ad130c0cf28797c3530683fc1cc6b0e9d3.tar.gz
enowars5-service-stldoctor-64e9b2ad130c0cf28797c3530683fc1cc6b0e9d3.zip
enhanced checker functionality and minor changes / fixes in documentation and src
Diffstat (limited to 'service/src')
-rw-r--r--service/src/main.c8
-rw-r--r--service/src/stlfile.c2
-rw-r--r--service/src/test.sh5
-rw-r--r--service/src/tests/sample-binary.stlbin134 -> 134 bytes
4 files changed, 9 insertions, 6 deletions
diff --git a/service/src/main.c b/service/src/main.c
index 095eb7d..3d62fc7 100644
--- a/service/src/main.c
+++ b/service/src/main.c
@@ -43,7 +43,7 @@ int
save_submission(struct parseinfo *info, char *stldata, int stlsize)
{
DIR *d;
- FILE *f;
+ FILE *f = NULL;
char *dirpath = NULL, *infopath = NULL, *modelpath = NULL;
dirpath = aprintf("%s/%s-%i", resultdir, info->hash, time(NULL));
@@ -70,9 +70,9 @@ save_submission(struct parseinfo *info, char *stldata, int stlsize)
fail:
if (f) fclose(f);
- remove(infopath);
- remove(modelpath);
- remove(dirpath);
+ if (infopath) remove(infopath);
+ if (modelpath) remove(modelpath);
+ if (dirpath) remove(dirpath);
free(dirpath);
free(modelpath);
diff --git a/service/src/stlfile.c b/service/src/stlfile.c
index d1d1d7a..7b691d0 100644
--- a/service/src/stlfile.c
+++ b/service/src/stlfile.c
@@ -282,7 +282,7 @@ parse_file(struct parseinfo *info, char *buf, size_t len)
if (!info->solidname) info->solidname = checkp(strdup(""));
if (!info->modelname) {
- resp = ask("Please enter your model name:\n");
+ resp = ask("Please enter your model name: ");
if (strlen(resp) < 4) {
fprintf(stderr, "Model name is too short!\n");
return FAIL;
diff --git a/service/src/test.sh b/service/src/test.sh
index 5af9a16..69e3ea1 100644
--- a/service/src/test.sh
+++ b/service/src/test.sh
@@ -46,17 +46,20 @@ if [ "$1" == "stl" ]; then
announce "Testing ASCII STL Parsing"
(
+ echo "echo"
echo "submit"
cat tests/sample-ascii.stl | wc -c
cat tests/sample-ascii.stl
+ echo "ASCII-testname"
) | checkleaks
announce "Testing BIN STL Parsing"
(
+ echo "echo"
echo "submit"
cat tests/sample-binary.stl | wc -c
cat tests/sample-binary.stl
- echo "testname"
+ echo "BIN-testname"
) | checkleaks
elif [ "$1" == "poc" ]; then
diff --git a/service/src/tests/sample-binary.stl b/service/src/tests/sample-binary.stl
index 919696c..13c02e4 100644
--- a/service/src/tests/sample-binary.stl
+++ b/service/src/tests/sample-binary.stl
Binary files differ