alpine 3.6
misc weakness #252

4

Weakness Breakdown


Definition:

The software specifies permissions for a security-critical resource in a way that allows the resource to be read or modified by unintended actors.

Warning code(s):

This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data.

File Name:

strongswan/src/strongswan-5.5.3/src/libstrongswan/utils/compat/windows.c

Context:

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

 		sc = accept(s, NULL, NULL);
		if (sc >= 0)
		{
			closesocket(s);
			s = sc;
			if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY,
						   (void*)&on, sizeof(on)) == 0 &&
				setsockopt(c, IPPROTO_TCP, TCP_NODELAY,
						   (void*)&on, sizeof(on)) == 0)
			{
				sv[0] = s;
				sv[1] = c;
				return 0;
			}
		}
	}
	closesocket(s);
	closesocket(c);
	return -1;
}

/**
 * See header
 */
char* getpass(const char *prompt)
{
	static char buf[64] = "";
	char *pos;
	HANDLE in, out;
	DWORD mode, written = 0, total, done;

	out = GetStdHandle(STD_OUTPUT_HANDLE);
	in = GetStdHandle(STD_INPUT_HANDLE);

	if (out == INVALID_HANDLE_VALUE || in == INVALID_HANDLE_VALUE ||
		!GetConsoleMode(out, &mode) || !GetConsoleMode(in, &mode))
	{
		return NULL;
	}

	total = strlen(prompt);
	while (written < total)
	{
		if (!WriteConsole(out, prompt + written, total - written, &done, NULL))
		{
			return NULL;
		}
		written += done;
	}
 

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.