mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
dissect: avoid overflow access by NULLSTR_FOREACH
NULLSTR_FOREACH expects two terminating NULs, but the joined string for extension-release.d only had the canonical one. Use a placeholder when joining and fix it manually.
This commit is contained in:
parent
07a7441a1c
commit
4f67a5d923
@ -2270,9 +2270,11 @@ int dissected_image_acquire_metadata(DissectedImage *m) {
|
||||
|
||||
/* As per the os-release spec, if the image is an extension it will have a file
|
||||
* named after the image name in extension-release.d/ */
|
||||
if (m->image_name)
|
||||
paths[META_EXTENSION_RELEASE] = strjoina("/usr/lib/extension-release.d/extension-release.", m->image_name);
|
||||
else
|
||||
if (m->image_name) {
|
||||
char *ext = strjoina("/usr/lib/extension-release.d/extension-release.", m->image_name, "0");
|
||||
ext[strlen(ext) - 1] = '\0'; /* Extra \0 for NULSTR_FOREACH using placeholder from above */
|
||||
paths[META_EXTENSION_RELEASE] = ext;
|
||||
} else
|
||||
log_debug("No image name available, will skip extension-release metadata");
|
||||
|
||||
for (; n_meta_initialized < _META_MAX; n_meta_initialized ++) {
|
||||
|
Loading…
Reference in New Issue
Block a user