Skip to content

Commit

Permalink
Merge pull request #16 from rufferson/master
Browse files Browse the repository at this point in the history
Some memory leaks, spec preference, oob and transfer fixup
  • Loading branch information
Junker authored Mar 31, 2020
2 parents fcb7c67 + fbbd4b1 commit 72e343d
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 79 deletions.
60 changes: 28 additions & 32 deletions src/hfu_disco.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,42 @@ static void jabber_hfu_disco_info_cb(JabberStream *js, const char *from,

query = xmlnode_get_child_with_namespace(packet, "query", NS_DISCO_INFO);

if (type == JABBER_IQ_RESULT && query)
{
js_data = g_hash_table_lookup(HFUJabberStreamDataTable, js);
if (!js_data) return;
if (type != JABBER_IQ_RESULT || query == NULL)
return;

js_data = g_hash_table_lookup(HFUJabberStreamDataTable, js);
// Always prefer latest standard, skip if already found
if (!js_data || str_equal(js_data->ns, NS_HTTP_FILE_UPLOAD_V0))
return;

for (feature = xmlnode_get_child(query, "feature") ; feature; feature = xmlnode_get_next_twin(feature))
{
const char *var = xmlnode_get_attrib(feature, "var");
if(!var)
continue;
const char *var = xmlnode_get_attrib(feature, "var");
if(!var)
continue;

if(str_equal(var, NS_HTTP_FILE_UPLOAD))
js_data->ns = NS_HTTP_FILE_UPLOAD;
else if(str_equal(var, NS_HTTP_FILE_UPLOAD_V0))
js_data->ns = NS_HTTP_FILE_UPLOAD_V0;
if(str_equal(var, NS_HTTP_FILE_UPLOAD) && js_data->ns == NULL)
js_data->ns = NS_HTTP_FILE_UPLOAD;
else if(str_equal(var, NS_HTTP_FILE_UPLOAD_V0))
js_data->ns = NS_HTTP_FILE_UPLOAD_V0;
else
continue;

g_free(js_data->host);
js_data->host = g_strdup(from);

if (str_equal(var, NS_HTTP_FILE_UPLOAD) || str_equal(var, NS_HTTP_FILE_UPLOAD_V0))
x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data");
if (x)
{
for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field))
{
js_data->host = g_strdup(from);

x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data");
if (x)
{
for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field))
{
const char *var = xmlnode_get_attrib(field, "var");

if(var && str_equal(var, "max-file-size"))
{
if((value = xmlnode_get_child(field, "value")))
{
js_data->max_file_size = (gsize) atol(xmlnode_get_data(value));
}
}
}
}
const char *var = xmlnode_get_attrib(field, "var");

if(var && str_equal(var, "max-file-size"))
if((value = xmlnode_get_child(field, "value")))
js_data->max_file_size = (gsize) atol(xmlnode_get_data(value));
}
}


}
}

Expand Down
Loading

0 comments on commit 72e343d

Please sign in to comment.