Commit bb40de0c authored by Beniamino Galvani's avatar Beniamino Galvani

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: ac5206aa ('2007-11-21')
(cherry picked from commit 581aa981)
parent 144e7e40
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment