config: ensure that both ABI and MODULE are specified before the properties

If we have properties, strtok will return strings from there as tokens
and the error will appear later as we will attempt to parse an incomplete
GVariant. It is better to catch this early so that we can print a more
useful error message.
This commit is contained in:
George Kiagiadakis
2019-06-27 18:30:11 +03:00
parent 22699a4b21
commit 1e7bcd8943

View File

@@ -152,7 +152,9 @@ parse_commands_file (struct WpDaemonData *d, GInputStream * stream,
abi = strtok_r (NULL, " ", &saveptr); abi = strtok_r (NULL, " ", &saveptr);
module = strtok_r (NULL, " ", &saveptr); module = strtok_r (NULL, " ", &saveptr);
if (!abi || !module) { if (!abi || !module ||
(abi && abi[0] == '{') || (module && module[0] == '{'))
{
g_set_error (error, WP_DOMAIN_DAEMON, WP_CODE_INVALID_ARGUMENT, g_set_error (error, WP_DOMAIN_DAEMON, WP_CODE_INVALID_ARGUMENT,
"expected ABI and MODULE at line %i", lineno); "expected ABI and MODULE at line %i", lineno);
return FALSE; return FALSE;