Age | Commit message (Collapse) | Author | Files | Lines |
|
bConfigurationValue in sysfs can be 3 digits (1byte value) + 1 new line
= 4 bytes
In it's current form a bConfigurationValue of 128 will be detected as
not null terminated due to the trailing newline, simple fix is to just
extend the array size to 5
|
|
Close the image file before exiting the function
Problem detected by the Coverity tool
CID 1042549 (#2 of 3): Resource leak (RESOURCE_LEAK)9. leaked_storage:
Variable "image" going out of scope leaks the storage it points to.
|
|
Close the image file before exiting the function
Problem detected by the Coverity tool
CID 1042550 (#1 of 15): Resource leak (RESOURCE_LEAK)7. leaked_storage:
Variable "image" going out of scope leaks the storage it points to.
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
discovered_devs_append takes a reference to the past in dev, so we must
release our own reference.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
If usbi_sanitize_device fails we need to continue from the beginning of
the loop, rather then going on with the device we've just free-ed.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
..\libusb\hotplug.c(255): warning C4244: '=' : conversion from
'ssize_t' to 'int', possible loss of data
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
a bug introduced in the last commit.
|
|
The check for NULL != cached_device was unnecessary and caused clang's
static analysis to print out a warning.
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
It is now possible to have a read access and submit control transfers
to all USB devices using libusb, please note that controllers and hubs
also appear as devices.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Note the new netbsd_usb.c is an unmodified copy of openbsd_usb.c with
s/obsd/netbsd done on it. The reason for this split is that the openbsd
developers have been working on various improvements for their userspace
usb support, and adding support for those means breaking netbsd support,
by giving netbsd its own backend we can add support for the openbsd
improvements without breaking netbsd support.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Since the buffer pointer will later be casted to ``struct
libusb_control_setup *'', it should point to memory aligned to at least
2 bytes boundary as that's the strictest requirement of the struct fields.
Also, use a (void *) casting trick to convince the compiler the cast is
safe, to fix warnings such as:
/usr/local/include/libusb-1.0/libusb.h: In function 'libusb_control_transfer_get_setup':
/usr/local/include/libusb-1.0/libusb.h:1435:9: error: cast increases required alignment of target type [-Werror=cast-align]
/usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_setup':
/usr/local/include/libusb-1.0/libusb.h:1464:39: error: cast increases required alignment of target type [-Werror=cast-align]
/usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_transfer':
/usr/local/include/libusb-1.0/libusb.h:1509:39: error: cast increases required alignment of target type [-Werror=cast-align]
cc1: all warnings being treated as errors
This actually can lead to failure to build from the sources for certain
projects which use -Werror=cast-align on ARM.
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
If a device is open, the device's fd will trigger a POLLERR condition
once it is removed. Sometimes this can occur well before the udev
monitor sends the remove event. This can also be caught early if
the device is not currently open but an attempt to open it is made.
In both situations, this can be caught early and processed so that
the device does not continue to show up in the device list after it
has been disconnected but before the udev monitor processes the event.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
When libusb_hotplug_register_callback gets called with the
LIBUSB_HOTPLUG_ENUMERATE flag, there may still be hotplug events pending
in the hotplug pipe, waiting for dispatching from libusb_handle_events.
This means that the user callback can be called twice for arrival of the
same device, once from libusb_hotplug_register_callback, since the device
is already part of the usb_devs list, and once from libusb_handle_events
when it reads the event from the hotplug pipe.
This could be fixed by adding a mechanism to pause hotplug handling, then
drain the hotplug pipe (ie by calling libusb_handle_events from
libusb_hotplug_register_callback), before iterating over the usb_devs list,
and then un-pausing hotplug handling afterwards, doing this however requires
a lot of hairy code, which will be prone to dead-locking.
OTOH it is quite simple for user applications which care about this to detect
this and ignore the 2nd call, so lets simply document this may happen and
be done with it.
Note that this is also the solution which ie libudev has choosen, there is
no way with libudev to get a device-list + listen for device arrival / removal
without running into the same problem.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
from hotplug_register_callback
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Calling user callbacks with locks held is a bad idea and should be avoided
whenever possible. Before this patch this could lead ie to the following hang:
1) User calls libusb_hotplug_register_callback with the
LIBUSB_HOTPLUG_ENUMERATE flag
2) libusb_hotplug_register_callback calls the user callback while holding the
hotplug_cbs_lock
3) The callback calls a synchronous libusb function
4) The synchronous libusb function calls libusb_handle_events
5) There is an hotplug event waiting in the hotplug pipe and
libusb_handle_events calls usbi_hotplug_match
6) usbi_hotplug_match tries to take the lock a 2nd time
7) hang / assert / abort (depending on the platform)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
If we write the remove event to the pipe before doing the list_del,
in theory another thread can process the event and unref the device before
it has been removed from usb_devs.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Closes #130
|
|
* Also fixes and closes #129 again
|
|
* Closes #129
|
|
|
|
* Also fix an issue with LIBUSB_LOG_LEVEL_NONE
|
|
* This change makes it easier to debug issues in UI applications
which don't necessarily have a console connected to stderr.
* Outputting to the debugger shouldn't occur in normal situations so
this change has to be explicitly enabled by a build-time config flag.
* Uses OutputDebugString() on Windows platforms or the syslog facility
on other OSes, if available.
* Also align the report of configure defaults to autotool's.
|
|
It is possible for the extra socket flags (available from 2.6.27 on) to be
defined but not available. Check for this case and set the flags correctly
on the netlink socket.
|
|
When a transfer is submitted, the device is referenced in libusb_submit_transfer()
and unreferenced in usbi_handle_transfer_completion(). This transfer could potentially
be freed by any user callback, or is freed by libusb if LIBUSB_TRANSFER_FREE_TRANSFER
is set in the flags. The call to unreference the device uses this potentially freed
memory. Reading the device handle beforehand will prevent this disaster.
|
|
windows_clock_gettime()
* When the timer thread is created in windows_init(), it performs an
initialisation phase in which it uses QueryPerformanceFrequency() to determine
if there is a high resolution timer available, and sets hires_frequency and
hires_ticks_to_ps appropriately. However, since windows_init() does not wait for
this initialisation phase to complete, windows_clock_gettime() can be called
before hires_frequency and hires_ticks_to_ps have been updated. This can result
in windows_clock_gettime() temporarily returning real-time clock values even
though the platform supports a monotonic clock.
* See http://sourceforge.net/mailarchive/forum.php?thread_name=1373620013-3574-1-git-send-email-simon.haggett%40realvnc.com&forum_name=libusbx-devel
|
|
* When the timer thread is created in wince_init(), it performs an initialisation
phase in which it uses QueryPerformanceFrequency() to determine if there is a
high resolution timer available, and sets hires_frequency and hires_ticks_to_ps
appropriately. However, since wince_init() does not wait for this initialisation
phase to complete, wince_clock_gettime() can be called before hires_frequency
and hires_ticks_to_ps have been updated. This can result in
wince_clock_gettime() temporarily returning real-time clock values even though
the platform supports a monotonic clock.
* See http://sourceforge.net/mailarchive/forum.php?thread_name=1373619997-3535-1-git-send-email-simon.haggett%40realvnc.com&forum_name=libusbx-devel
|
|
* fd_to_winfd() currently returns INVALID_WINFD if fd is 0, but usbi_create_fd()
can legally assign an fd number of 0 if poll_fd[0] is not already occupied.
* Transfers which are assigned an fd number of 0 for their event handle are then
unable to have their event handle retrieved later on.
See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-PATCH-1-1-Windows-fd-to-winfd-shouldn-t-treat-fd-0-as-invalid-tt1535.html
|
|
Xcode 4.3 do not provide autotools anymore.
libusbx now provides a Xcode project to ease build Mac OS X.
|
|
For messages received on the hotplug pipe, the message was read via
usbi_read() (ssize_t) and compared against the size of the message
struct (size_t). usbi_read() returns -1 on an error condition, so some
systems can cast the ssize_t to size_t for the comparison, making it
equal to SIZE_MAX and causing the error check condition to incorrectly
evaluate to false.
|
|
Defensively set return-by-reference value to -1 in error condition
NB: The comments do not match the implementation.
Comments: "[return] the index of the configuration matching a specific
bConfigurationValue in the idx output parameter, or -1 if the config was
not found"
There is a code path where idx is never touched. Perhaps clients of the
function are careful to only read idx if the return value is success,
but also setting idx to -1 is much safer.
|
|
There shouldn't be any problems with any supported version of OSX in
converting a UInt64 to an unsigned long. They should be the same size
but even if they are not the session should still be unique.
|
|
|
|
|
|
|
|
|
|
libusb-1.0.0.dylib not libusbx.dylib. Added several xcconfig files to make source control and documentation easier. Reorganised a few files' positions within the project. Disable strict aliasing since libusbx breaks strict aliasing rules anyway. Set project format as 3.1-compatible.
Conflicts:
Xcode/libusbx.xcodeproj/project.pbxproj
|
|
|
|
|
|
Xcode do not use ./configure so the config.h file needs to be generated
by hand.
This config.h is the minimal file for libusbx built using Xcode.
|
|
|