From 09ecfb6567f3f4ea2e70e3e9d7f54c8f909271c0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 20 Feb 2009 12:31:00 +0100 Subject: path: validate configured character set --- src/path.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/path.c') diff --git a/src/path.c b/src/path.c index 01480bee4..1b6405cb0 100644 --- a/src/path.c +++ b/src/path.c @@ -21,6 +21,7 @@ #include +#include #include #undef G_LOG_DOMAIN @@ -53,6 +54,16 @@ utf8_to_fs_charset(const char *path_utf8) void path_set_fs_charset(const char *charset) { + char *test; + + assert(charset != NULL); + + /* convert a space to ensure that the charset is valid */ + test = g_convert(" ", 1, charset, "UTF-8", NULL, NULL, NULL); + if (test == NULL) + g_error("invalid filesystem charset: %s", charset); + g_free(test); + g_free(fs_charset); fs_charset = g_strdup(charset); -- cgit v1.2.3