1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +03:00

dissect-image: initially fds[] array fully

THe previous code wasn't wrong, but it's certainly nicer to avoid a
partially uninitialized array here, hence Coverity has a point
complaining about this.

Coverity 1446731
This commit is contained in:
Lennart Poettering 2021-02-23 15:11:07 +01:00
parent 999c248629
commit d9119c00fa

View File

@ -2280,8 +2280,11 @@ int dissected_image_acquire_metadata(DissectedImage *m) {
log_debug("No image name available, will skip extension-release metadata");
for (; n_meta_initialized < _META_MAX; n_meta_initialized ++) {
if (!paths[n_meta_initialized])
if (!paths[n_meta_initialized]) {
fds[2*n_meta_initialized] = fds[2*n_meta_initialized+1] = -1;
continue;
}
if (pipe2(fds + 2*n_meta_initialized, O_CLOEXEC) < 0) {
r = -errno;
goto finish;
@ -2435,11 +2438,8 @@ int dissected_image_acquire_metadata(DissectedImage *m) {
strv_free_and_replace(m->extension_release, extension_release);
finish:
for (k = 0; k < n_meta_initialized; k++) {
if (!paths[k])
continue;
for (k = 0; k < n_meta_initialized; k++)
safe_close_pair(fds + 2*k);
}
return r;
}