From daafc5a368266dc2206b7da0c107b98e0ca042d6 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sat, 7 May 2011 19:26:12 +0300 Subject: [PATCH] options: fix -profile parsing after 2db33ab48c Commit 2db33ab48cfa785 ("options: support string list separators other than ','") started using the "priv" field in options of string list type to store the separator character. However, the "profile" option has a custom type which uses the same parsing function but uses the "priv" field for another purpose. As a result "-profile" parsing used a "random" character as the separator instead of ','; at least uses which depended on ',' working were likely to fail, and if the separator used happened to be a character occurring in the profile name then any use of -profile could break. Fix by adding a check in the parsing function to only read the priv field if the option type is normal string list. --- m_option.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/m_option.c b/m_option.c index c388bc0929..927b93cd69 100644 --- a/m_option.c +++ b/m_option.c @@ -682,7 +682,9 @@ static int parse_str_list(const m_option_t* opt,const char *name, const char *pa if (param == NULL || strlen(param) == 0) return M_OPT_MISSING_PARAM; - char separator = opt->priv ? *(char *)opt->priv : OPTION_LIST_SEPARATOR; + // custom type for "profile" calls this but uses ->priv for something else + char separator = opt->type == &m_option_type_string_list && opt->priv ? + *(char *)opt->priv : OPTION_LIST_SEPARATOR; while(ptr[0] != '\0') { ptr = get_nextsep(ptr, separator, 0); if(!ptr) { -- 2.11.4.GIT