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) (unidiff)
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
@@ -99,49 +99,49 @@ namespace opkele {
99 99
100 idigger_t() 100 idigger_t()
101 : util::curl_t(easy_init()), 101 : util::curl_t(easy_init()),
102 util::expat_t(0), 102 util::expat_t(0),
103 xri_proxy(XRI_PROXY_URL) { 103 xri_proxy(XRI_PROXY_URL) {
104 CURLcode r; 104 CURLcode r;
105 (r=misc_sets()) 105 (r=misc_sets())
106 || (r=set_write()) 106 || (r=set_write())
107 || (r=set_header()) 107 || (r=set_header())
108 ; 108 ;
109 if(r) 109 if(r)
110 throw exception_curl(OPKELE_CP_ "failed to set curly options",r); 110 throw exception_curl(OPKELE_CP_ "failed to set curly options",r);
111 } 111 }
112 ~idigger_t() throw() { } 112 ~idigger_t() throw() { }
113 113
114 void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) { 114 void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) {
115 idiscovery_t idis; 115 idiscovery_t idis;
116 idis.xri_identity = false; 116 idis.xri_identity = false;
117 discover_at(idis,yurl,xmode_html|xmode_xrd|(redirs?0:xmode_noredirs)); 117 discover_at(idis,yurl,xmode_html|xmode_xrd|(redirs?0:xmode_noredirs));
118 if(!xrds_location.empty()) { 118 if(!xrds_location.empty()) {
119 idis.clear(); 119 idis.clear();
120 discover_at(idis,xrds_location,xmode_xrd); 120 discover_at(idis,xrds_location,xmode_xrd);
121 } 121 }
122 idis.normalized_id = idis.canonicalized_id = yurl; 122 idis.normalized_id = idis.canonicalized_id = yurl;
123 service_type_t st; 123 service_type_t st = { 0, 0 };
124 for(st.uri=*types;*types;st.uri=*(++types)) 124 for(st.uri=*types;*types;st.uri=*(++types))
125 queue_endpoints(oi,idis,&st); 125 queue_endpoints(oi,idis,&st);
126 } 126 }
127 127
128 string discover(endpoint_discovery_iterator& oi,const string& identity) { 128 string discover(endpoint_discovery_iterator& oi,const string& identity) {
129 string rv; 129 string rv;
130 idiscovery_t idis; 130 idiscovery_t idis;
131 string::size_type fsc = identity.find_first_not_of(data::_whitespace_chars); 131 string::size_type fsc = identity.find_first_not_of(data::_whitespace_chars);
132 if(fsc==string::npos) 132 if(fsc==string::npos)
133 throw bad_input(OPKELE_CP_ "whitespace-only identity"); 133 throw bad_input(OPKELE_CP_ "whitespace-only identity");
134 string::size_type lsc = identity.find_last_not_of(data::_whitespace_chars); 134 string::size_type lsc = identity.find_last_not_of(data::_whitespace_chars);
135 assert(lsc!=string::npos); 135 assert(lsc!=string::npos);
136 if(!strncasecmp(identity.c_str()+fsc,"xri://",sizeof("xri://")-1)) 136 if(!strncasecmp(identity.c_str()+fsc,"xri://",sizeof("xri://")-1))
137 fsc += sizeof("xri://")-1; 137 fsc += sizeof("xri://")-1;
138 if((fsc+1)>=lsc) 138 if((fsc+1)>=lsc)
139 throw bad_input(OPKELE_CP_ "not a character of importance in identity"); 139 throw bad_input(OPKELE_CP_ "not a character of importance in identity");
140 string id(identity,fsc,lsc-fsc+1); 140 string id(identity,fsc,lsc-fsc+1);
141 idis.clear(); 141 idis.clear();
142 if(strchr(data::_iname_leaders,id[0])) { 142 if(strchr(data::_iname_leaders,id[0])) {
143 /* TODO: further normalize xri identity? Like folding case 143 /* TODO: further normalize xri identity? Like folding case
144 * or whatever... */ 144 * or whatever... */
145 rv = id; 145 rv = id;
146 set<string> cids; 146 set<string> cids;
147 for(const struct service_type_t *st=op_service_types; 147 for(const struct service_type_t *st=op_service_types;