Skip to content

Commit

Permalink
registry: Fix a bug with parsing gitlab registries.
Browse files Browse the repository at this point in the history
  • Loading branch information
nouwaarom committed Apr 9, 2021
1 parent dd7153c commit 44f40d7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/registry/gitlab-registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@
#include "http-get/http-get.h"
#include "registry-internal.h"
#include <curl/curl.h>
#include <string.h>
#include <strdup/strdup.h>
#include <string.h>

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`
Expand All @@ -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) {
Expand Down

0 comments on commit 44f40d7

Please sign in to comment.