* Enlarge the device name buffer a bit as with a deep enough hierarchy we might
actually hit this limit. * Use snprintf() instead of sprintf() as suggested by CID 6447 (even though the USB module isn't supposed to return such a malformed string). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39908 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -31,7 +31,7 @@ typedef struct {
|
|||||||
mutex lock;
|
mutex lock;
|
||||||
uint32 reference_count;
|
uint32 reference_count;
|
||||||
|
|
||||||
char name[32];
|
char name[64];
|
||||||
void *link;
|
void *link;
|
||||||
|
|
||||||
sem_id notify;
|
sem_id notify;
|
||||||
@@ -61,12 +61,13 @@ usb_raw_device_added(usb_device newDevice, void **cookie)
|
|||||||
return B_NO_MORE_SEMS;
|
return B_NO_MORE_SEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
char deviceName[32];
|
char deviceName[64];
|
||||||
memcpy(deviceName, &newDevice, sizeof(usb_device));
|
memcpy(deviceName, &newDevice, sizeof(usb_device));
|
||||||
if (gUSBModule->usb_ioctl('DNAM', deviceName, sizeof(deviceName)) >= B_OK) {
|
if (gUSBModule->usb_ioctl('DNAM', deviceName, sizeof(deviceName)) >= B_OK) {
|
||||||
sprintf(device->name, "bus/usb/%s", deviceName);
|
snprintf(device->name, sizeof(device->name), "bus/usb/%s", deviceName);
|
||||||
} else {
|
} else {
|
||||||
sprintf(device->name, "bus/usb/%08lx", newDevice);
|
snprintf(device->name, sizeof(device->name), "bus/usb/%08lx",
|
||||||
|
newDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
device->device = newDevice;
|
device->device = newDevice;
|
||||||
|
|||||||
Reference in New Issue
Block a user