- iface = (void*)cur_ptr;
- // TODO: Sanity check with remaining space
- cur_ptr += sizeof(*iface);
+ size_t iface_base_ofs;
+
+ iface = (void*)(full_buf + ptr_ofs);
+ if( iface->Length == 0 ) {
+ Log_Warning("USB", "Bad USB descriptor (length = 0)");
+ break ;
+ }
+ ptr_ofs += iface->Length;
+ if( ptr_ofs > total_length ) {
+ // Sanity fail
+ break;
+ }
+ iface_base_ofs = ptr_ofs;
+ // Check type
+ if( iface->Type != 4 ) {
+ LOG("Not an interface (type = %i)", iface->Type);
+ j --; // Counteract j++ in loop
+ continue ;
+ }