alpine 3.6
obsolete weakness #93

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:

gpsd/src/gpsd-3.16/contrib/motosend.c

Context:

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

 	default:
		fprintf(stderr, "invalid speed\n");
		return 1;
	}

	if ((fd = open(argv[2], O_RDWR | O_NONBLOCK | O_NOCTTY, 0644)) == -1)
		err(1, "open");

	tcgetattr(fd, &term);
	cfmakeraw(&term);
	cfsetospeed(&term, speed);
	cfsetispeed(&term, speed);
	term.c_cc[VMIN] = 8;
	term.c_cc[VTIME] = 1;
	term.c_cflag &= ~(PARENB | PARODD | CRTSCTS);
	term.c_cflag |= CREAD | CLOCAL;
	term.c_iflag = term.c_oflag = term.c_lflag = (tcflag_t) 0;

	if (tcsetattr(fd, TCSANOW | TCSAFLUSH, &term) == -1)
		err(1, "tcsetattr");

	tcflush(fd, TCIOFLUSH);
	t = 0; n = 0;
	while (1){
		usleep(1000);
		bzero(buf, BSIZ);
		if ((l = read(fd, buf, BSIZ)) == -1)
			if (!(EINTR == errno || EAGAIN == errno))
				err(1, "read");

		if (l > 0){
			printf("%s", gpsd_hexdump(buf, l));
			fflush(stdout);
		}
		/* allow for up to "n" resends, once per second */
		if (((s = time(NULL)) > t) && (n < 1)){
			t = s;
			n++;
			moto_send(fd, argv[3], argv[4]);
		}
	}
	return 0;
}

char moto_gen_checksum(char *buf, int len){
	int n;
	char ck = '\0';

	for (n = 0; n < len; n++)
		ck ^= buf[n]; 

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.