summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-05-07 09:30:02 +0200
committerThomas Haller <thaller@redhat.com>2020-09-08 12:38:20 +0200
commit1c82f1e263694186003af7744bac723cd78d1f62 (patch)
tree10a975d0b83b3d31c7f358d7c6154e1dabe3d5c4
parent5ab31f998e0c990e8a9391f39a9ec09cc1bef7da (diff)
downloadNetworkManager-1c82f1e263694186003af7744bac723cd78d1f62.tar.gz
ifcfg-rh: check return value of fdopen()
Reported by coverity: >>> CID 210222: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing a pointer that might be "NULL" "f" when calling "fseek". Fixes: ac5206aa9c5a ('2007-11-21') (cherry picked from commit 581aa981c27d4bde17eb8772fe92697f586a6ed6) (cherry picked from commit bb40de0ca02e4f41e17d3fdccd0df87c79182bdd) (cherry picked from commit cde95a3c755cc350ea0b9d24f35f88b2b2aad067)
-rw-r--r--src/settings/plugins/ifcfg-rh/shvar.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c
index d4bc71f3f5..f00b5e2361 100644
--- a/src/settings/plugins/ifcfg-rh/shvar.c
+++ b/src/settings/plugins/ifcfg-rh/shvar.c
@@ -1420,6 +1420,13 @@ svWriteFile (shvarFile *s, int mode, GError **error)
return FALSE;
}
f = fdopen (tmpfd, "w");
+ if (!f) {
+ errsv = errno;
+ g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv),
+ "Internal error writing file '%s': %s",
+ s->fileName, nm_strerror_native (errsv));
+ return FALSE;
+ }
fseek (f, 0, SEEK_SET);
c_list_for_each (current, &s->lst_head) {
const shvarLine *line = c_list_entry (current, shvarLine, lst);