mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-25 06:46:40 -04:00
security: fix missing fdopen() NULL check in conf.c
Memory Safety: Medium In pw_conf_save_state(), the return value of fdopen() was not checked for NULL. If fdopen() fails, subsequent fprintf() and fclose() calls would operate on a NULL FILE pointer, causing a crash. Additionally, the file descriptor would be leaked since fclose() would not be called. Added a NULL check after fdopen() that closes the raw fd and returns an error on failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6798f591bd
commit
05bcfa7a2a
1 changed files with 5 additions and 0 deletions
|
|
@ -368,6 +368,11 @@ int pw_conf_save_state(const char *prefix, const char *name, const struct pw_pro
|
||||||
}
|
}
|
||||||
|
|
||||||
f = fdopen(fd, "w");
|
f = fdopen(fd, "w");
|
||||||
|
if (f == NULL) {
|
||||||
|
res = -errno;
|
||||||
|
close(fd);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
fprintf(f, "{");
|
fprintf(f, "{");
|
||||||
count += pw_properties_serialize_dict(f, &conf->dict, PW_PROPERTIES_FLAG_NL);
|
count += pw_properties_serialize_dict(f, &conf->dict, PW_PROPERTIES_FLAG_NL);
|
||||||
fprintf(f, "%s}", count == 0 ? " " : "\n");
|
fprintf(f, "%s}", count == 0 ? " " : "\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue