mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-13 20:56:17 +00:00
Fix a use after free in the xmlrpc-c index path
The string was freed before it was tested, and tmp was never released.
This commit is contained in:
+3
-1
@@ -77,16 +77,18 @@ xmlrpc_list_entry_to_value(xmlrpc_env* env, xmlrpc_value* src, int index) {
|
|||||||
{
|
{
|
||||||
const char* str;
|
const char* str;
|
||||||
xmlrpc_read_string(env, tmp, &str);
|
xmlrpc_read_string(env, tmp, &str);
|
||||||
|
xmlrpc_DECREF(tmp);
|
||||||
|
|
||||||
if (env->fault_occurred)
|
if (env->fault_occurred)
|
||||||
throw xmlrpc_error_c(env);
|
throw xmlrpc_error_c(env);
|
||||||
|
|
||||||
const char* end = str;
|
const char* end = str;
|
||||||
int64_t v3 = ::strtoll(str, (char**)&end, 0);
|
int64_t v3 = ::strtoll(str, (char**)&end, 0);
|
||||||
|
bool invalid = *str == '\0' || *end != '\0';
|
||||||
|
|
||||||
::free((void*)str);
|
::free((void*)str);
|
||||||
|
|
||||||
if (*str == '\0' || *end != '\0')
|
if (invalid)
|
||||||
throw xmlrpc_error_c(XMLRPC_TYPE_ERROR, "Invalid index.");
|
throw xmlrpc_error_c(XMLRPC_TYPE_ERROR, "Invalid index.");
|
||||||
|
|
||||||
return v3;
|
return v3;
|
||||||
|
|||||||
Reference in New Issue
Block a user