summaryrefslogtreecommitdiffstats
path: root/src/import
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-01-15 22:55:15 +0100
committerLennart Poettering <lennart@poettering.net>2021-01-19 18:29:59 +0100
commit6792cbbcf84b730f465decbeaf247c6b1ccf1c18 (patch)
tree96475730ea0097acfaa523ef002cb0ecab0412f8 /src/import
parentimport: turn on HTTP logging in debug mode (diff)
downloadsystemd-6792cbbcf84b730f465decbeaf247c6b1ccf1c18.tar.xz
systemd-6792cbbcf84b730f465decbeaf247c6b1ccf1c18.zip
import: ignore non-successful HTTP codes for collecing image metadata
Previously we'd collect the data from redirects too, which wasn't particularly terrible, since these typically don't carry the data we were interested in, but it's still incorrect to do so.
Diffstat (limited to 'src/import')
-rw-r--r--src/import/pull-job.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/import/pull-job.c b/src/import/pull-job.c
index f41a7e7a5d..d1e61ba601 100644
--- a/src/import/pull-job.c
+++ b/src/import/pull-job.c
@@ -435,8 +435,10 @@ fail:
static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb, void *userdata) {
_cleanup_free_ char *length = NULL, *last_modified = NULL, *etag = NULL;
- PullJob *j = userdata;
size_t sz = size * nmemb;
+ PullJob *j = userdata;
+ CURLcode code;
+ long status;
int r;
assert(contents);
@@ -449,6 +451,18 @@ static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb
assert(j->state == PULL_JOB_ANALYZING);
+ code = curl_easy_getinfo(j->curl, CURLINFO_RESPONSE_CODE, &status);
+ if (code != CURLE_OK) {
+ log_error("Failed to retrieve response code: %s", curl_easy_strerror(code));
+ r = -EIO;
+ goto fail;
+ }
+
+ if (status < 200 || status >= 300)
+ /* If this is not HTTP 2xx, let's skip these headers, they are probably for
+ * some redirect or so, and we are not interested in the headers of those. */
+ return sz;
+
r = curl_header_strdup(contents, sz, "ETag:", &etag);
if (r < 0) {
log_oom();