fix(ai): resolve UAF and require provider argument instead of defaults

This enforces explicit provider specification.
Automatic fallback to preferences or "openai" is removed.
Users must now pass the provider name explicitly.

default provider functionality was improperly removed and implemented (some parts still remain intact), leading to UAF.
This commit is contained in:
2026-05-19 16:42:22 +00:00
parent 4776c1f1ec
commit 53cdf488b6

View File

@@ -10932,21 +10932,14 @@ cmd_ai_start(ProfWin* window, const char* const command, gchar** args)
if (g_strv_length(args) >= 2) {
provider_name = args[1];
}
if (g_strv_length(args) >= 3) {
model = args[2];
if (!provider_name) {
cons_show_error("Please specify provider name.");
return TRUE;
}
// Resolve defaults
auto_gchar gchar* owned_provider_name = NULL;
if (!provider_name) {
// Use default provider from preferences
auto_gchar gchar* default_provider = prefs_get_string(PREF_AI_PROVIDER);
if (default_provider && strlen(default_provider) > 0) {
provider_name = default_provider;
}
}
if (!provider_name) {
provider_name = "openai"; // Fallback
if (g_strv_length(args) >= 3) {
model = args[2];
}
AIProvider* provider = ai_get_provider(provider_name);