diff --git a/src/registry/gitlab-registry.c b/src/registry/gitlab-registry.c index 07cf4203..9411c662 100644 --- a/src/registry/gitlab-registry.c +++ b/src/registry/gitlab-registry.c @@ -8,8 +8,17 @@ #include "http-get/http-get.h" #include "registry-internal.h" #include -#include #include +#include + +static char *string_split(char *in, char sep) { + char *next_sep = strchr(in, sep); + if (next_sep == NULL) { + return next_sep; + } + *next_sep = '\0'; + return next_sep + sizeof(char); +} /** * Parse a list of packages from the given `html` @@ -21,7 +30,7 @@ static list_t *gitlab_registry_parse(const char *hostname, const char *html) { char *input = strdup(html); char *line = input; char *category = NULL; - while ((line = strtok(line, "\n"))) { + while ((line = string_split(line, '\n'))) { char *dash_position = strstr(line, "-"); // The line starts with a dash, so we expect a package. if (dash_position != NULL && dash_position - line < 4) {