* 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:
Michael Lotz 2010-12-21 00:42:21 +00:00
parent bf905cfe0c
commit b950cc6532

View File

@ -31,7 +31,7 @@ typedef struct {
mutex lock;
uint32 reference_count;
char name[32];
char name[64];
void *link;
sem_id notify;
@ -61,12 +61,13 @@ usb_raw_device_added(usb_device newDevice, void **cookie)
return B_NO_MORE_SEMS;
}
char deviceName[32];
char deviceName[64];
memcpy(deviceName, &newDevice, sizeof(usb_device));
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 {
sprintf(device->name, "bus/usb/%08lx", newDevice);
snprintf(device->name, sizeof(device->name), "bus/usb/%08lx",
newDevice);
}
device->device = newDevice;