1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 03:12:44 +00:00

fix: check tr_ctorSetFoo() return values before adding torrent via RPC (#5202)

This commit is contained in:
Charles Kerr 2023-03-11 19:44:54 -06:00 committed by GitHub
parent 3039ff1390
commit 900281eb1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1688,21 +1688,25 @@ char const* torrentAdd(tr_session* session, tr_variant* args_in, tr_variant* /*a
}
else
{
auto ok = false;
if (std::empty(filename))
{
auto const metainfo = tr_base64_decode(metainfo_base64);
tr_ctorSetMetainfo(ctor, std::data(metainfo), std::size(metainfo), nullptr);
ok = tr_ctorSetMetainfo(ctor, std::data(metainfo), std::size(metainfo), nullptr);
}
else if (tr_sys_path_exists(tr_pathbuf{ filename }))
{
ok = tr_ctorSetMetainfoFromFile(ctor, filename);
}
else
{
if (tr_sys_path_exists(tr_pathbuf{ filename }))
{
tr_ctorSetMetainfoFromFile(ctor, filename);
}
else
{
tr_ctorSetMetainfoFromMagnetLink(ctor, filename);
}
ok = tr_ctorSetMetainfoFromMagnetLink(ctor, filename);
}
if (!ok)
{
return "unrecognized info";
}
addTorrentImpl(idle_data, ctor);