path: root/src/test/test-bus-util.c
diff options
authorDongsu Park <>2018-09-03 20:44:13 +0200
committerSven Eden <>2018-10-29 10:18:25 +0100
commitc235b61057a1a48c4262d12f3bb6676aac143dc3 (patch)
tree51926ed70222a0c77f50effd75121456671cbe11 /src/test/test-bus-util.c
parente81229d2391d2d1d4ecf3639ef41b905d566d4ea (diff)
importd, basic/string-util: use case-insensitive comparison for HTTP headers
According to RFC2616[1], HTTP header names are case-insensitive. So it's totally valid to have a header starting with either `Date:` or `date:`. However, when systemd-importd pulls an image from an HTTP server, it parses HTTP headers by comparing header names as-is, without any conversion. That causes failures when some HTTP servers return headers with different combinations of upper-/lower-cases. An example: returns `Etag: "pe89so9oir60"`, while returns `ETag: "f03372edea9a1e7232e282c346099857"`. Since systemd-importd expects to see `ETag`, the etag for the Container Linux image is correctly interpreted as a part of the hidden file name. However, it cannot parse etag for Flatcar Linux, so the etag the Flatcar Linux image is not appended to the hidden file name. ``` $ sudo ls -al /var/lib/machines/ -r--r--r-- 1 root root 3303014400 Aug 21 20:07 '.raw-https:\x2f\x2falpha\x2erelease\x2ecore-os\x2enet\x2famd64-usr\x2fcurrent\x2fcoreos_developer_container\x2ebin\x2ebz2.\x22f03372edea9a1e7232e282c346099857\x22.raw' -r--r--r-- 1 root root 3303014400 Aug 17 06:15 '.raw-https:\x2f\x2falpha\x2erelease\x2eflatcar-linux\x2enet\x2famd64-usr\x2fcurrent\x2fflatcar_developer_container\x2ebin\x2ebz2.raw' ``` As a result, when the Flatcar image is removed and downloaded again, systemd-importd is not able to determine if the file has been already downloaded, so it always download it again. Then it fails to rename it to an expected name, because there's already a hidden file. To fix this issue, let's introduce a new helper function `memory_startswith_no_case()`, which compares memory regions in a case-insensitive way. Use this function in `curl_header_strdup()`. See also [1]: (cherry picked from commit 21224070e802878f81c342835364880ef1a63e88)
Diffstat (limited to 'src/test/test-bus-util.c')
0 files changed, 0 insertions, 0 deletions