Skip to content

Commit 9442528

Browse files
jefdriesenmikeller
authored andcommitted
Check the descriptor transport in the filter
The filter function should take into account the transports supported by the device descriptor. If a transport isn't supported, the filter function shouldn't indicate a match.
1 parent c6acdf3 commit 9442528

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/descriptor.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,13 @@ dc_descriptor_get_transports (const dc_descriptor_t *descriptor)
10631063
int
10641064
dc_descriptor_filter (const dc_descriptor_t *descriptor, dc_transport_t transport, const void *userdata)
10651065
{
1066-
if (descriptor == NULL || descriptor->filter == NULL || userdata == NULL)
1066+
if (descriptor == NULL)
1067+
return 1;
1068+
1069+
if ((descriptor->transports & transport) == 0)
1070+
return 0;
1071+
1072+
if (descriptor->filter == NULL || userdata == NULL)
10671073
return 1;
10681074

10691075
return descriptor->filter (descriptor, transport, userdata);

0 commit comments

Comments
 (0)