File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed
src/libstd/sys/redox/net/dns Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ impl Dns {
102102 }
103103
104104 pub fn parse ( data : & [ u8 ] ) -> Result < Self , String > {
105+ let name_ind = 0b11000000 ;
105106 let mut i = 0 ;
106107
107108 macro_rules! pop_u8 {
@@ -147,9 +148,15 @@ impl Dns {
147148 ( ) => {
148149 {
149150 let mut name = String :: new( ) ;
151+ let old_i = i;
150152
151153 loop {
152154 let name_len = pop_u8!( ) ;
155+ if name_len & name_ind == name_ind {
156+ i -= 1 ;
157+ i = ( pop_n16!( ) - ( ( name_ind as u16 ) << 8 ) ) as usize ;
158+ continue ;
159+ }
153160 if name_len == 0 {
154161 break ;
155162 }
@@ -161,6 +168,10 @@ impl Dns {
161168 }
162169 }
163170
171+ if i <= old_i {
172+ i = old_i + 2 ;
173+ }
174+
164175 name
165176 }
166177 } ;
@@ -184,21 +195,8 @@ impl Dns {
184195
185196 let mut answers = Vec :: new ( ) ;
186197 for _answer_i in 0 ..answers_len {
187- let name_ind = 0b11000000 ;
188- let name_test = pop_u8 ! ( ) ;
189- i -= 1 ;
190-
191198 answers. push ( DnsAnswer {
192- name : if name_test & name_ind == name_ind {
193- let name_off = pop_n16 ! ( ) - ( ( name_ind as u16 ) << 8 ) ;
194- let old_i = i;
195- i = name_off as usize ;
196- let name = pop_name ! ( ) ;
197- i = old_i;
198- name
199- } else {
200- pop_name ! ( )
201- } ,
199+ name : pop_name ! ( ) ,
202200 a_type : pop_n16 ! ( ) ,
203201 a_class : pop_n16 ! ( ) ,
204202 ttl_a : pop_n16 ! ( ) ,
You can’t perform that action at this time.
0 commit comments