alpine 3.8
obsolete weakness #35

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:

gammu/src/gammu-1.39.0/libgammu/device/usb/usb.c

Context:

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

 
ssize_t GSM_USB_Write(GSM_StateMachine *s, const void *buf, size_t nbytes)
{
	GSM_Device_USBData *d = &s->Device.Data.USB;
	int rc = LIBUSB_ERROR_TIMEOUT, ret = 0, repeat = 0;

	while (repeat < 10 && (rc == LIBUSB_ERROR_TIMEOUT || rc == LIBUSB_ERROR_INTERRUPTED || rc == LIBUSB_ERROR_OTHER || rc == LIBUSB_ERROR_NO_MEM)) {
		rc = libusb_bulk_transfer(d->handle, d->ep_write, (void *)buf, nbytes, &ret, 1000);
		/* This seems to be some strange failure on partial data transfer */
		if (rc == LIBUSB_ERROR_OTHER && ret != 0) {
			smprintf(s, "Other error while writing, but got some data\n");
			rc = 0;
			break;
		}
		if (rc == LIBUSB_ERROR_TIMEOUT && ret != 0) {
			smprintf(s, "Timeout while write, but some data were written\n");
			rc = 0;
			break;
		}
		if (rc != 0) {
			smprintf(s, "Failed to write to usb (%d)!\n", rc);
			GSM_USB_Error(s, rc);
		}
		repeat++;
		usleep(1000);
	}
	if (rc != 0) {
		return -1;
	}
	return ret;
}

/**
 * Find parameters for FBUS connection over USB.
 */
gboolean FBUSUSB_Match(GSM_StateMachine *s, libusb_device *dev, struct libusb_device_descriptor *desc)
{
	int c, i, a;
	int rc;
	struct libusb_config_descriptor *config;
	GSM_Device_USBData *d = &s->Device.Data.USB;
	const unsigned char *buffer;
	int buflen;
	struct cdc_extra_desc *extra_desc;
	struct cdc_union_desc *union_desc = NULL;
	const struct libusb_endpoint_descriptor *ep1, *ep2;

	/* We care only about Nokia */
	if (desc->idVendor != NOKIA_VENDOR_ID) return FALSE;
 

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.