evdi icon indicating copy to clipboard operation
evdi copied to clipboard

Bad design of device registration (API of evdi_add_device function)

Open kravemir opened this issue 8 years ago • 4 comments

Hello,

I've stumbled across this project, because I'm in search of Linux compatible USB 3.0 to digital video output adapter.

I've read the API specification, and the part of it seems to be not well designed:

evdi_device_status evdi_check_device(int device);
int evdi_add_device(); // returns 0 or 1 - indicates success
evdi_handle evdi_open(int device);

In short: I see at least two problems with it:

  • the caller of evdi_add_device doesn't know the ID of added device, which will cause troubles at simultaneous usage of the libevdi by multiple additional display providers,
  • it seems to allow device stealing (might be a security issue).

Detailed: in order to register a new device, the user-space display provider has to:

  1. request a new device node using evdi_add_device function,
  2. iterate over all possible values (1 to a possible large number), and find all EVDI devices by evdi_check_device function,
  3. iterate over all EVDI devices, and try to open it using evdi_open.

This weird and complicated setup is caused, because evdi_add_device returns success indicator and no information about registered device ID. Instead of, the specification of return value should have been at least:

  • ID (where, ID > 0) - ID of the new, successfully added, device,
  • -1 - otherwise, ie. unsuccessful.

Kind regards, Miro K.

kravemir avatar Jun 13 '17 08:06 kravemir

@kravemir a pull request would probably have helped fix this issue.

MatthewBooth avatar May 16 '18 09:05 MatthewBooth

@MatthewBooth Currently, my free time is dedicated to another FOSS projects. And, I don't own any DisplayLink device to test functionality.

kravemir avatar May 19 '18 15:05 kravemir