summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2011-01-12 20:41:19 (UTC)
committer Michael Krelin <hacker@klever.net>2011-01-12 20:41:19 (UTC)
commit824440e52ce8ddf1c45487d20d8996d08d0f96b5 (patch) (side-by-side diff)
tree36c48bea8deeccaccd181c3ecc08b452908c9ee9
parentc34fa95284928944bdd1b72aba164767257dd46f (diff)
downloadlibopkele-824440e52ce8ddf1c45487d20d8996d08d0f96b5.zip
libopkele-824440e52ce8ddf1c45487d20d8996d08d0f96b5.tar.gz
libopkele-824440e52ce8ddf1c45487d20d8996d08d0f96b5.tar.bz2
fix uninitialized pointer in discovery
it's not the most brilliant idea to pass the uninitialized structure and dereference the pointer member later on. Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/discovery.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index b4ed3b6..5585e12 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -75,97 +75,97 @@ namespace opkele {
enum {
xmode_html = 1, xmode_xrd = 2, xmode_cid = 4,
xmode_noredirs = 8
};
int xmode;
string xrds_location;
string http_content_type;
service_t html_openid1;
service_t html_openid2;
string cdata_buf;
long status_code;
string status_string;
typedef list<string> pt_stack_t;
pt_stack_t pt_stack;
int skipping;
bool parser_choked;
string save_html;
XRD_t *xrd;
service_t *xrd_service;
string* cdata;
idigger_t()
: util::curl_t(easy_init()),
util::expat_t(0),
xri_proxy(XRI_PROXY_URL) {
CURLcode r;
(r=misc_sets())
|| (r=set_write())
|| (r=set_header())
;
if(r)
throw exception_curl(OPKELE_CP_ "failed to set curly options",r);
}
~idigger_t() throw() { }
void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) {
idiscovery_t idis;
idis.xri_identity = false;
discover_at(idis,yurl,xmode_html|xmode_xrd|(redirs?0:xmode_noredirs));
if(!xrds_location.empty()) {
idis.clear();
discover_at(idis,xrds_location,xmode_xrd);
}
idis.normalized_id = idis.canonicalized_id = yurl;
- service_type_t st;
+ service_type_t st = { 0, 0 };
for(st.uri=*types;*types;st.uri=*(++types))
queue_endpoints(oi,idis,&st);
}
string discover(endpoint_discovery_iterator& oi,const string& identity) {
string rv;
idiscovery_t idis;
string::size_type fsc = identity.find_first_not_of(data::_whitespace_chars);
if(fsc==string::npos)
throw bad_input(OPKELE_CP_ "whitespace-only identity");
string::size_type lsc = identity.find_last_not_of(data::_whitespace_chars);
assert(lsc!=string::npos);
if(!strncasecmp(identity.c_str()+fsc,"xri://",sizeof("xri://")-1))
fsc += sizeof("xri://")-1;
if((fsc+1)>=lsc)
throw bad_input(OPKELE_CP_ "not a character of importance in identity");
string id(identity,fsc,lsc-fsc+1);
idis.clear();
if(strchr(data::_iname_leaders,id[0])) {
/* TODO: further normalize xri identity? Like folding case
* or whatever... */
rv = id;
set<string> cids;
for(const struct service_type_t *st=op_service_types;
st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st) {
idis.clear();
discover_at( idis,
xri_proxy + util::url_encode(id)+
"?_xrd_t="+util::url_encode(st->uri)+
"&_xrd_r=application/xrd%2Bxml"
";sep=true;refs=true",
xmode_xrd );
if(status_code==241) continue;
if(status_code!=100)
throw failed_xri_resolution(OPKELE_CP_
"XRI resolution failed with '"+status_string+"' message"
", while looking for SEP with type '"+st->uri+"'", status_code);
if(idis.xrd.canonical_ids.empty())
throw opkele::failed_discovery(OPKELE_CP_ "No CanonicalID for XRI identity found");
string cid = idis.xrd.canonical_ids.begin()->second;
if(cids.find(cid)==cids.end()) {
cids.insert(cid);
idis.clear();
discover_at( idis,
xri_proxy + util::url_encode(id)+
"?_xrd_t="+util::url_encode(st->uri)+
"&_xrd_r=application/xrd%2Bxml"
";sep=true;refs=true",