for handling a litle strange descriptor.

Hi,

I'm modifying USBProxy for some software on Android smartphone.
The smartphone behaves like an network interface in that time, and it tell USBProxy a little strange descriptor as follows.

Then, I have 2 problems. 

At the first, in Device::add_string(), USBProxy frees allocated memory twice or more sometimes because it assigned a same String Descriptor to 2 or more elements of strings[][] array. Therefore delete(strings[index][i]) was commented out.It means I have another problem for leaking memory.

At the second, some descriptors don't have a consecutive number. For example, the first Interface descriptor has the zeroth and the second alternate interface descriptors. Therefore the first alternate interface descriptor becomes NULL, but USBProxy causes 'segmentation fault' when it calculates the length of descriptors for example. Then I modified them to avoid NULL descriptor.

I don't know whether there is this along your intention. I will send you 'pull request'. I'd like you review it.

root@arm:~/Projects/USBProxy/build# tools/usb-mitm -dd -l
SIGRTMIN: 34
CP: Vector Plugins
CP: Pointer PacketFilter_StreamLog::file
CP: String DeviceProxy = DeviceProxy_LibUSB
CP: String HostProxy = HostProxy_GadgetFS
Loading plugins from /usr/local/lib/USBProxy/
vendorId=ffffffff
productId=ffffffff
cleaning up /tmp
removing 1
Made directory /tmp/gadget-6Aepe2 for gadget
Printing Config data
	Strings: 2
		DeviceProxy: DeviceProxy_LibUSB
		HostProxy: HostProxy_GadgetFS
	Vectors: 1
		Plugins:
			PacketFilter_StreamLog
Pointer: 1
		PacketFilter_StreamLog::file: 0xb6d77540
Made directory /tmp/mqueue-gd1BOY for mqueue
cleaning up /tmp/mqueue-gd1BOY
removing 2
Device: 12 01 00 02 02 00 00 40 e8 04 5d 68 28 02 02 03 04 01
  Manufacturer: SAMSUNG
  Product:      SAMSUNG_Android_SC-06D
  Serial:       d0120973
	*Config(1): 09 02 5e 00 02 01 00 c0 30
		Interface(0):
			*Alt(0): 09 04 00 00 01 02 0d 00 05
			   Name: CDC Network Control Model (NCM)
			Other(24): 05 24 00 10 01
			Other(24): 05 24 06 00 01
			Other(24): 0d 24 0f 07 00 00 00 00 ea 05 00 00 00
			Other(24): 06 24 1a 00 01 11
				EP(82): 07 05 82 03 10 00 09
			 Alt(2): 08 0b 00 02 02 0d 00 08 08
			   Name: CDC NCM
		Interface(1):
			*Alt(0): 09 04 01 00 00 0a 00 01 06
			   Name: CDC Network Data
			 Alt(1): 09 04 01 01 02 0a 00 01 06
			   Name: CDC Network Data
				EP(81): 07 05 81 02 00 02 00
				EP(01): 07 05 01 02 00 02 00
HS Qualifier: 0a 06 00 02 02 00 00 40 01 00
	 Config(1): 09 07 5e 00 02 01 00 c0 30
		Interface(0):
			*Alt(0): 09 04 00 00 01 02 0d 00 05
			   Name: CDC Network Control Model (NCM)
			Other(24): 05 24 00 10 01
			Other(24): 05 24 06 00 01
			Other(24): 0d 24 0f 07 00 00 00 00 ea 05 00 00 00
			Other(24): 06 24 1a 00 01 11
				EP(82): 07 05 82 03 10 00 20
			 Alt(2): 08 0b 00 02 02 0d 00 08 08
			   Name: CDC NCM
		Interface(1):
			*Alt(0): 09 04 01 00 00 0a 00 01 06
			   Name: CDC Network Data
			 Alt(1): 09 04 01 01 02 0a 00 01 06
			   Name: CDC Network Data
				EP(81): 07 05 81 02 40 00 00
				EP(01): 07 05 01 02 40 00 00


--
Kiyotaka Atsumi
atsumi@aizulab.com, kiyotaka@ka-lab.jp