Skip to content

Commit 44f40d7

Browse files
committed
registry: Fix a bug with parsing gitlab registries.
1 parent dd7153c commit 44f40d7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/registry/gitlab-registry.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@
88
#include "http-get/http-get.h"
99
#include "registry-internal.h"
1010
#include <curl/curl.h>
11-
#include <string.h>
1211
#include <strdup/strdup.h>
12+
#include <string.h>
13+
14+
static char *string_split(char *in, char sep) {
15+
char *next_sep = strchr(in, sep);
16+
if (next_sep == NULL) {
17+
return next_sep;
18+
}
19+
*next_sep = '\0';
20+
return next_sep + sizeof(char);
21+
}
1322

1423
/**
1524
* 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) {
2130
char *input = strdup(html);
2231
char *line = input;
2332
char *category = NULL;
24-
while ((line = strtok(line, "\n"))) {
33+
while ((line = string_split(line, '\n'))) {
2534
char *dash_position = strstr(line, "-");
2635
// The line starts with a dash, so we expect a package.
2736
if (dash_position != NULL && dash_position - line < 4) {

0 commit comments

Comments
 (0)