core: fix nm_utils_file_set_contents() handling of -1 length

nm_utils_file_set_contents() must compute the content size when
@length is -1.

Fixes: 21358edc54
This commit is contained in:
Beniamino Galvani 2017-02-08 11:33:29 +01:00 committed by Thomas Haller
parent ec91f950b8
commit 0a0893280b

View file

@ -4076,6 +4076,9 @@ nm_utils_file_set_contents (const gchar *filename,
g_return_val_if_fail (!error || !*error, FALSE);
g_return_val_if_fail (length >= -1, FALSE);
if (length == -1)
length = strlen (contents);
tmp_name = g_strdup_printf ("%s.XXXXXX", filename);
fd = g_mkstemp_full (tmp_name, O_RDWR, mode);
if (fd < 0) {