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 else
{ {
auto ok = false;
if (std::empty(filename)) if (std::empty(filename))
{ {
auto const metainfo = tr_base64_decode(metainfo_base64); 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 else
{ {
if (tr_sys_path_exists(tr_pathbuf{ filename })) ok = tr_ctorSetMetainfoFromMagnetLink(ctor, filename);
{ }
tr_ctorSetMetainfoFromFile(ctor, filename);
} if (!ok)
else {
{ return "unrecognized info";
tr_ctorSetMetainfoFromMagnetLink(ctor, filename);
}
} }
addTorrentImpl(idle_data, ctor); addTorrentImpl(idle_data, ctor);