lib/utils: Check for invalid UTF-8 in filenames

In case a filename contains invalid UTF-8 characters, libostree will
pass it to g_variant_builder_add() in create_tree_variant_from_hashes()
anyway, which leads to a critical warning from glib and an invalid
commit. This commit makes ostree print a useful error and exit instead.

Closes: #1271
Approved by: cgwalters
This commit is contained in:
Matthew Leeds authored and Atomic Bot committed 2017-10-14 00:47:40 +00:00
1 parent a1986b1a80
commit 2a9c5efe1d
2 files changed
+11 -1

No files matched your search

+2
View File
@@ -47,6 +47,8 @@ ot_util_filename_validate (const char *name,
return glnx_throw (error, "Invalid path uplink filename '..'");
if (strchr (name, '/') != NULL)
return glnx_throw (error, "Invalid / in filename %s", name);
if (!g_utf8_validate (name, -1, NULL))
return glnx_throw (error, "Invalid UTF-8 in filename %s", name);
return TRUE;
}