]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
importd: accept a single space as SHA256SUMS separator
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Aug 2025 07:23:07 +0000 (09:23 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 3 Sep 2025 10:10:48 +0000 (12:10 +0200)
The SHA256SUMS files provided by https://images.linuxcontainers.org/
are slightly non-conforming, insted of using " *" or "  " as separator
between hash and file name they use " ". Let's accept that too, in the
interest of maximizing compatibility.

(cherry picked from commit 265386ba35463bf38f309cce7ef0dc78769eb2b3)

src/import/pull-common.c

index 9a2ced002b4511e88274e35be71b7c5c2de28852..3f5a338890101879852526f9958951ca705d4842 100644 (file)
@@ -10,6 +10,7 @@
 #include "discover-image.h"
 #include "escape.h"
 #include "fd-util.h"
+#include "hexdecoct.h"
 #include "hostname-util.h"
 #include "io-util.h"
 #include "memory-util.h"
@@ -318,7 +319,6 @@ int pull_make_verification_jobs(
 
 static int verify_one(PullJob *checksum_job, PullJob *job) {
         _cleanup_free_ char *fn = NULL;
-        const char *line, *p;
         int r;
 
         assert(checksum_job);
@@ -351,17 +351,23 @@ static int verify_one(PullJob *checksum_job, PullJob *job) {
                 return log_error_errno(SYNTHETIC_ERRNO(ELOOP),
                                        "Cannot verify checksum/signature files via themselves.");
 
-        line = strjoina(job->checksum, " *", fn, "\n"); /* string for binary mode */
-        p = memmem_safe(checksum_job->payload,
-                        checksum_job->payload_size,
-                        line,
-                        strlen(line));
-        if (!p) {
-                line = strjoina(job->checksum, "  ", fn, "\n"); /* string for text mode */
+        const char *p = NULL;
+        FOREACH_STRING(separator,
+                       " *", /* separator for binary mode */
+                       "  ", /* separator for text mode */
+                       " "   /* non-standard separator used by linuxcontainers.org */) {
+                _cleanup_free_ char *line = NULL;
+
+                line = strjoin(job->checksum, separator, fn, "\n");
+                if (!line)
+                        return log_oom();
+
                 p = memmem_safe(checksum_job->payload,
                                 checksum_job->payload_size,
                                 line,
                                 strlen(line));
+                if (p)
+                        break;
         }
 
         /* Only counts if found at beginning of a line */