alpine 3.9
obsolete weakness #562

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:

alsa-utils/src/alsa-utils-1.1.8/alsactl/daemon.c

Context:

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

 		sig = SIGUSR2;
	else if (strcmp(cmd, "quit") == 0)
		sig = SIGTERM;
	if (sig == SIGHUP) {
		error("Unknown kill command '%s'", cmd);
		return -EINVAL;
	}
	pid = read_pid_file(pidfile);
	if (pid > 0) {
		if (kill(pid, sig) >= 0)
			return 0;
		return -errno;
	}
	return 0;
}

static int check_another_instance(const char *pidfile)
{
	long pid;

	pid = read_pid_file(pidfile);
	if (pid >= 0) {
		/* invoke new card rescan */
		if (kill(pid, SIGUSR1) >= 0) {
			usleep(1000);
			pid = read_pid_file(pidfile);
			if (pid >= 0)
				return 1;
		}
	}
	return 0;
}

int state_daemon(const char *file, const char *cardname, int period,
		 const char *pidfile)
{
	int count = 0, pcount, psize = 0, i, j, k, changed = 0;
	time_t last_write, now;
	unsigned short revents;
	struct card **cards = NULL;
	struct pollfd *pfd = NULL, *pfdn;

	if (check_another_instance(pidfile))
		return 0;
	rescan = 1;
	signal(SIGABRT, signal_handler_quit);
	signal(SIGTERM, signal_handler_quit);
	signal(SIGINT, signal_handler_quit);
	signal(SIGUSR1, signal_handler_rescan);
	signal(SIGUSR2, signal_handler_save_and_quit); 

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.