centos 6
obsolete weakness #29

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:

openct-0.6.19/src/ifd/ifd-smph.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 6 obsolete weakness.

   int res;

  if (slot)
    {
      ct_error("%s: bad slot index %u", 
	       (privd->prot == prot_phoenix) ? "phoenix" : "smartmouse", slot);
      return IFD_ERROR_INVALID_SLOT;
    }

  tcflush(dev->fd, TCIOFLUSH);
  if (smph_setctrl(dev, (privd->prot == prot_phoenix) 
		   ? TIOCM_RTS | TIOCM_CTS | TIOCM_DTR 
		   : TIOCM_CTS | TIOCM_DTR) < 0)
    return -1;

  /* FIXME: use ifd_serial_reset instead? */
  sleep(1);

  if (smph_setctrl(dev, (privd->prot == prot_phoenix) 
		   ? TIOCM_CTS | TIOCM_DTR :
		   TIOCM_RTS | TIOCM_CTS | TIOCM_DTR) < 0)
    return -1;

  /* FIXME: use ifd_serial_reset instead? */
  usleep(200);

  if ((res = smph_recv(reader, 0, (unsigned char *)atr, size, dev->timeout)) < 1)
    return -1;

  ifd_debug(1, "Bytes received %i\n", res);
  return res;
}

/*
 * Send command to IFD
 */
static int _smph_send(ifd_device_t *dev, const unsigned char *buffer, 
		      size_t len)
{
  unsigned char tmp;
  unsigned int i;
  struct pollfd pfd;
  
  ifd_debug(3, "data:%s", ct_hexdump(buffer, len));
  for (i = 0; i < len; i++)
    {
      if (write(dev->fd, buffer + i, 1) < 1)
	return -1;
      tcdrain(dev->fd);
    } 

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.