alpine 3.9
obsolete weakness #539

1

Weakness Breakdown


Definition:

An obsolete weakness occurs when someone uses deprecated or obsolete functions when building a system. As a programming language evolves, some functions occasionally become obsolete.

Warning code(s):

This C routine is considered obsolete.

File Name:

dahdi-tools/src/dahdi-tools-2.11.1/xpp/xtalk/xusb_libusb.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.9 obsolete weakness.

 	}
retry_read:
	switch (iface->transfer_type) {
	case XUSB_TT_BULK:
		ret = usb_bulk_read(xusb_device->impl->handle, ep_in, buf, len, timeout);
		break;
	case XUSB_TT_INTERRUPT:
		ret = usb_interrupt_read(xusb_device->impl->handle, ep_in, buf, len, timeout);
		break;
	default:
		ret = -EAFNOSUPPORT;
		break;
	}
	if (ret < 0) {
		XUSB_DBG(iface, "read from endpoint 0x%x failed: (%d) %s\n",
			ep_in, ret, usb_strerror());
		memset(buf, 0, len);
		return ret;
	}
	if (!ret) {
		XUSB_ERR(iface, "read to endpoint 0x%x short read[%d]: (%d)\n",
			ep_in, retries, ret);
		if (retries++ > MAX_RETRIES)
			return -EFAULT;
		usleep(100);
		goto retry_read;
	}
	dump_packet(LOG_DEBUG, DBG_MASK, __func__, buf, ret);
	return ret;
}

/*
 * Serialize calls to usb_find_busses()/usb_find_devices()
 */

static const key_t	SEM_KEY = 0x1a2b3c4d;
static int semid = -1;	/* Failure */

static void xusb_lock_usb()
{
	struct sembuf	sembuf;

	while (semid < 0) {
		/* Maybe it was already created? */
		semid = semget(SEM_KEY, 1, 0);
		if (semid < 0) {
			/* No, let's create ourselves */
			semid = semget(SEM_KEY, 1, IPC_CREAT | IPC_EXCL | 0644);
			if (semid < 0) {
				/* Someone else won the race to create it */ 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.