From 39f0b276c782ea5a23fed6e3ff3b374b8a29f1df Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Tue, 25 Feb 2014 12:22:30 +0900 Subject: [PATCH] taskschd: Don't accept task XML with an invalid boolean value. --- dlls/taskschd/task.c | 44 ++++++++++++++++----------------- dlls/taskschd/tests/scheduler.c | 1 - 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/dlls/taskschd/task.c b/dlls/taskschd/task.c index 1288314bb2f..7dd9f04b628 100644 --- a/dlls/taskschd/task.c +++ b/dlls/taskschd/task.c @@ -1553,8 +1553,8 @@ static HRESULT read_variantbool_value(IXmlReader *reader, VARIANT_BOOL *vbool) *vbool = VARIANT_FALSE; else { - FIXME("unexpected bool value %s\n", debugstr_w(value)); - return E_FAIL; + WARN("unexpected bool value %s\n", debugstr_w(value)); + return SCHED_E_INVALIDVALUE; } return S_OK; @@ -1826,62 +1826,62 @@ static HRESULT read_settings(IXmlReader *reader, ITaskSettings *taskset) else if (!lstrcmpW(name, DisallowStartIfOnBatteries)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_DisallowStartIfOnBatteries(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_DisallowStartIfOnBatteries(taskset, bool_val); } else if (!lstrcmpW(name, AllowStartOnDemand)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_AllowDemandStart(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_AllowDemandStart(taskset, bool_val); } else if (!lstrcmpW(name, StopIfGoingOnBatteries)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_StopIfGoingOnBatteries(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_StopIfGoingOnBatteries(taskset, bool_val); } else if (!lstrcmpW(name, AllowHardTerminate)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_AllowHardTerminate(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_AllowHardTerminate(taskset, bool_val); } else if (!lstrcmpW(name, StartWhenAvailable)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_StartWhenAvailable(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_StartWhenAvailable(taskset, bool_val); } else if (!lstrcmpW(name, RunOnlyIfNetworkAvailable)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_RunOnlyIfNetworkAvailable(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_RunOnlyIfNetworkAvailable(taskset, bool_val); } else if (!lstrcmpW(name, Enabled)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_Enabled(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_Enabled(taskset, bool_val); } else if (!lstrcmpW(name, Hidden)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_Hidden(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_Hidden(taskset, bool_val); } else if (!lstrcmpW(name, RunOnlyIfIdle)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_RunOnlyIfIdle(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_RunOnlyIfIdle(taskset, bool_val); } else if (!lstrcmpW(name, WakeToRun)) { hr = read_variantbool_value(reader, &bool_val); - if (hr == S_OK) - ITaskSettings_put_WakeToRun(taskset, bool_val); + if (hr != S_OK) return hr; + ITaskSettings_put_WakeToRun(taskset, bool_val); } else if (!lstrcmpW(name, ExecutionTimeLimit)) { diff --git a/dlls/taskschd/tests/scheduler.c b/dlls/taskschd/tests/scheduler.c index 48d16ddbd8f..4aad40855c4 100644 --- a/dlls/taskschd/tests/scheduler.c +++ b/dlls/taskschd/tests/scheduler.c @@ -1246,7 +1246,6 @@ todo_wine MultiByteToWideChar(CP_ACP, 0, xml7, -1, xmlW, sizeof(xmlW)/sizeof(xmlW[0])); hr = ITaskDefinition_put_XmlText(taskdef, xmlW); -todo_wine ok(hr == SCHED_E_INVALIDVALUE, "expected SCHED_E_INVALIDVALUE, got %#x\n", hr); ITaskDefinition_Release(taskdef);