aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2023-01-05 12:36:20 +0100
committerJan200101 <sentrycraft123@gmail.com>2023-01-05 12:36:20 +0100
commit1f616ab22d64030f98310898cde6178bbdff390f (patch)
tree356bbe890c5cd731c32b20d816f2e678d629e878
parent45c527009d03e3a67e0db64bc03c7bd1ded84155 (diff)
downloadcgci-1f616ab22d64030f98310898cde6178bbdff390f.tar.gz
cgci-1f616ab22d64030f98310898cde6178bbdff390f.zip
correct string logic, fix invalid reads on parser, add script to log
-rw-r--r--src/build.c3
-rw-r--r--src/config.c12
-rw-r--r--src/parser.c3
-rw-r--r--src/ui.c16
4 files changed, 22 insertions, 12 deletions
diff --git a/src/build.c b/src/build.c
index 8d7f369..952389b 100644
--- a/src/build.c
+++ b/src/build.c
@@ -103,6 +103,9 @@ void create_build()
free(build_path);
}
+ printf("Running '%s'\n", current_project->script_path);
+ fflush(stdout);
+
int status = system(current_project->script_path);
if (status)
build.status = STATUS_FAILURE;
diff --git a/src/config.c b/src/config.c
index 06d82f4..229de19 100644
--- a/src/config.c
+++ b/src/config.c
@@ -127,7 +127,7 @@ char* project_dir(char* project)
cache = realloc(cache, size);
strncat(cache, "/", size - strlen(cache) - 1);
strncat(cache, project, size - strlen(cache) - 1);
- cache[size] = '\0';
+ cache[size-1] = '\0';
return cache;
}
@@ -142,11 +142,11 @@ char* build_dir(char* project, char* build)
if (!project_path)
return project_path;
- size_t size = strlen(project_path) + 1 + strlen(build) ;
- project_path = realloc(project_path, size+1);
- strncat(project_path, "/", size);
- strncat(project_path, build, size);
- project_path[size] = '\0';
+ size_t size = strlen(project_path) + 1 + strlen(build) + 1;
+ project_path = realloc(project_path, size);
+ strncat(project_path, "/", size - strlen(project_path) - 1);
+ strncat(project_path, build, size - strlen(project_path) - 1);
+ project_path[size-1] = '\0';
return project_path;
} \ No newline at end of file
diff --git a/src/parser.c b/src/parser.c
index 90705ce..cd7e672 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -309,9 +309,8 @@ void parse_query(const char* query_arg)
char* key = head;
char* value = NULL;
- while (head <= end)
+ while (++head <= end)
{
- ++head;
if (!value && *head == '=')
{
*head = '\0';
diff --git a/src/ui.c b/src/ui.c
index fdfc945..d86532e 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -118,9 +118,17 @@ void print_head()
}
printf("</title>");
+ char* token = config.token;
+ if (current_project)
+ {
+ token = current_project->token;
+ if (!token)
+ token = config.token;
+ }
+
if (current_project && current_project->name
&& context.action && !strcmp(context.action, "trigger")
- && context.token && config.token && !strcmp(context.token, config.token))
+ && context.token && token && !strcmp(context.token, token))
printf("<meta http-equiv=\"refresh\" content=\"0; url=/%s\"/>", current_project->name);
printf("<link rel=\"stylesheet\" type=\"text/css\" href=\"%s/assets/base.css\"/>", config.path_prefix ? config.path_prefix : "");
@@ -241,12 +249,12 @@ void print_build_trigger()
printf(
"<form>"
"<label>Trigger Build</label><br>"
- "%s"
"<input name=\"token\" type=\"password\" placeholder=\"token\" value=\"%s\" required><br>"
+ "%s"
"<input type=\"submit\" value=\"submit\">"
"</form>",
- context.token ? "Invalid token" : "",
- context.token ? context.token : ""
+ context.token ? context.token : "",
+ context.token ? "Invalid token<br>" : ""
);
}