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: ac5206aa9c ('2007-11-21')
(cherry picked from commit 581aa981c2)
This commit is contained in:
Beniamino Galvani 2020-05-07 09:30:02 +02:00
parent 144e7e40f0
commit bb40de0ca0

View file

@ -1492,6 +1492,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);