mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
importd: accept a single space as SHA256SUMS separator
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.
This commit is contained in:
committed by
Luca Boccassi
parent
de9e6428b5
commit
265386ba35
@@ -6,6 +6,7 @@
|
||||
#include "dirent-util.h"
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
#include "hexdecoct.h"
|
||||
#include "io-util.h"
|
||||
#include "log.h"
|
||||
#include "memory-util.h"
|
||||
@@ -333,7 +334,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);
|
||||
@@ -366,17 +366,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 */
|
||||
|
||||
Reference in New Issue
Block a user