for handling a litle strange descriptor.

# I do pull request again because I had closed pull request by mistake.

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'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
searching in [/tmp/gadget-6Aepe2]
Starting setup writer thread (10769) for EP00.
Starting setup reader thread (10768) for EP00.
[80 06 00 03 00 00 ff 00]
[80 06 00 03 00 00 04 00]: 04 03 09 04
[80 06 03 03 09 04 ff 00]
[80 06 03 03 09 04 2e 00]: 
	2e 03 53 00 41 00 4d 00 53 00 55 00 4e 00 47 00 5f 00 41 00 6e 00 64 00 72 00 6f 00 69 00 64 00
	5f 00 53 00 43 00 2d 00 30 00 36 00 44 00
[80 06 02 03 09 04 ff 00]
[80 06 02 03 09 04 10 00]: 10 03 53 00 41 00 4d 00 53 00 55 00 4e 00 47 00
[80 06 04 03 09 04 ff 00]
[80 06 04 03 09 04 12 00]: 12 03 64 00 30 00 31 00 32 00 30 00 39 00 37 00 33 00
[40 f0 01 00 4c 05 00 00]
[00 09 01 00 00 00 00 00]
Opened EP82
Starting writer thread (10775) for EP82.
[80 06 05 03 09 04 ff 00]
[80 06 05 03 09 04 40 00]: 
	40 03 43 00 44 00 43 00 20 00 4e 00 65 00 74 00 77 00 6f 00 72 00 6b 00 20 00 43 00 6f 00 6e 00
	74 00 72 00 6f 00 6c 00 20 00 4d 00 6f 00 64 00 65 00 6c 00 20 00 28 00 4e 00 43 00 4d 00 29 00p
Starting reader thread (10774) for EP82.
[01 0b 00 00 01 00 00 00]
[a1 80 00 00 00 00 1c 00]
[a1 80 00 00 00 00 1c 00]: 1c 00 03 00 00 08 00 00 04 00 00 00 04 00 00 00 00 40 00 00 04 00 00 00 04 00 00 00
[21 8a 00 00 00 00 00 00]
[21 84 00 00 00 00 00 00]
[01 0b 01 00 01 00 00 00]
[80 06 07 03 09 04 ff 00]
[80 06 07 03 09 04 1a 00]: 1a 03 30 00 32 00 35 00 44 00 30 00 37 00 30 00 32 00 33 00 32 00 33 00 30 00
[80 06 06 03 09 04 ff 00]
[80 06 06 03 09 04 22 00]: 
	22 03 43 00 44 00 43 00 20 00 4e 00 65 00 74 00 77 00 6f 00 72 00 6b 00 20 00 44 00 61 00 74 00
	61 00
82[16]: a1 2a 00 00 00 00 08 00 00 00 64 19 00 00 64 19
82[8]: a1 00 01 00 00 00 00 00
^CReceived SIGINT, stopping relaying...
Finished setup reader thread (10768) for EP00.
Finished setup writer thread (10769) for EP00.
Finished reader thread (10774) for EP82.
Finished writer thread (10775) for EP82.
*** glibc detected *** tools/usb-mitm: double free or corruption (out): 0x00016c98 ***
Aborted