iSulad/0100-do-not-check-key-s-case-when-parse-http-header.patch
WangFengTu b1ffa045c4 iSulad: sync with upstream iSulad
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
2021-05-18 14:48:15 +08:00

61 lines
2.6 KiB
Diff

From 7311814a1cbe1fbb767ab3879e26e06a4837bfff Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Sat, 15 May 2021 11:18:53 +0800
Subject: [PATCH 100/104] do not check key's case when parse http header
fix pull docker.io/library/busybox:latest failed.
It seems that docker.io registry changes it's
http response header to be all lower case.
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
.../modules/image/oci/registry/registry_apiv2.c | 11 ++++-------
src/utils/http/parser.c | 2 +-
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/daemon/modules/image/oci/registry/registry_apiv2.c b/src/daemon/modules/image/oci/registry/registry_apiv2.c
index b26e42ba..ea9e8dc5 100644
--- a/src/daemon/modules/image/oci/registry/registry_apiv2.c
+++ b/src/daemon/modules/image/oci/registry/registry_apiv2.c
@@ -205,7 +205,7 @@ static int parse_auths(pull_descriptor *desc, struct parsed_http_message *m)
int ret = 0;
for (i = 0; i < m->num_headers; i++) {
- if (!strcmp(m->headers[i][0], "Www-Authenticate") || !strcmp(m->headers[i][0], "WWW-Authenticate")) {
+ if (!strcasecmp(m->headers[i][0], "Www-Authenticate")) {
ret = parse_auth(desc, (char *)m->headers[i][1]);
if (ret != 0) {
WARN("parse auth %s failed", (char *)m->headers[i][1]);
@@ -294,12 +294,9 @@ static int parse_ping_header(pull_descriptor *desc, char *http_head)
version = get_header_value(message, "Docker-Distribution-Api-Version");
if (version == NULL) {
- version = get_header_value(message, "Docker-Distribution-API-Version");
- if (version == NULL) {
- ERROR("Docker-Distribution-Api-Version not found in header, registry may can not support registry API V2");
- ret = -1;
- goto out;
- }
+ ERROR("Docker-Distribution-Api-Version not found in header, registry may can not support registry API V2");
+ ret = -1;
+ goto out;
}
if (!util_strings_contains_word(version, "registry/2.0")) {
diff --git a/src/utils/http/parser.c b/src/utils/http/parser.c
index eb626485..5ea1677c 100644
--- a/src/utils/http/parser.c
+++ b/src/utils/http/parser.c
@@ -320,7 +320,7 @@ char *get_header_value(const struct parsed_http_message *m, const char *header)
char *ret = NULL;
for (i = 0; i < m->num_headers; i++) {
- if (strcmp(m->headers[i][0], header) == 0) {
+ if (strcasecmp(m->headers[i][0], header) == 0) {
ret = (char *)m->headers[i][1];
break;
}
--
2.25.1